Repository navigation
fix: backport load data and parquet compatibility - #24332
mergify[bot] merged 1 commit into
Conversation
ⓘ You've reached your Qodo monthly free-tier limit. Reviews pause until next month — upgrade your plan to continue now, or link your paid account if you already have one. |
There was a problem hiding this comment.
Pull request overview
This PR backports a set of user-visible ingestion compatibility fixes from main to 3.0-dev, focusing on LOAD DATA semantics (timezone-aware TIMESTAMP parsing, JSON casts, AUTO_INCREMENT zero handling) and improved Parquet type/DECIMAL support, along with expanded unit/BVT coverage.
Changes:
- Extend Parquet scanning/type mapping (including logical types and DECIMAL loading/rescaling) and bump
parquet-go. - Make ingestion AUTO_INCREMENT
0handling respectsql_mode/NO_AUTO_VALUE_ON_ZERO, and update distributed snapshot/load_data fixtures accordingly. - Add/expand unit tests for Parquet, sql_mode caching, JSON→JSON cast, and LOAD DATA TIMESTAMP timezone behavior.
Reviewed changes
Copilot reviewed 30 out of 32 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/sql/colexec/external/parquet.go | Parquet mapper/loader changes (logical types, DECIMAL handling, dictionary support, scan behavior). |
| pkg/sql/colexec/external/parquet_test.go | Expanded unit coverage for Parquet mapping/dictionary/DECIMAL behaviors. |
| pkg/sql/colexec/external/external_timestamp_timezone_test.go | Tests for session-timezone-aware TIMESTAMP parsing in LOAD DATA paths. |
| pkg/sql/colexec/preinsert/preinsert.go | AUTO_INCREMENT zero handling updated to follow sql_mode semantics. |
| pkg/sql/colexec/preinsert/preinsert_test.go | Unit tests covering the new AUTO_INCREMENT/sql_mode behavior. |
| pkg/sql/plan/function/func_cast.go | Adds JSON→JSON cast support to avoid LOAD DATA failures into JSON columns. |
| pkg/sql/plan/function/func_cast_test.go | Tests for JSON casting behavior (including JSON→JSON). |
| pkg/frontend/session.go | Session cache/init for sql_mode NO_AUTO_VALUE_ON_ZERO parsing behavior. |
| pkg/frontend/session_sql_mode_test.go | Unit tests validating sql_mode NO_AUTO_VALUE_ON_ZERO parsing and caching. |
| pkg/container/types/date.go | Adds helper for converting “days from unix epoch” into Date (used by Parquet logical DATE mapping). |
| go.mod | Bumps github.com/parquet-go/parquet-go dependency (and related module adjustments). |
| go.sum | Corresponding dependency checksum updates. |
| test/distributed/cases/snapshot/sys_restore_to_nonsys_account.sql | Sets/restores sql_mode to include NO_AUTO_VALUE_ON_ZERO around AUTO_INCREMENT inserts. |
| test/distributed/cases/snapshot/sys_restore_to_nonsys_account.result | Expected output updated for sql_mode statements. |
| test/distributed/cases/snapshot/sys_restore_to_newnonsys_account.sql | Same sql_mode scoping adjustment for AUTO_INCREMENT inserts. |
| test/distributed/cases/snapshot/sys_restore_to_newnonsys_account.result | Expected output updated for sql_mode statements. |
| test/distributed/cases/snapshot/snapshot_restore_to_table_partition.sql | Same sql_mode scoping adjustment for AUTO_INCREMENT inserts. |
| test/distributed/cases/snapshot/snapshot_restore_to_table_partition.result | Regenerated expected output (now populated). |
| test/distributed/cases/snapshot/restore_fk_table.sql | Same sql_mode scoping adjustment; fixes a trailing un-numbered line in fixture. |
| test/distributed/cases/snapshot/restore_fk_table.result | Expected output updated for sql_mode statements. |
| test/distributed/cases/snapshot/cluster_level_snapshot_restore_to_nonsys_account.sql | Same sql_mode scoping adjustment; fixes a trailing un-numbered line in fixture. |
| test/distributed/cases/snapshot/cluster_level_snapshot_restore_to_nonsys_account.result | Expected output updated for sql_mode statements. |
| test/distributed/cases/load_data/load_data.sql | Fixture updates to align LOAD DATA behavior with sql_mode/AUTO_INCREMENT semantics. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
f367e03 to
1be5fe8
Compare
c0d6d06 to
21a4941
Compare
21a4941 to
f04deec
Compare
XuPeng-SH
left a comment
There was a problem hiding this comment.
Requesting changes — not on the backport content itself (which I agree is desirable and was already approved by three reviewers), but because the PR as-is cannot merge and the rebase will need a non-trivial judgment call that deserves another look before it lands.
Blocking
Merge conflicts with #24329 (Hive-partitioned Parquet), now merged into 3.0-dev at d8a036c:
CONFLICT (content): Merge conflict in pkg/sql/colexec/external/parquet.go
CONFLICT (content): Merge conflict in pkg/sql/colexec/external/parquet_test.go
Both collide in the part of scanParquetFile / newParquetHandler that this PR rewrites end-to-end for logical-type and DECIMAL support. The Hive PR added:
param.refreshPartitionValues()call beforenewParquetHandlerh.filepathColIndex/h.partitionColIndices/h.hasPhysicalColfieldsh.fillVirtualColumns(bat, param, proc)at the end of each batchh.rowCountOnlycompletion logic that nilsparam.parqhand advancesFileparam.FileFinisHivePartitionColandfindColumnIgnoreCasegating inprepare
None of those live in this PR's rewrite. After rebase, three things need to be preserved/re-integrated — not auto-resolved:
scanParquetFilehas to keep callingrefreshPartitionValues+fillVirtualColumns+ honoringrowCountOnly. Otherwise Hive external tables silently return empty partition columns / never finalize the last file.prepare()has to keep theisHivePartitionCol/ContainExternalHidenColbranches that skip physical-column lookup for virtual columns. Otherwise Hive BVT fails with "column not found" on partition columns.getMappermust keepfindColumnIgnoreCase's ambiguity check that 24329 added. If the backport reintroduces a case-sensitive lookup, mixed-case Hive partition DDL regresses.
Could you rebase onto current 3.0-dev and push, so the final parquet.go/parquet_test.go shape can be reviewed as a whole? I don't want to pre-approve a file I haven't seen the merged version of.
Non-blocking nits I noticed while reviewing
pkg/frontend/session.go:581addsatomic.StoreInt32(&ses.sqlModeNoAutoValueOnZero, -1)inNewSession, but 3.0-dev already resets this inInitSystemVariablesat line 275. The new reset isn't wrong (belt-and-suspenders during session construction before sysvars init), but consider whether it's actually reachable beforeInitSystemVariablesruns. If not, it can be dropped.preinsert_test.gostill setspreInsert.ctr.tblId = preInsert.TableDef.TblIdat lines 502/561/610.ctr.tblIdexists on 3.0-dev but isn't read by the refactored code path (which usespreInsert.autoIncrementTableID). These writes are dead. Not this PR's fault — inherited from 3.0-dev — but if you're touching the tests, removing them would reduce confusion.- Commit is a single squash titled "fix: backport load data and parquet compatibility". Given the scope (parquet mapper overhaul + AUTO_INCREMENT sql_mode + JSON→JSON cast + DATE helper + sysvar cache init), splitting into ~4 commits in the squash message (one per upstream PR being ported, with upstream PR numbers referenced) would make this much easier to bisect later. Not blocking — just a request for the final merge message.
What I'd approve
A rebased version that visibly preserves (1)–(3) under "Blocking" and whose BVT run includes both the load_data backport cases and the existing hive_partition_external_table.sql (24329's BVT). Happy to re-review quickly once it's pushed.
Co-authored-by: Copilot <[email protected]>
|
@Copilot I rebased PR #24332 onto current 3.0-dev after #24329 and pushed the final merged parquet.go/parquet_test.go shape at 11246d9.\n\nChecked the blocking items from this review:\n\n1. scanParquetFile keeps refreshPartitionValues(), fillVirtualColumns(), and rowCountOnly finalization.\n2. prepare() keeps isHivePartitionCol and ContainExternalHidenCol branches, and now still validates ColIndex before indexing.\n3. physical columns still use findColumnIgnoreCase(), including the ambiguity check.\n\nI also adjusted the getData finish/offset unit test to match #24329/base behavior after the rebase.\n\nValidation run locally:\n |
XuPeng-SH
left a comment
There was a problem hiding this comment.
LGTM on the rebased version (f04deec).
Verified the three integration points I flagged as must-preserve after the #24329 merge into 3.0-dev:
scanParquetFilestill callsrefreshPartitionValuesbeforenewParquetHandler, still callsfillVirtualColumnswhen partition/filepath cols are projected, and still honorsrowCountOnlyto nilparam.parqh+ advanceFileparam.FileFin(parquet.go:43-85).preparekeeps theisHivePartitionCol→partitionColIndicesbranch and theContainExternalHidenCol→filepathColIndexbranch before physical-column lookup, and only setshasPhysicalColfor real parquet-backed columns (parquet.go:160-218).findColumnIgnoreCasestill ambiguity-checks multiple case-insensitive matches (parquet.go:131-157).
The production delta vs. 3.0-dev is now ~500 lines in parquet.go (down from ~800 pre-rebase) and reads surgically: uint8/uint16/uint32 widening mappers, bounds-check on attr.ColIndex in prepare, NYI message tweak for nested types, plus the DECIMAL/DATE/TIMESTAMP mapper overhauls from #22714 that were the point of this backport.
Retracting one earlier nit: I was wrong about NewSession:581 atomic.StoreInt32(&ses.sqlModeNoAutoValueOnZero, -1) being redundant with InitSystemVariables:275. Go zero-init would leave the field at 0, which GetSqlModeNoAutoValueOnZero treats as "cached: NO_AUTO_VALUE_ON_ZERO absent" rather than "uncached". The -1 at NewSession time is load-bearing.
Remaining dead preInsert.ctr.tblId = … writes at preinsert_test.go:502,561,610 — inherited from 3.0-dev, not this PR's regression; leave for a separate cleanup.
CI is rerunning on the rebased head; merge after it clears.
Merge Queue Status
This pull request spent 20 seconds in the queue, including 3 seconds running CI. Required conditions to merge
|
What type of PR is this?
Which issue(s) this PR fixes:
issue #24188
What this PR does / why we need it:
Backports and adapts the missing user-visible LOAD DATA / parquet compatibility fixes from main to 3.0-dev:
Validation:
go test ./pkg/sql/colexec/external -run 'Test(ReadFileOffsetCompressedUnsafe|_getColData_Timestamp|parquet|Parquet)' -count=1go test ./pkg/sql/colexec/preinsert -run 'Test(ShouldConvertZeroToNullSkipOnUpdate|ShouldTreatZeroAsAutoIncrFallback|PreInsert)' -count=1go test ./pkg/sql/plan/function -run 'TestCastJsonToJson|TestCastJson' -count=1go test ./pkg/frontend -run 'TestGetSqlModeNoAutoValueOnZero|TestEnableRemapHint' -count=1