Skip to content

Conversation

@Pajaraja
Copy link
Contributor

What changes were proposed in this pull request?

Change TypeCoercionBase so that the only outputs that are casted are the ones that need to be casted.

Why are the changes needed?

Remove redundant CAST.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Existing golden file test cte-recursion.

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

No.

@github-actions github-actions bot added the SQL label Dec 10, 2025
Copy link
Member

@dongjoon-hyun dongjoon-hyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please file a JIRA issue due to the number of lines, @Pajaraja . 😄

if (widerType.isDefined && widerType.get == dt) {
Alias(Cast(attr, dt), attr.name)()
if (attr.dataType != dt) {
Alias(Cast(attr, dt, Some(conf.sessionLocalTimeZone)), attr.name)()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is non-trivial because you are adding Some(conf.sessionLocalTimeZone).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a test with time sensitive CAST in the golden file, but I think it's okay either way since ResolveTimeZone is in the same batch as TypeCoercion.

I changed it here to have parity with how Union/Intersect/Except do it, but it should be no-op.

@Pajaraja Pajaraja changed the title [SQL][MINOR] Remove redundant casting in rCTEs [SQL][SPARK-54669] Remove redundant casting in rCTEs Dec 10, 2025
@Pajaraja
Copy link
Contributor Author

Added a Jira ticket

@dongjoon-hyun dongjoon-hyun changed the title [SQL][SPARK-54669] Remove redundant casting in rCTEs [SPARK-54669][SQL] Remove redundant casting in rCTEs Dec 10, 2025
Copy link
Member

@dongjoon-hyun dongjoon-hyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for revising the PR, @Pajaraja .

cc @cloud-fan from the original PR.

SELECT n+1, stamp FROM t1 WHERE n < 5)
SELECT * FROM t1
-- !query analysis
[Analyzer test output redacted due to nondeterminism]
Copy link
Contributor

@peter-toth peter-toth Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this non-deterministic? If it is really non-deterministic, can you add a deterministic test?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same question

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was nondeterministic because the original relation was Date. I changed into string now.
It's deterministic now.

Copy link
Contributor

@peter-toth peter-toth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Maybe we could simplify the new test a bit, but that's just a nit.

@cloud-fan
Copy link
Contributor

thanks, merging to master!

@cloud-fan cloud-fan closed this in bed030c Dec 11, 2025
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.

4 participants