New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-36921][SQL] Support ANSI intervals by DIV
#34257
Conversation
@MaxGekk Could you take a look? Thank you. I'm not quite sure if this PR will solve the SPARK-36921 |
ok to test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Peng-Lei Could you add a couple of end-to-end tests to intervals.sql
including a negative test:
SELECT DIV(INTERVAL '1' MONTH, INTERVAL '1' DAY);
Kubernetes integration test starting |
Kubernetes integration test status failure |
Literal(Period.ofYears(1))), 2L) | ||
checkEvaluation(IntegralDivide(Literal(Period.ofYears(1)), | ||
Literal(Period.ofMonths(3))), 4L) | ||
checkEvaluation(IntegralDivide(Literal(Period.ofYears(1)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you check negative intervals, and also some corner cases like division by max/min and zero intervals (ArithmeticExpressionSuite).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM in general, could you add an example to the expression description.
Test build #144160 has finished for PR 34257 at commit
|
Kubernetes integration test starting |
Kubernetes integration test status failure |
DIV
+1, LGTM. Merging to master. |
Test build #144191 has finished for PR 34257 at commit
|
|
@cloud-fan The ANSI SQL standard doesn't define the semantic of DIV. We can implement it as we want.
For the consistency to existing Spark's DIV implementation for other input types. This is widest integer that doesn't overflow on div of day-time interval. |
Why DIV returns long is the question to you, @cloud-fan ;-) |
Following to our current approach for ANSI interval in other places, we should be more stronger here. @Peng-Lei Could you address this, please. |
What changes were proposed in this pull request?
Why are the changes needed?
Extended the div function to support ANSI intervals. The operation should produce quotient of division.
SPARK-36921
Does this PR introduce any user-facing change?
Yes, user can use user can use YearMonthIntervalType and DayTimeIntervalType as input for div function.
How was this patch tested?
Add ut testcase