-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Support for boolean primary MySQL queries #25424
Conversation
This reverts commit 9af038be0f4be54affd801c9ac2f6750db883377.
This reverts commit 9af038be0f4be54affd801c9ac2f6750db883377.
@strongduanmu Respected sir, This PR works well (SQLNodeConverterEngineIT and XML tests are successful) but I am getting a maven error : what is encrypt rule & how to add support for 'IS NULL' ? |
@strongduanmu Queries in Update.xml test file is giving the above error which follows scenario/encrypt/config/query-with-cipher.yaml configuration |
...deration/optimizer/converter/segment/expression/impl/BinaryOperationExpressionConverter.java
Outdated
Show resolved
Hide resolved
...java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/MySQLStatementVisitor.java
Show resolved
Hide resolved
...java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/MySQLStatementVisitor.java
Show resolved
Hide resolved
@strongduanmu Please review, All database parsers have been optimised now. |
@kanha-gupta Good job, I will review this pr again. |
@@ -77,6 +77,8 @@ public final class EncryptConditionEngine { | |||
SUPPORTED_COMPARE_OPERATOR.add("<="); | |||
SUPPORTED_COMPARE_OPERATOR.add("IS"); |
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.
Please remove useless IS operator.
@@ -441,7 +446,9 @@ public final ASTNode visitBooleanPrimary(final BooleanPrimaryContext ctx) { | |||
ExpressionSegment right = new LiteralExpressionSegment(ctx.IS().getSymbol().getStopIndex() + 2, ctx.stop.getStopIndex(), rightText); | |||
String text = ctx.start.getInputStream().getText(new Interval(ctx.start.getStartIndex(), ctx.stop.getStopIndex())); | |||
ExpressionSegment left = (ExpressionSegment) visit(ctx.booleanPrimary()); | |||
String operator = "IS"; | |||
if (null != ctx.NULL()) { | |||
right = null; |
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.
Can you refer https://github.com/polardb/polardbx-sql/blob/cdd976850bdfc3264dff279198b6b06eb8641fbe/polardbx-optimizer/src/main/java/com/alibaba/polardbx/optimizer/parse/visitor/FastSqlToCalciteNodeVisitor.java#L5346-L5350 to extract is
and is not
as an operator, and keep the right to LiteralExpressionSegment?
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.
Surely sir, I tried it on my local system.
Keeping right to LiteralExpressionSegment is causing double NULL values ->
IS NULL NULL where :
IS NULL -> postfix operator
NULL -> LiteralExpressionSegment
Can you please suggest the fix for this ?
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.
You can modify is null operator to is operator, is not null operator to is not operator.
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.
@strongduanmu Sir, I tried it. The problem I am encountering is that Calcite's SqlStdOperatorTable do not have "IS" as a function or PostFixOperator. Therefore While breaking "IS NULL" into "IS" as operator & "NULL" in right as LiteralExpressionSegment, It gives error "IS" is not supported.
Same problem is for "IS NOT NULL" as SqlStdOperatorTable doesnt support "IS NOT"
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.
@strongduanmu Therefore Please suggest a solution for it.
Thank you
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.
Can you refer https://github.com/polardb/polardbx-sql/blob/cdd976850bdfc3264dff279198b6b06eb8641fbe/polardbx-optimizer/src/main/java/com/alibaba/polardbx/optimizer/parse/visitor/FastSqlToCalciteNodeVisitor.java#L5346-L5350 to extract
is
andis not
as an operator, and keep the right to LiteralExpressionSegment?
@kanha-gupta Can you take a look at this link? It provide an example to convert to sql node.
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.
@strongduanmu Okay sir, I will update you with the progress :)
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.
@strongduanmu Sir, should I just revise CodeStyle ? in the example code, operator is set when Right is instanceof SqlNullExpr. Therefore I can understand that the Logic would stay same just like this current PR ?
Thank you
@@ -356,7 +356,7 @@ private BinaryOperationExpression createPatternMatchingOperationSegment(final AE | |||
|
|||
private BinaryOperationExpression createBinaryOperationSegment(final AExprContext ctx, final String operator) { | |||
if ("IS".equalsIgnoreCase(operator)) { | |||
ExpressionSegment left = (ExpressionSegment) visit(ctx.aExpr(0)); | |||
String ifOperator = operator; |
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.
What does ifOperator mean?
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.
Sir, I'll rename it. The variable helps in storing & changing String values when IF conditions are met.
Changes proposed in this pull request:
Before committing this PR, I'm sure that I have checked the following options:
./mvnw clean install -B -T1C -Dmaven.javadoc.skip -Dmaven.jacoco.skip -e
.