strongduanmu commented on a change in pull request #11289:
URL: https://github.com/apache/shardingsphere/pull/11289#discussion_r668369882
##########
File path:
shardingsphere-infra/shardingsphere-infra-optimize/src/test/java/org/apache/shardingsphere/infra/optimize/core/convert/SelectStatementSqlNodeConverterTest.java
##########
@@ -169,4 +177,22 @@ public void testConvertLeftOuterJoin() {
assertThat(sqlNode, instanceOf(SqlSelect.class));
// TODO outer join is not supported by parser of ShardingSphere
}
+
+ @Test
+ public void testExpressionSegment() {
+ String sql = "select 10 + 30 from t_order where 1 + 1 order by 1 + 1";
+ SQLStatement sqlStatement = sqlStatementParserEngine.parse(sql, false);
+ Collection<ProjectionSegment> projectionSegments =
((MySQLSelectStatement) sqlStatement).getProjections().getProjections();
+ ProjectionSegment projectionSegment =
projectionSegments.stream().findFirst().orElse(null);
+ assertThat(projectionSegment,
instanceOf(ExpressionProjectionSegment.class));
+ assert projectionSegment != null;
Review comment:
@tuichenchuxin `assertNotNull` is better. For more development spec, you
can refer
[code-conduct](https://shardingsphere.apache.org/community/cn/contribute/code-conduct/).
##########
File path:
shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/impl/MySQLStatementSQLVisitor.java
##########
@@ -886,6 +886,8 @@ public final ASTNode visitOrderByItem(final
OrderByItemContext ctx) {
ASTNode expr = visitExpr(ctx.expr());
if (expr instanceof ColumnSegment) {
return new ColumnOrderByItemSegment((ColumnSegment) expr,
orderDirection);
+ } else if (expr instanceof ExpressionSegment) {
Review comment:
@tuichenchuxin Can we merge this logic with the following logic?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]