fix(spark)!: reject lossy write conversions - #1269
Conversation
c5297d1 to
a377d26
Compare
Filesystem Overwrite, Ignore, and ErrorIfExists round-trip as append, while partitioned writes lose their layout and can produce rows invisible to table reads. Incoming file UPDATE is converted into replacement of the entire target directory. Reject save modes and partition or bucket metadata that FileHolder cannot preserve, and reject incoming UPDATE. Ordinary append and legacy append payloads remain supported. Substrait v0.102.0 restricts create_mode to CTAS, so new INSERT payloads leave it unspecified and ambiguous legacy non-append modes are rejected. BREAKING CHANGE: Spark filesystem write conversion now rejects non-append, partitioned, and bucketed commands, incoming file UPDATE, and legacy INSERT payloads carrying non-append create modes. Execute these writes directly in Spark until their semantics can be represented by a supported extension.
a377d26 to
83bf5d4
Compare
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (4)
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughFilesystem write conversion now supports unpartitioned, unbucketed append writes. Export and import paths reject unsupported write modes or settings. Tests cover successful appends and rejected cases. ChangesFilesystem append writes
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~12 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to This change intentionally restricts Spark filesystem write conversion to unpartitioned, unbucketed appends, so unsupported writes now fail instead of silently changing semantics. No concrete merge-blocking risk is evident beyond the documented breaking change. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change reduces destructive write exposure by rejecting operations and layouts that cannot be preserved. Supported append writes remain compatible. No introduced security concern was established, but caller authorization for output paths and interrupted-write recovery remain unverified. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
nielspardon
left a comment
There was a problem hiding this comment.
Please reword "Substrait v0.102.0 restricts create_mode to CTAS" in the description. The spec defines create_mode for CTAS and says nothing about INSERT, and v0.102.0 didn't change that, so rejecting it here is this binding's compatibility choice rather than a spec rule. The inline comments cover two gaps the guards still leave open.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
|
Thanks for the wording and scope feedback. I drafted the description to distinguish the spec’s CTAS create modes from this binding’s append-only file INSERT support, narrow the legacy-payload claim, and leave CTAS-based support for other save modes as a separate change. The local patch also covers Hive layout guards and MODIFIED_RECORDS output. The full build and independent review pass; code and description updates remain unpublished. |
Apply partition and bucket checks to every V1 write command, reject unsupported file output modes before input conversion, and verify extension roundtrips and Hive rejection paths. BREAKING CHANGE: Spark conversion now rejects partitioned or bucketed Hive writes and file writes requesting MODIFIED_RECORDS output. Execute these unsupported writes directly in Spark.
|
Hive and file writes now share the layout guards, and file writes reject MODIFIED_RECORDS before converting the input. The append path and tests are simplified. The description narrows legacy compatibility to known unpartitioned, unbucketed targets and leaves CTAS support for other save modes as separate work. |
Filesystem Overwrite, Ignore, and ErrorIfExists round-trip as append, while partitioned and bucketed file or Hive writes lose their layout. Incoming file UPDATE is converted into replacement of the target directory, and MODIFIED_RECORDS output is discarded.
Reject write modes, output modes, and layout metadata that the current conversion cannot preserve. Keep ordinary file append supported. Legacy APPEND_IF_EXISTS payloads remain supported only for targets known to be unpartitioned and unbucketed: FileHolder does not retain enough information to identify legacy payloads that lost layout metadata.
The spec defines create_mode for CTAS and is silent on INSERT. This binding leaves it unspecified on new file INSERT payloads and rejects legacy non-append values that its append-only conversion cannot honor. Supporting other save modes through ExtensionWrite(CTAS, create_mode) remains a separate change.
Summary by CodeRabbit
BREAKING CHANGE: Spark write conversion now rejects partitioned or bucketed V1 file/Hive commands, non-append filesystem save modes, incoming file UPDATE, MODIFIED_RECORDS output, and legacy filesystem INSERT plans with non-append create modes. Execute unsupported writes directly in Spark. Replay legacy APPEND_IF_EXISTS payloads only when their targets are known to be unpartitioned and unbucketed.