Skip to content

Commit

Permalink
change
Browse files Browse the repository at this point in the history
  • Loading branch information
D3Hunter committed Oct 16, 2023
1 parent 5ed8c9b commit 1b7436e
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/realtikvtest/importintotest4/global_sort_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"encoding/json"
"fmt"
"net/url"
"slices"
"strconv"
"testing"
"time"
Expand Down Expand Up @@ -122,3 +123,30 @@ func (s *mockGCSSuite) TestGlobalSortBasic() {
s.NoError(err)
s.Len(files, 0)
}

func (s *mockGCSSuite) TestGlobalSortMultiFiles() {
var allData []string
for i := 0; i < 10; i++ {
var content []byte
keyCnt := 1000
for j := 0; j < keyCnt; j++ {
idx := i*keyCnt + j
content = append(content, []byte(fmt.Sprintf("%d,test-%d\n", idx, idx))...)
allData = append(allData, fmt.Sprintf("%d test-%d", idx, idx))
}
s.server.CreateObject(fakestorage.Object{
ObjectAttrs: fakestorage.ObjectAttrs{BucketName: "gs-multi-files", Name: fmt.Sprintf("t.%d.csv", i)},
Content: content,
})
}
slices.Sort(allData)
s.prepareAndUseDB("gs_multi_files")
s.server.CreateBucketWithOpts(fakestorage.CreateBucketOpts{Name: "sorted"})
s.tk.MustExec("create table t (a bigint primary key , b varchar(100), key(b), key(a,b), key(b,a));")
// 1 subtask, encoding 10 files using 4 threads.
sortStorageURI := fmt.Sprintf("gs://sorted/gs_multi_files?endpoint=%s", gcsEndpoint)
importSQL := fmt.Sprintf(`import into t FROM 'gs://gs-multi-files/t.*.csv?endpoint=%s'
with thread=4, cloud_storage_uri='%s'`, gcsEndpoint, sortStorageURI)
s.tk.MustQuery(importSQL)
s.tk.MustQuery("select * from t").Sort().Check(testkit.Rows(allData...))
}

0 comments on commit 1b7436e

Please sign in to comment.