Skip to content

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 <[email protected]>
Signed-off-by: Kent Yao <[email protected]>
(cherry picked from commit ccc436d)
Signed-off-by: Kent Yao <[email protected]>
@yaooqinn
Copy link
Member Author

Thanks, merged to master and 3.5

@yaooqinn yaooqinn deleted the SPARK-46388 branch December 13, 2023 12:10
turboFei pushed a commit to turboFei/spark that referenced this pull request Nov 6, 2025
…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 apache#44326 from yaooqinn/SPARK-46388.

Authored-by: Kent Yao <[email protected]>
Signed-off-by: Kent Yao <[email protected]>
(cherry picked from commit ccc436d)
Signed-off-by: Kent Yao <[email protected]>
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