Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lightning: return 0 early on empty parquet files (#52519) #52522

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion br/pkg/lightning/mydump/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ func SampleFileCompressRatio(ctx context.Context, fileMeta SourceFileMeta, store
// SampleParquetDataSize samples the data size of the parquet file.
func SampleParquetDataSize(ctx context.Context, fileMeta SourceFileMeta, store storage.ExternalStorage) (int64, error) {
totalRowCount, err := ReadParquetFileRowCountByFile(ctx, store, fileMeta)
if err != nil {
if totalRowCount == 0 || err != nil {
return 0, err
}

Expand Down
8 changes: 6 additions & 2 deletions br/pkg/lightning/mydump/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1108,7 +1108,7 @@ func TestSampleFileCompressRatio(t *testing.T) {
require.InDelta(t, ratio, 5000.0/float64(bf.Len()), 1e-5)
}

func TestSampleParquetDataSize(t *testing.T) {
func testSampleParquetDataSize(t *testing.T, count int) {
s := newTestMydumpLoaderSuite(t)
store, err := storage.NewLocalStorage(s.sourceDir)
require.NoError(t, err)
Expand All @@ -1133,7 +1133,7 @@ func TestSampleParquetDataSize(t *testing.T) {
t.Logf("seed: %d", seed)
rand.Seed(seed)
totalRowSize := 0
for i := 0; i < 1000; i++ {
for i := 0; i < count; i++ {
kl := rand.Intn(20) + 1
key := make([]byte, kl)
kl, err = rand.Read(key)
Expand Down Expand Up @@ -1166,3 +1166,7 @@ func TestSampleParquetDataSize(t *testing.T) {
// expected error within 10%, so delta = totalRowSize / 10
require.InDelta(t, totalRowSize, size, float64(totalRowSize)/10)
}
func TestSampleParquetDataSize(t *testing.T) {
t.Run("count=1000", func(t *testing.T) { testSampleParquetDataSize(t, 1000) })
t.Run("count=0", func(t *testing.T) { testSampleParquetDataSize(t, 0) })
}
Loading