Skip to content

[SPARK-57762][SQL] Add missing error class COLUMN_IS_NOT_VARIANT_TYPE#56872

Closed
szehon-ho wants to merge 2 commits into
apache:masterfrom
szehon-ho:SPARK-57762
Closed

[SPARK-57762][SQL] Add missing error class COLUMN_IS_NOT_VARIANT_TYPE#56872
szehon-ho wants to merge 2 commits into
apache:masterfrom
szehon-ho:SPARK-57762

Conversation

@szehon-ho

Copy link
Copy Markdown
Member

What changes were proposed in this pull request?

The semi-structured extraction operator (:) throws the COLUMN_IS_NOT_VARIANT_TYPE error class (from ExtractSemiStructuredFields and SemiStructuredExtractResolver) when applied to a column that is not of the VARIANT type, but the error class was never registered in error-conditions.json. This registers the error condition so it resolves correctly through the error framework, and adds a test.

Why are the changes needed?

The error class was used but not declared. Hitting this path raised INTERNAL_ERROR ("Cannot find main error class 'COLUMN_IS_NOT_VARIANT_TYPE'") instead of the intended error.

Does this PR introduce any user-facing change?

No. Previously this code path raised an INTERNAL_ERROR because the error class was unregistered; now the intended error message is produced.

How was this patch tested?

Added a unit test in QueryCompilationErrorsSuite. Also ran SparkThrowableSuite.

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

Generated-by: Cursor (Claude Opus 4.8)

@szehon-ho

Copy link
Copy Markdown
Member Author

cc @haoyangeng-db @cloud-fan @dongjoon-hyun could you please help review? Thanks!

@dongjoon-hyun dongjoon-hyun 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.

+1, LGTM. Thank you, @szehon-ho .

@MaxGekk MaxGekk 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.

1 blocking, 0 non-blocking, 0 nits.
The error class registration is correct, but the CI failure needs a golden file fix before merging.

Correctness (1)

  • error-conditions.json:1032: registering this class changes the observed output for SELECT NULL:a AS b; in type-coercion-edge-cases.sql from INTERNAL_ERROR to AnalysisException(COLUMN_IS_NOT_VARIANT_TYPE) -- the golden file still records the old output and must be regenerated. See inline.

],
"sqlState" : "0A000"
},
"COLUMN_IS_NOT_VARIANT_TYPE" : {

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.

Registering this error class causes the sql - extended tests CI job to fail with 2 tests:

  • type-coercion-edge-cases.sql
  • type-coercion-edge-cases.sql_analyzer_test

The input file contains SELECT NULL:a AS b;, which hits this error path. Before this PR the golden file recorded the old output:

"errorClass" : "INTERNAL_ERROR",
"message" : "Cannot find main error class 'COLUMN_IS_NOT_VARIANT_TYPE'"

Now that the class is registered the actual output changes to a proper AnalysisException with errorClass: COLUMN_IS_NOT_VARIANT_TYPE, but sql/core/src/test/resources/sql-tests/results/type-coercion-edge-cases.sql.out (line 53) still records the old text.

Please regenerate the golden files:

SPARK_GENERATE_GOLDEN_FILES=1 build/sbt 'sql/testOnly *SQLQueryTestSuite -- -z type-coercion-edge-cases'

and include the updated type-coercion-edge-cases.sql.out (and the matching analyzer-results/type-coercion-edge-cases.sql.out) in this PR.

@dongjoon-hyun dongjoon-hyun 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.

Could you make a CI happy to make it sure, @szehon-ho ?

@dongjoon-hyun

Copy link
Copy Markdown
Member

I revisited this in order to merge Today, but it seems that we have no CI success until now.

### What changes were proposed in this pull request?
The semi-structured extraction operator (`:`) throws the `COLUMN_IS_NOT_VARIANT_TYPE` error class (from `ExtractSemiStructuredFields` and `SemiStructuredExtractResolver`) when applied to a column that is not of the VARIANT type, but the error class was never registered in `error-conditions.json`. This registers the error condition so it resolves correctly through the error framework, and adds a test.

### Why are the changes needed?
The error class was used but not declared. Hitting this path raised `INTERNAL_ERROR` ("Cannot find main error class 'COLUMN_IS_NOT_VARIANT_TYPE'") instead of the intended error.

### Does this PR introduce _any_ user-facing change?
No. Previously this code path raised an `INTERNAL_ERROR` because the error class was unregistered; now the intended error message is produced.

### How was this patch tested?
Added a unit test in `QueryCompilationErrorsSuite`. Also ran `SparkThrowableSuite`.

### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Cursor (Claude Opus 4.8)
Regenerate type-coercion-edge-cases.sql golden files so SELECT NULL:a
expects AnalysisException(COLUMN_IS_NOT_VARIANT_TYPE) instead of
INTERNAL_ERROR.
@szehon-ho

Copy link
Copy Markdown
Member Author

Thanks @dongjoon-hyun. I've rebased onto the latest master to re-trigger CI. I looked into the earlier failures and they appear unrelated to this change (which only adds the COLUMN_IS_NOT_VARIANT_TYPE error class and updates the corresponding golden files). Will keep an eye on the new run and confirm once it's green.

@szehon-ho szehon-ho closed this in aec7c17 Jul 21, 2026
szehon-ho added a commit that referenced this pull request Jul 21, 2026
### What changes were proposed in this pull request?
The semi-structured extraction operator (`:`) throws the `COLUMN_IS_NOT_VARIANT_TYPE` error class (from `ExtractSemiStructuredFields` and `SemiStructuredExtractResolver`) when applied to a column that is not of the VARIANT type, but the error class was never registered in `error-conditions.json`. This registers the error condition so it resolves correctly through the error framework, and adds a test.

### Why are the changes needed?
The error class was used but not declared. Hitting this path raised `INTERNAL_ERROR` ("Cannot find main error class 'COLUMN_IS_NOT_VARIANT_TYPE'") instead of the intended error.

### Does this PR introduce _any_ user-facing change?
No. Previously this code path raised an `INTERNAL_ERROR` because the error class was unregistered; now the intended error message is produced.

### How was this patch tested?
Added a unit test in `QueryCompilationErrorsSuite`. Also ran `SparkThrowableSuite`.

### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Cursor (Claude Opus 4.8)

Closes #56872 from szehon-ho/SPARK-57762.

Authored-by: Szehon Ho <szehon.apache@gmail.com>
Signed-off-by: Szehon Ho <szehon.apache@gmail.com>
(cherry picked from commit aec7c17)
Signed-off-by: Szehon Ho <szehon.apache@gmail.com>
@szehon-ho

Copy link
Copy Markdown
Member Author

Merge Summary:

Posted by merge_spark_pr.py

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants