Skip to content

Commit

Permalink
[SPARK-51246][SQL] Make InTypeCoercion produce resolved Casts
Browse files Browse the repository at this point in the history
### What changes were proposed in this pull request?

Make `InTypeCoercion` produce resolved `Cast`s.

### Why are the changes needed?

This is important to avoid recursing down the tree in the single-pass Analyzer.

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

No.

### How was this patch tested?

Existing tests.

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

No.

Closes #49991 from vladimirg-db/vladimirg-db/make-in-coercion-produce-resolved-casts.

Authored-by: Vladimir Golubev <vladimir.golubev@databricks.com>
Signed-off-by: Max Gekk <max.gekk@gmail.com>
(cherry picked from commit 500bf78)
Signed-off-by: Max Gekk <max.gekk@gmail.com>
  • Loading branch information
vladimirg-db authored and MaxGekk committed Feb 18, 2025
1 parent 3000f94 commit ebc8df2
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,13 @@ abstract class TypeCoercionHelper {
// IN subquery expression.
if (commonTypes.length == lhs.length) {
val castedRhs = rhs.zip(commonTypes).map {
case (e, dt) if e.dataType != dt => Alias(Cast(e, dt), e.name)()
case (e, dt) if e.dataType != dt =>
Alias(Cast(e, dt).withTimeZone(conf.sessionLocalTimeZone), e.name)()
case (e, _) => e
}
val newLhs = lhs.zip(commonTypes).map {
case (e, dt) if e.dataType != dt => Cast(e, dt)
case (e, dt) if e.dataType != dt =>
Cast(e, dt).withTimeZone(conf.sessionLocalTimeZone)
case (e, _) => e
}

Expand Down

0 comments on commit ebc8df2

Please sign in to comment.