Skip to content

Commit f4369d5

Browse files
craig[bot]andyyang890
andcommitted
Merge #145002
145002: sql/importer: fix export parquet for NULL values r=rharding6373 a=andyyang890 This patch fixes a bug where a NULL value could cause a parquet export to fail because we weren't ensuring NULL values were fully decoded being passing them to our parquet writer. Fixes #144998 Release note (bug fix): A bug where a NULL value could cause a parquet export to fail has been fixed. Co-authored-by: Andy Yang <[email protected]>
2 parents ffc9e28 + 2d60f57 commit f4369d5

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

pkg/sql/importer/exportparquet.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,8 @@ func (sp *parquetWriterProcessor) Run(ctx context.Context, output execinfra.RowR
170170
if err := memAcc.Grow(ctx, datumAllocSize); err != nil {
171171
return err
172172
}
173-
if !ed.IsNull() {
174-
if err := ed.EnsureDecoded(typs[i], alloc); err != nil {
175-
return err
176-
}
173+
if err := ed.EnsureDecoded(typs[i], alloc); err != nil {
174+
return err
177175
}
178176
// If we're encoding a DOidWrapper, then we want to cast
179177
// the wrapped datum. Note that we don't use

pkg/sql/importer/exportparquet_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,15 @@ INDEX (y))`)
367367
stmt: `EXPORT INTO PARQUET 'nodelocal://1/uncompress'
368368
FROM SELECT * FROM foo `,
369369
},
370+
{
371+
filePrefix: "null_vals_with_index",
372+
prep: []string{
373+
`CREATE TABLE null_vals_with_index (a STRING PRIMARY KEY, b STRING, INDEX b_idx (b ASC))`,
374+
`INSERT INTO null_vals_with_index VALUES ('a', NULL)`,
375+
},
376+
stmt: `EXPORT INTO PARQUET 'nodelocal://1/null_vals_with_index'
377+
FROM SELECT * FROM null_vals_with_index@b_idx`,
378+
},
370379
}
371380

372381
for _, test := range tests {

0 commit comments

Comments
 (0)