Skip to content

Spark: Fix RewriteManifestsSparkAction sortBy() for dotted partition field names - #17428

Open
agnes-xinyi-lu wants to merge 2 commits into
apache:mainfrom
agnes-xinyi-lu:xinyilu/fix
Open

Spark: Fix RewriteManifestsSparkAction sortBy() for dotted partition field names#17428
agnes-xinyi-lu wants to merge 2 commits into
apache:mainfrom
agnes-xinyi-lu:xinyilu/fix

Conversation

@agnes-xinyi-lu

Copy link
Copy Markdown
Contributor

Fixes RewriteManifestsSparkAction.sortBy() to backtick-quote partition field names, so a literal . in a partition field's name (e.g. from partitioning on a nested source column) isn't misparsed as nested-field access. Adds a regression test.
For issue #17425

@github-actions github-actions Bot added the spark label Jul 30, 2026
@agnes-xinyi-lu agnes-xinyi-lu changed the title Spark 4.1:Spark: Fix RewriteManifestsSparkAction sortBy() for dotted partition field names Spark: Fix RewriteManifestsSparkAction sortBy() for dotted partition field names Jul 30, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How about spark/v4.0 and spark/v3.5? Shall we fix there too?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done.

Column[] partitionColumns =
partitionFieldClustering.stream()
.map(p -> col(DATA_FILE_PARTITION_COLUMN_NAME + "." + p))
.map(p -> col(DATA_FILE_PARTITION_COLUMN_NAME + ".`" + p + "`"))

@uros-b uros-b Jul 30, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The backtick quoting is written as

". + p + ""

without escaping an embedded backtick in p.

A partition field name containing a backtick, e.g.

"a`b"

produces a malformed col() expression and an AnalysisException at runtime.

The correct idiom would be

p.replace("", "``")

e.g. used by SparkSchemaUtil.indexQuotedNameById.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

updated, PTAL @uros-b thanks!

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants