Skip to content

Conversation

@amaliujia
Copy link
Contributor

What changes were proposed in this pull request?

ParseToDate should load the EvalMode in main thread instead of loading it in a lazy val.

Why are the changes needed?

This is because it is sometimes hard to estimate when the lazy val is executed while the SQLConf where we load the EvalMode is thread local.

Does this PR introduce any user-facing change?

No

How was this patch tested?

Existing UT

@amaliujia
Copy link
Contributor Author

@cloud-fan

@github-actions github-actions bot added the SQL label May 24, 2023
@amaliujia
Copy link
Contributor Author

I needed to re-generate the golden files.

extends RuntimeReplaceable with ImplicitCastInputTypes with TimeZoneAwareExpression {

override lazy val replacement: Expression = format.map { f =>
Cast(GetTimestamp(left, f, TimestampType, timeZoneId), DateType, timeZoneId)
Copy link
Contributor

Choose a reason for hiding this comment

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

can we pass evalMode to cast here as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

emp 4 100.0
emp 5 1000.0
emp 6 - no dept 500.0
java.lang.IllegalArgumentException
Copy link
Contributor

Choose a reason for hiding this comment

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

what happens here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Auto golden file regeneration gives this update

override lazy val replacement: Expression = format.map { f =>
Cast(GetTimestamp(left, f, TimestampType, timeZoneId), DateType, timeZoneId)
}.getOrElse(Cast(left, DateType, timeZoneId)) // backwards compatibility
Cast(GetTimestamp(left, f, TimestampType, timeZoneId, ansiEnabled), DateType, timeZoneId)
Copy link
Contributor

Choose a reason for hiding this comment

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

the Cast here still doesn't have the evalMod passed... But it's a good catch that we should pass ansiEnabled to GetTimestamp

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmmm oops I see what is missing. Added.

@cloud-fan
Copy link
Contributor

thanks, merging to master!

@cloud-fan cloud-fan closed this in 88f69d6 May 29, 2023
czxm pushed a commit to czxm/spark that referenced this pull request Jun 12, 2023
### What changes were proposed in this pull request?

ParseToDate should load the EvalMode in main thread instead of loading it in a lazy val.

### Why are the changes needed?

This is because it is sometimes hard to estimate when the lazy val is executed while the SQLConf where we load the EvalMode is thread local.

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

No

### How was this patch tested?

Existing UT

Closes apache#41298 from amaliujia/SPARK-43779.

Authored-by: Rui Wang <[email protected]>
Signed-off-by: Wenchen Fan <[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.

2 participants