Skip to content

[GLUTEN-12538][VL] Support native TIMESTAMP_NTZ Delta writes - #13512

Draft
felipepessoto wants to merge 3 commits into
apache:mainfrom
felipepessoto:felipepessoto-native-ntz-delta-writer
Draft

felipepessoto wants to merge 3 commits into
apache:mainfrom
felipepessoto:felipepessoto-native-ntz-delta-writer

Conversation

@felipepessoto

@felipepessoto felipepessoto commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: ff96f335479906882d087e030ea5dc3532427316

Dimension Assessment Rationale
Change confidence 8.5/10 ↑ All eight Delta CI shards passed on this head; focused checks cover NTZ tags and field names with either Arrow offset width.
↓ The x86 Spark 4.1 MERGE test is red. Running one task at a time reproduced the same wrapped NOT NULL exception twice on the PR and twice on unmodified main.

What changes are proposed in this pull request?

Relates to #11622 and #12538.

Velox writes Delta TIMESTAMP_NTZ columns as Parquet microseconds with isAdjustedToUTC=false, including nested fields. Ordinary TIMESTAMP columns in the same file retain isAdjustedToUTC=true. This changes data-file writing, not Delta’s statistics fallback (#13510).

Merge order: I’ll keep this PR in draft until #13756 (Arrow timestamp tagging) and #13757 (NTZ operator validation) merge. Then I’ll rebase, drop the shared changes they cover, and keep only what the Delta writer still needs, including its regression tests.

How was this patch tested?

All 36 focused Arrow, write-gate, and validator checks passed on the rebased sources, including nested NTZ fields alongside strings and binary data with either Arrow offset width. Earlier Spark 3.5 and 4.1 runs verified native Parquet footers and compared rows, partition paths, and file statistics against vanilla Spark. Regressions cover shuffled NTZ map keys, nested field names, calendar rebasing, and null checks that must not enable unsupported expressions.

Was this patch authored or co-authored using generative AI tooling?

Generated-by: GitHub Copilot (GPT-6 Astra and GPT-6.2 Astra)

Copilot AI balanced review requested due to automatic review settings November 1, 2026 02:53
@github-actions github-actions Bot added CORE works for Gluten Core VELOX DOCS labels Nov 1, 2026
@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Shared Arrow and Parquet changes affect non-Delta consumers and depend on pinned Velox behavior unavailable in this checkout, requiring human review of broader native integration and regression validation.

No open issues 🎉

What changed in this PR

Enables native Velox Delta writes for TIMESTAMP_NTZ, including nested and mixed timestamp schemas. Statistics fallback and NTZ literal preservation remain separate work.

Changes:

  • Preserve NTZ semantics across Arrow and Parquet schemas, prepare null-struct payloads safely, and retain microsecond precision when generating partition IDs.
  • Remove Delta 4’s blanket NTZ rejection while retaining existing writer gates, and allow field-access projections through mixed NTZ structs.
  • Add native and Spark regression coverage and document supported behavior and remaining limitations.
File Description
gluten-ut/​spark35/​src-delta/​test/​scala/​org/​apache/​spark/​sql/​execution/​datasources/​GlutenDeltaTimestampNtzWriteSuite.scala Tests native writer provenance, schemas, values, statistics, and partitions against Spark writes.
gluten-substrait/​src/​main/​scala/​org/​apache/​gluten/​extension/​columnar/​validator/​Validators.scala Allows field access and null predicates through mixed NTZ structs.
gluten-arrow/​src/​main/​scala/​org/​apache/​spark/​sql/​utils/​SparkArrowUtil.scala Preserves NTZ logical-type metadata in Arrow fields.
docs/​backends/​velox/​get-started/​VeloxDelta.md Documents native NTZ writing, gates, and remaining limitations.
cpp/​velox/​utils/​VeloxWriterUtils.h Declares schema, input-preparation, and partition-key helpers.
cpp/​velox/​utils/​VeloxWriterUtils.cc Implements NTZ schema reconstruction, null-struct preparation, and microsecond partition keys.
cpp/​velox/​tests/​VeloxWriterUtilsTest.cc Tests schema semantics, timestamp precision, and non-mutating input preparation.
cpp/​velox/​tests/​CMakeLists.txt Registers the writer utility tests.
cpp/​velox/​operators/​writer/​VeloxParquetDataSource.cc Applies the schema and input-preparation helpers when writing Parquet.
cpp/​velox/​jni/​VeloxJniWrapper.cc Uses exact timestamp microseconds for partition ID generation.
backends-velox/​src-delta4/​test/​scala/​org/​apache/​gluten/​execution/​VeloxDelta4WriteSuite.scala Checks native NTZ writes and explicit validation fallback.
backends-velox/​src-delta4/​test/​scala/​org/​apache/​gluten/​delta/​GlutenDeltaNativeWriteGateSuite.scala Tests nested NTZ eligibility and retained encoding and validation gates.
backends-velox/​src-delta4/​main/​scala/​org/​apache/​spark/​sql/​delta/​GlutenDeltaNativeWriteGate.scala Removes the blanket NTZ writer rejection.

Review effort: Balanced

@felipepessoto
felipepessoto marked this pull request as draft November 1, 2026 02:59
@felipepessoto
felipepessoto force-pushed the felipepessoto-native-ntz-delta-writer branch from 8c51593 to db9060c Compare November 3, 2026 00:45
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

@felipepessoto
felipepessoto force-pushed the felipepessoto-native-ntz-delta-writer branch from db9060c to 101864c Compare November 5, 2026 21:43
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

@felipepessoto
felipepessoto force-pushed the felipepessoto-native-ntz-delta-writer branch from 101864c to 07cba69 Compare November 6, 2026 21:18
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

@felipepessoto
felipepessoto force-pushed the felipepessoto-native-ntz-delta-writer branch from 07cba69 to 16d256d Compare November 16, 2026 00:03
@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

1 similar comment
@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

@github-actions github-actions Bot added the BOLT label Nov 20, 2026
@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

@felipepessoto
felipepessoto force-pushed the felipepessoto-native-ntz-delta-writer branch from e98a1f3 to 758c7f4 Compare November 25, 2026 21:33
@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

felipepessoto and others added 3 commits November 27, 2026 10:06
Preserve NTZ schemas through Arrow and native Parquet writing, prepare null nested values safely at the writer boundary, and group timestamp partitions at microsecond precision. Keep ordinary timestamp semantics and existing fallback gates, with native and independent Spark regression coverage.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Move the Arrow-specific schema regression out of the shared Delta suite so ClickHouse test compilation does not require gluten-arrow. Preserve the metadata, round-trip, and native writer assertions without adding backend dependencies.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…writes

Keep physical nested field names intact and read shuffle key types directly from the Spark C schema before Arrow loses map-key metadata. Mark corrected-calendar Parquet footers without rewriting data pages. Validate NTZ projections per expression branch so a supported null predicate cannot exempt its siblings.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@felipepessoto
felipepessoto force-pushed the felipepessoto-native-ntz-delta-writer branch from 758c7f4 to ff96f33 Compare November 27, 2026 18:14
@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BOLT CORE works for Gluten Core DOCS VELOX

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants