[SPARK-59273][SQL] Complete CHAR/VARCHAR support at core execution boundaries - #58541
Open
srielau wants to merge 2 commits into
Open
[SPARK-59273][SQL] Complete CHAR/VARCHAR support at core execution boundaries#58541srielau wants to merge 2 commits into
srielau wants to merge 2 commits into
Conversation
…undaries Treat first-class CharType/VarcharType as the string family in JDBC getters/setters, partition decoding, row-to-column conversion, na.fill, and ANALYZE COLUMN stats so standardSemantics no longer fails at these boundaries.
srielau
commented
Sep 5, 2026
| case java.sql.Types.BOOLEAN => BooleanType | ||
| case java.sql.Types.CHAR if conf.charVarcharAsString => StringType | ||
| case java.sql.Types.CHAR | ||
| if conf.charVarcharAsString && !conf.charVarcharStandardSemantics => StringType |
Contributor
Author
There was a problem hiding this comment.
Should this test !conf.charVarcharFirstClassTypes instead? preserveCharVarcharTypeInfo is also a first-class mode. With preserve=true and charVarcharAsString=true, this branch currently degrades JDBC CHAR/VARCHAR to STRING, contrary to the shared first-class-type contract. The VARCHAR branch below has the same issue. Could we also extend the precedence test to cover this combination?
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?
When
spark.sql.charVarchar.standardSemantics.enabledis true,CharTypeandVarcharTypeare first-classStringTypesubtypes. Several execution-boundary matchers still used exactStringType(or an explicit CHAR/VARCHAR reject), so those paths failed or skipped constrained string columns.This patch treats CHAR/VARCHAR as the string family at:
CHAR/VARCHARkeep first-class types when standard semantics is on, even ifcharVarcharAsStringis also set)RowToColumnConverterDataFrame.na.fillfor string replacement valuesANALYZE TABLE ... FOR COLUMNS(string-family stats)Read-side CHAR padding and VARCHAR overflow still come from existing CAST /
ApplyCharTypePaddingpaths rather than being reimplemented in each converter.Why are the changes needed?
With first-class CHAR/VARCHAR, JDBC scans/writes, file-only partition discovery, columnar conversion,
na.fill("..."), and column stats currently throw or silently ignore those columns. That blocks enabling standard semantics.JIRA: https://issues.apache.org/jira/browse/SPARK-59273 (subtask of SPARK-58794)
Does this PR introduce any user-facing change?
Yes, when
spark.sql.charVarchar.standardSemantics.enabledis true (still default false):EXCEED_LIMIT_LENGTH.df.na.fill("x")fills null CHAR/VARCHAR columns (CHAR values are padded by CAST).ANALYZE TABLE ... FOR COLUMNScollects string-family stats on CHAR/VARCHAR instead of rejecting them.How was this patch tested?
Added/extended unit tests:
JDBCSuite: read CHAR/VARCHAR and arrays; write CHAR/VARCHAR; standard semantics wins overcharVarcharAsStringin schema inferenceParquetV1PartitionDiscoverySuite/ParquetV2PartitionDiscoverySuite: CHAR/VARCHAR partition values and oversize VARCHARRowToColumnConverterSuite: CHAR/VARCHAR and nested CHAR arraysDataFrameNaFunctionsSuite:na.fillon CHAR/VARCHARStatisticsCollectionSuite:ANALYZE TABLE ... FOR COLUMNSon CHAR/VARCHARWas this patch authored or co-authored using generative AI tooling?
Generated-by: Cursor Grok 4.6