Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-46388][SQL] HiveAnalysis misses the pattern guard of query.resolved #44326

Closed
wants to merge 4 commits into from

Conversation

yaooqinn
Copy link
Member

@yaooqinn yaooqinn commented Dec 13, 2023

What changes were proposed in this pull request?

This PR adds query.resolved as a pattern guard when HiveAnalysis converts InsertIntoStatement to InsertIntoHiveTable.

Why are the changes needed?

Due to https://github.com/apache/spark/pull/41262/files#diff-ed19f376a63eba52eea59ca71f3355d4495fad4fad4db9a3324aade0d4986a47R1080, the table field is resolved regardless of the query field. Before, it never got a chance to be resolved as HiveTableRelation and then match any rule of HiveAnalysis. But now, it gets the chance always and results in a spark-kernel bug - Invalid call to toAttribute on unresolved object.

insert into t2 select cast(a as short) from t where b=1;
Invalid call to toAttribute on unresolved object

Does this PR introduce any user-facing change?

no, bugfix for 3.5 and later

How was this patch tested?

added new test

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

no

@yaooqinn
Copy link
Member Author

@yaooqinn yaooqinn closed this in ccc436d Dec 13, 2023
yaooqinn added a commit that referenced this pull request Dec 13, 2023
…solved`

### What changes were proposed in this pull request?

This PR adds `query.resolved` as a pattern guard when HiveAnalysis converts InsertIntoStatement to InsertIntoHiveTable.

### Why are the changes needed?

Due to https://github.com/apache/spark/pull/41262/files#diff-ed19f376a63eba52eea59ca71f3355d4495fad4fad4db9a3324aade0d4986a47R1080, the `table` field is resolved regardless of the query field. Before, it never got a chance to be resolved as `HiveTableRelation` and then match any rule of HiveAnalysis. But now, it gets the chance always and results in a spark-kernel bug - `Invalid call to toAttribute on unresolved object.`

```
insert into t2 select cast(a as short) from t where b=1;
Invalid call to toAttribute on unresolved object
```

### Does this PR introduce _any_ user-facing change?

no, bugfix for 3.5 and later

### How was this patch tested?

added new test

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

no

Closes #44326 from yaooqinn/SPARK-46388.

Authored-by: Kent Yao <yao@apache.org>
Signed-off-by: Kent Yao <yao@apache.org>
(cherry picked from commit ccc436d)
Signed-off-by: Kent Yao <yao@apache.org>
@yaooqinn
Copy link
Member Author

Thanks, merged to master and 3.5

@yaooqinn yaooqinn deleted the SPARK-46388 branch December 13, 2023 12:10
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.

3 participants