Skip to content

Conversation

@gotocoding-DB
Copy link
Contributor

@gotocoding-DB gotocoding-DB commented Nov 6, 2024

What changes were proposed in this pull request?

MakeDTInterval and MakeYMInterval do not catch Java exceptions in nullSafeEval like it does MakeInterval. So we making behavior similar.

Why are the changes needed?

To show to users readable nice error message.

Does this PR introduce any user-facing change?

Yes, I changed error message type in error-conditions.json => it's a behavioral change for clients who parse error message type or error message text.

How was this patch tested?

There already were few tests to check behavior, I just changed expected error type.

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

Yes, Copilot used.

@github-actions github-actions bot added the SQL label Nov 6, 2024
@gotocoding-DB gotocoding-DB changed the title [WIP] [SPARK-50226] Throw ARITHMETIC_OVERFLOW in MakeYMInterval and MakeDTInterval [WIP] [SPARK-50226] [SQL] Throw ARITHMETIC_OVERFLOW in MakeYMInterval and MakeDTInterval Nov 6, 2024
@gotocoding-DB
Copy link
Contributor Author

Had a conversation with @mihailom-db.
We should use INTERVAL_ARITHMETIC_OVERFLOW, add 2 subclasses to it: with hint and without hint and use "without_hint" variation for Make[DT|YM]Interval.

@mihailomilosevic2001
Copy link
Contributor

Update title please. No spaces between tags and the name of the PR should be the same as the ticket on jira.

@gotocoding-DB gotocoding-DB changed the title [WIP] [SPARK-50226] [SQL] Throw ARITHMETIC_OVERFLOW in MakeYMInterval and MakeDTInterval [WIP][SPARK-50226][SQL] Correct MakeDTInterval and MakeYMInterval to catch Java exceptions Nov 6, 2024
@gotocoding-DB
Copy link
Contributor Author

Update title please. No spaces between tags and the name of the PR should be the same as the ticket on jira.

Done.

@gotocoding-DB gotocoding-DB marked this pull request as draft November 6, 2024 11:29
@gotocoding-DB
Copy link
Contributor Author

gotocoding-DB commented Nov 8, 2024

CI fails, but testOnly org.apache.spark.sql.SparkSessionE2ESuite locally works fine (I've checked it 5 times, always green). Could it be useful just to restart CI (if yes – how to do it? I can just add 1 more commit with merging to fresh master, but maybe there is just a button "retry").

UPD Found that testOnly org.apache.spark.sql.SingleLevelAggregateHashMapSuite really fails, so it's not because of flaps.

@mihailomilosevic2001
Copy link
Contributor

@srielau Does this look good to you?

@mihailomilosevic2001
Copy link
Contributor

You can remove [WIP] and Draft as well.

@gotocoding-DB gotocoding-DB force-pushed the SPARK-50226-overflow-error branch from 98c4d11 to d7352a4 Compare November 8, 2024 12:52
@gotocoding-DB gotocoding-DB changed the title [WIP][SPARK-50226][SQL] Correct MakeDTInterval and MakeYMInterval to catch Java exceptions [SPARK-50226][SQL] Correct MakeDTInterval and MakeYMInterval to catch Java exceptions Nov 8, 2024
@gotocoding-DB gotocoding-DB marked this pull request as ready for review November 8, 2024 18:08
Copy link
Contributor

@mihailomilosevic2001 mihailomilosevic2001 left a comment

Choose a reason for hiding this comment

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

LGTM except for few comments

@MaxGekk
Copy link
Member

MaxGekk commented Nov 13, 2024

+1, LGTM. Merging to master.
Thank you, @gotocoding-DB and @mihailom-db @srielau for review.

@MaxGekk MaxGekk closed this in bd94419 Nov 13, 2024
@MaxGekk
Copy link
Member

MaxGekk commented Nov 13, 2024

@gotocoding-DB Congratulations with your first contribution to Apache Spark!

@gotocoding-DB gotocoding-DB deleted the SPARK-50226-overflow-error branch November 13, 2024 17:46
Math.toIntExact(
Math.addExact(month.asInstanceOf[Int],
Math.multiplyExact(year.asInstanceOf[Int], MONTHS_PER_YEAR)))
} catch {
Copy link
Contributor

Choose a reason for hiding this comment

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

shall we add IntervalUtils.makeYearMonthInterval so that we duplicate less code between interpreted and codegen?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Off course we should deduplicate it, but I didn't succeed with it: #48773 (comment).
Max suggested to use StaticInvoke, I'll try it in separate PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

there is already makeDayTimeInterval and we can just follow it. Can you try it again and create a PR? We can help to check the code together.

Copy link
Contributor Author

@gotocoding-DB gotocoding-DB Nov 14, 2024

Choose a reason for hiding this comment

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

Ok, I'll do it a bit later.
UPD: #48848

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.

5 participants