in parser/sql/dialect/hive/src/main/java/org/apache/shardingsphere/sql/parser/hive/visitor/statement/HiveStatementVisitor.java [441:492]
public final ASTNode visitSimpleExpr(final SimpleExprContext ctx) {
int startIndex = ctx.start.getStartIndex();
int stopIndex = ctx.stop.getStopIndex();
if (null != ctx.subquery()) {
SubquerySegment subquerySegment = new SubquerySegment(
ctx.subquery().getStart().getStartIndex(), ctx.subquery().getStop().getStopIndex(), (MySQLSelectStatement) visit(ctx.subquery()), getOriginalText(ctx.subquery()));
return null == ctx.EXISTS() ? new SubqueryExpressionSegment(subquerySegment) : new ExistsSubqueryExpression(startIndex, stopIndex, subquerySegment);
}
if (null != ctx.parameterMarker()) {
ParameterMarkerValue parameterMarker = (ParameterMarkerValue) visit(ctx.parameterMarker());
ParameterMarkerExpressionSegment result = new ParameterMarkerExpressionSegment(startIndex, stopIndex, parameterMarker.getValue(), parameterMarker.getType());
parameterMarkerSegments.add(result);
return result;
}
if (null != ctx.literals()) {
return SQLUtils.createLiteralExpression(visit(ctx.literals()), startIndex, stopIndex, ctx.literals().start.getInputStream().getText(new Interval(startIndex, stopIndex)));
}
if (null != ctx.intervalExpression()) {
return visit(ctx.intervalExpression());
}
if (null != ctx.functionCall()) {
return visit(ctx.functionCall());
}
if (null != ctx.collateClause()) {
ExpressionSegment expr = null == ctx.simpleExpr() ? null : (ExpressionSegment) visit(ctx.simpleExpr(0));
return new CollateExpression(startIndex, stopIndex, (SimpleExpressionSegment) visit(ctx.collateClause()), expr);
}
if (null != ctx.columnRef()) {
return visit(ctx.columnRef());
}
if (null != ctx.matchExpression()) {
return visit(ctx.matchExpression());
}
if (null != ctx.notOperator()) {
ASTNode expression = visit(ctx.simpleExpr(0));
if (expression instanceof ExistsSubqueryExpression) {
((ExistsSubqueryExpression) expression).setNot(true);
return expression;
}
return new NotExpression(startIndex, stopIndex, (ExpressionSegment) expression, "!".equalsIgnoreCase(ctx.notOperator().getText()));
}
if (null != ctx.LP_() && 1 == ctx.expr().size()) {
return visit(ctx.expr(0));
}
if (null != ctx.OR_()) {
ExpressionSegment left = (ExpressionSegment) visit(ctx.simpleExpr(0));
ExpressionSegment right = (ExpressionSegment) visit(ctx.simpleExpr(1));
String text = ctx.start.getInputStream().getText(new Interval(ctx.start.getStartIndex(), ctx.stop.getStopIndex()));
return new BinaryOperationExpression(ctx.start.getStartIndex(), ctx.stop.getStopIndex(), left, right, ctx.OR_().getText(), text);
}
return visitRemainSimpleExpr(ctx);
}