[SPARK-58794][SQL] Empty2Null, text, and Hive prune fallback for CHAR/VARCHAR - #58255
Open
srielau wants to merge 1 commit into
Open
[SPARK-58794][SQL] Empty2Null, text, and Hive prune fallback for CHAR/VARCHAR#58255srielau wants to merge 1 commit into
srielau wants to merge 1 commit into
Conversation
…/VARCHAR Treat CHAR/VARCHAR as a string family for partition empty-to-null and the text data source. Hive metastore filter conversion still excludes these keys, so under standard semantics prune them client-side instead.
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?
Follow-up on first-class CHAR/VARCHAR (
spark.sql.charVarchar.standardSemantics.enabled) so a few string-family call sites treatCharType/VarcharTypelikeSTRING.V1WritesappliesEmpty2Nullto nullable CHAR/VARCHAR partition columns (dataType.isInstanceOf[StringType]).CHAR(n>0)still pads''to spaces, so the empty CHAR case isCHAR(0).varcharKeysinSupportedAttribute: Hive's trailing-blank comparison is not Spark's). Under standard semantics that would scan every partition, soprunePartitionsFastFallbacknow also runs when a partition schema contains CHAR/VARCHAR. Pruning is then client-side with Spark's own predicates (CHAR compared without PAD SPACE; the test literal is'a 'forCHAR(5)).This is independent of #58130.
Why are the changes needed?
With first-class types, CHAR/VARCHAR stay in the plan instead of being rewritten to annotated STRING. Equality against
StringTypethen skips them:__HIVE_DEFAULT_PARTITION__USING textrejects a CHAR/VARCHAR schemaThe annotation-skipping idea was tried and dropped:
ApplyCharTypePaddinguses__CHAR_VARCHAR_TYPE_STRINGas an idempotence marker, so the annotation is load-bearing.Does this PR introduce any user-facing change?
Yes, only when
spark.sql.charVarchar.standardSemantics.enabledis true (still off by default).VARCHAR/CHAR(0)partition values become NULL like STRING.spark.read.schema("value CHAR(n)").text(...)is accepted.CHAR(5) = 'a'does not match a stored'a 'unless the literal carries the pad or an RTRIM collation is used.How was this patch tested?
sql/testOnly *CharVarcharTestSuite *V1WriteCommandSuite: 164 succeededhive/testOnly *HiveCharVarcharTestSuite: 58 succeededhive/testOnly *HivePartitionFilteringSuite*: 360 succeeded (Hive 2.3-4.1)Was this patch authored or co-authored using generative AI tooling?
Generated-by: Cursor Grok 4.6