Skip to content
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

Return NullLiteral in castTo method instead of throwing a exception #2799

Merged
merged 2 commits into from Jan 21, 2020

Conversation

xy720
Copy link
Member

@xy720 xy720 commented Jan 19, 2020

Issue
#2399
#2396 (2.2)
We used to use Precondition to throw an exception when encounter a NullLiteral in castTo method. So if the child of CastExpr is NullLiteral, then this CastExpr will throw an exception when invoking the castTo method.
And this may make the user not get the desired result.
For example, we get an unexpected exception in query: (In sql mode PIPES_AS_CONCAT_MODE)
select (1 || 'a' > 0) + 1;
which should return a result 'Null'.

@xy720 xy720 changed the title Filter NullLiteral in castTo method instead of throwing a exception Return NullLiteral in castTo method instead of throwing a exception Jan 19, 2020
@xy720 xy720 requested review from imay and morningman January 19, 2020 13:35
parsedStmt.rewriteExprs(rewriter);

Expr result = parsedStmt.getSelectList().getItems().get(0).getExpr();
Assert.assertEquals(Expr.IS_NULL_LITERAL.apply(result), true);
Copy link
Contributor

Choose a reason for hiding this comment

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

what the different between IS_NULL_LITERAL and result instance of NullLiteral

Copy link
Contributor

@morningman morningman left a comment

Choose a reason for hiding this comment

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

LGTM

@morningman morningman merged commit 2a30ac2 into apache:master Jan 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants