Repository navigation
[SPARK-60397][SQL] Fix ORC filter pushdown on nanosecond timestamp columns read with a lower precision - #59654
Open
dongjoon-hyun wants to merge 1 commit into
Open
dongjoon-hyun wants to merge 1 commit into
dongjoon-hyun wants to merge 1 commit into
Conversation
…lumns read with a lower precision
HyukjinKwon
approved these changes
Oct 20, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
This PR aims to fix the ORC filter pushdown on
TIMESTAMP_LTZ(p)andTIMESTAMP_NTZ(p)columns when the ORC file was written with a higher precision thanp.Since SPARK-57823 (#57681), ORC pushes down the predicates on these columns. However, the ORC reader truncates the stored nanoseconds to the read precision (SPARK-57455, #56557), while ORC evaluates a pushed down predicate against the stored values. Unlike Parquet (SPARK-60380, #59641), an ORC file schema has the written precision through the Catalyst type attribute (
spark.sql.catalyst.type), andOrcFilters.createFilterbuilds aSearchArgumentfor each file from its file schema. So, this PR keeps the predicates with a value when the read precision is not lower than the written precision, and pushes down onlyIsNullandIsNotNullotherwise.OrcTypeOps.acceptsReadTypeis added (defaulttrue), likeParquetFilterOps.acceptsReadTypeof SPARK-60358 ([SPARK-60358][SQL] Fix Parquet filter pushdown onTIMEcolumns read with a lower precision #59606). The ops ofTIMESTAMP_LTZ(p)andTIMESTAMP_NTZ(p)returntrueonly forTIMESTAMP_LTZ(q)andTIMESTAMP_NTZ(q)withq >= p, respectively.OrcFilters.createFiltergets the read schema (requiredSchemain V1,readDataSchemain V2) and checksacceptsReadTypebefore it converts a predicate with a value on a Types Framework field.A foreign ORC timestamp column without the attribute cannot be read with the nanosecond timestamp types (
UNSUPPORTED_FEATURE.ORC_TYPE_CAST), so the written precision is always known here. Since it is known only for each file, the pushed filters in the query plan are not changed.Why are the changes needed?
The query results are wrong. For example,
00:00:00.123456789is read as00:00:00.1234567withTIMESTAMP_NTZ(7), but the pushed down=compares the literal with the stored value.<=>,<=andINreturn no rows in the same way, with both V1 and V2, with both the vectorized and the row-based readers, and forTIMESTAMP_LTZtoo. The expected result isArray([1970-01-01T00:00:00.123456700]), which is the result withspark.sql.orc.filterPushdown=false.Does this PR introduce any user-facing change?
Yes, this fixes the wrong query results in the unreleased branches (
master,branch-4.xandbranch-4.3), including v4.3.0-rc1 (2026-08-31) and v4.3.0-rc2 (2026-10-12). The predicates with a value are not pushed down anymore only for the files written with a higher precision than the read precision. The nanosecond timestamp types are a preview feature, which is disabled by default (spark.sql.timestampNanosTypes.enabled).How was this patch tested?
Pass the CIs with the newly added test cases in
OrcFilterSuiteandOrcV1FilterSuite. The end-to-end test case fails without this fix.Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Opus 5.5