-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-29855][SQL] typed literals with negative sign with proper result or exception #26479
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
Conversation
|
cc @cloud-fan @maropu @HyukjinKwon @MaxGekk, thanks a lot |
| val value = string(ctx.STRING) | ||
| val valueType = ctx.identifier.getText.toUpperCase(Locale.ROOT) | ||
| val negativeSign = Option(ctx.negativeSign).map(_.getText).getOrElse("") | ||
| val isNegative = if (negativeSign == "-") true else false |
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.
is it simply val isNegative = ctx.negativeSign != null?
|
looks reasonable to me. Is it a common behavior in other DBs like pgsql? |
| val value = string(ctx.STRING) | ||
| val valueType = ctx.identifier.getText.toUpperCase(Locale.ROOT) | ||
| val negativeSign = Option(ctx.negativeSign).map(_.getText).getOrElse("") | ||
| val isNegative = if (negativeSign == "-") true else false |
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.
| val isNegative = if (negativeSign == "-") true else false | |
| val isNegative = ctx.negativeSign != null && ctx.negativeSign.getText == "-" |
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.
and remove val negativeSign
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.
do we really need to check ctx.negativeSign.getText? the parser rule is MINUS? ...
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.
negativeSign is used in error message, but I think @cloud-fan 's point is right, we need not to check ctx.negativeSign.getText. I'd do some tests to verify this.
|
Test build #113615 has finished for PR 26479 at commit
|
yes it right the pg behavior |
| select '1' year to second; | ||
| select interval 1 year '2-1' year to month; | ||
| select 1 year '2-1' year to month; | ||
| SET spark.sql.ansi.enabled=false; |
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.
not related to this PR, but it's really annoying to duplicate the test cases with ansi mode on and off.
I'm wondering if we can introduce a -- import abc.sql directive so that we can easily import test cases in ansi/interval.sql, with several ansi specific test cases. cc @maropu
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.
Ah, I see. That's certainly annoying. I'll try to make a pr later for that approach.
|
Test build #113617 has finished for PR 26479 at commit
|
|
Merged to master. |
…s from another test case in SQLQueryTestSuite ### What changes were proposed in this pull request? This pr is to support `--import` directive to load queries from another test case in SQLQueryTestSuite. This fix comes from the cloud-fan suggestion in #26479 (comment) ### Why are the changes needed? This functionality might reduce duplicate test code in `SQLQueryTestSuite`. ### Does this PR introduce any user-facing change? No. ### How was this patch tested? Run `SQLQueryTestSuite`. Closes #26497 from maropu/ImportTests. Authored-by: Takeshi Yamamuro <[email protected]> Signed-off-by: Wenchen Fan <[email protected]>
What changes were proposed in this pull request?
the integer should be -7 and the date and timestamp results are confusing which should throw exceptions
Why are the changes needed?
bug fix
Does this PR introduce any user-facing change?
NO
How was this patch tested?
ADD UTs