Visitar URL original
[GLUTEN-13179][CORE] Fix NPE when a column has a null name by rdtr · Pull Request #13206 · apache/gluten · GitHub
Skip to content

[GLUTEN-13179][CORE] Fix NPE when a column has a null name - #13206

Merged
philo-he merged 2 commits into
apache:mainfrom
rdtr:null-name-attribute
Oct 10, 2026
Merged

philo-he merged 2 commits into
apache:mainfrom
rdtr:null-name-attribute

Conversation

@rdtr

@rdtr rdtr commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

What changes are proposed in this pull request?

I ran the Spark 4.2 test "SPARK-57725: resolve columns when the input plan has a null-named attribute" in GlutenDataFrameSuite, and it failed with a NullPointerException:

java.lang.NullPointerException: Cannot invoke "String.toLowerCase(java.util.Locale)" because "name" is null
  at org.apache.gluten.expression.ConverterUtils$.normalizeColName(ConverterUtils.scala:53)
  at org.apache.gluten.expression.ConverterUtils$.getShortAttributeName(ConverterUtils.scala:57)
  at org.apache.gluten.expression.ConverterUtils$.genColumnNameWithExprId(ConverterUtils.scala:71)
  at org.apache.gluten.expression.ConverterUtils$.collectAttributeNamesWithExprId(ConverterUtils.scala:91)
  at org.apache.gluten.substrait.rel.RelBuilder.makeReadRelForInputIterator(RelBuilder.java:163)

A column can have a null name. For example, you can make one with a StructField that has a null name in the DataFrame API. Spark itself also failed with an NPE on this, and Spark 4.2.0 fixed it (SPARK-57725). The new Spark test selects column b from a LocalRelation that also has a column with a null name.

In Gluten, the plan is LocalTableScan [null#0, b#1] -> RowToVeloxColumnar -> InputIteratorTransformer. Gluten makes a name like b#1 (name + # + expression ID) for each input column. normalizeColName makes the name lower case, but it doesn't check for null, so it throws the NPE.

I didn't check why this bug (looks like not new) is surfaced now, likely because before Spark failed first. Spark 4.2 fixed its side, so now the plan gets to Gluten and the NPE shows up there.

This PR changes normalizeColName to return an empty name for a null name. The generated name still has the expression ID, so the column becomes #0, and it is still unique. Like in Spark's fix, you can't refer to this column by name, but the query works.

Part of #13179

How was this patch tested?

  • Added a test to ConverterUtilsSuite. It calls genColumnNameWithExprId and genColumnNameWithoutExprId with a column that has a null name, and checks that they return #<exprId> and an empty name. It runs on all Spark versions.
  • Added a test to VeloxLocalTableScanSuite. It does the same thing as the Spark test: it selects b from a LocalRelation that has a column with a null name. It checks the result and that the Project runs in Velox. It runs with spark.gluten.sql.columnar.localTableScan on and off, so it covers both the native LocalTableScan and the RowToVeloxColumnar path. It runs only on Spark 4.2 or later, because older Spark versions fail on this plan by themselves.

Results:

  • Without this change: the VeloxLocalTableScanSuite test fails on Spark 4.2, and the ConverterUtilsSuite test fails on Spark 4.1. Both fail with the NPE above.
  • With this change, Spark 4.2: ConverterUtilsSuite (3 tests) and VeloxLocalTableScanSuite (19 tests) pass.
  • With this change, Spark 4.1: ConverterUtilsSuite (3 tests) and the other 18 tests in VeloxLocalTableScanSuite pass.

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

Generated-by: Claude Code (Claude Opus 5.5)

…umn names

An attribute can have a null name, for example when it comes from a StructField built with a null name. Spark 4.2 fixed its own column resolution for this case (SPARK-57725) and added a test for it. With Gluten, the test then failed with a NullPointerException in ConverterUtils.normalizeColName, which lower-cases the name when Gluten builds the column names of an input, such as "b#1".

Map a null name to an empty one. The generated name still includes the expression ID, such as "#0", so it stays unique.
@github-actions github-actions Bot added CORE works for Gluten Core VELOX labels Oct 5, 2026
@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

@philo-he philo-he left a comment

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.

LGTM. Thanks.

@zhouyuan

zhouyuan commented Oct 9, 2026

Copy link
Copy Markdown
Member

@rdtr would you please do a rebase? The CI issue should be gone with retry

@github-actions

Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

@philo-he

Copy link
Copy Markdown
Member

Updated on GitHub. Will merge the PR soon. Thanks.

@philo-he
philo-he merged commit 79df455 into apache:main Oct 10, 2026
56 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CORE works for Gluten Core VELOX

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants