@Override public Node visitReadUncommitted(SqlBaseParser.ReadUncommittedContext context) { return new Isolation(getLocation(context), Isolation.Level.READ_UNCOMMITTED); }
@Override public Node visitRepeatableRead(SqlBaseParser.RepeatableReadContext context) { return new Isolation(getLocation(context), Isolation.Level.REPEATABLE_READ); }
@Override public Node visitShowSession(SqlBaseParser.ShowSessionContext context) { return new ShowSession(getLocation(context)); }
@Override public Node visitLikeClause(SqlBaseParser.LikeClauseContext context) { return new LikeClause( getLocation(context), getQualifiedName(context.qualifiedName()), Optional.ofNullable(context.optionType) .map(AstBuilder::getPropertiesOption)); }
@Override public Node visitUnquotedIdentifier(SqlBaseParser.UnquotedIdentifierContext context) { return new Identifier(getLocation(context), context.getText(), false); }
@Override public Node visitInSubquery(SqlBaseParser.InSubqueryContext context) { Expression result = new InPredicate( getLocation(context), (Expression) visit(context.value), new SubqueryExpression(getLocation(context), (Query) visit(context.query()))); if (context.NOT() != null) { result = new NotExpression(getLocation(context), result); } return result; }
@Override public Node visitDropColumn(SqlBaseParser.DropColumnContext context) { return new DropColumn(getLocation(context), getQualifiedName(context.tableName), (Identifier) visit(context.column)); }
@Override public Node visitCube(SqlBaseParser.CubeContext context) { return new Cube(getLocation(context), visit(context.expression(), Expression.class)); }
@Override public Node visitResetSession(SqlBaseParser.ResetSessionContext context) { return new ResetSession(getLocation(context), getQualifiedName(context.qualifiedName())); }
@Override public Node visitPositionalArgument(SqlBaseParser.PositionalArgumentContext context) { return new CallArgument(getLocation(context), (Expression) visit(context.expression())); }
@Override public Node visitShowSchemas(SqlBaseParser.ShowSchemasContext context) { return new ShowSchemas( getLocation(context), visitIfPresent(context.identifier(), Identifier.class), getTextIfPresent(context.pattern) .map(AstBuilder::unquote), getTextIfPresent(context.escape) .map(AstBuilder::unquote)); }
@Override public Node visitDropTable(SqlBaseParser.DropTableContext context) { return new DropTable(getLocation(context), getQualifiedName(context.qualifiedName()), context.EXISTS() != null); }
@Override public Node visitCreateRole(SqlBaseParser.CreateRoleContext context) { return new CreateRole( getLocation(context), (Identifier) visit(context.name), getGrantorSpecificationIfPresent(context.grantor())); }
@Override public Node visitSetRole(SqlBaseParser.SetRoleContext context) { SetRole.Type type = SetRole.Type.ROLE; if (context.ALL() != null) { type = SetRole.Type.ALL; } else if (context.NONE() != null) { type = SetRole.Type.NONE; } return new SetRole(getLocation(context), type, getIdentifierIfPresent(context.role)); }
@Override public Node visitArithmeticBinary(SqlBaseParser.ArithmeticBinaryContext context) { return new ArithmeticBinaryExpression( getLocation(context.operator), getArithmeticBinaryOperator(context.operator), (Expression) visit(context.left), (Expression) visit(context.right)); }
@Override public Node visitRenameSchema(SqlBaseParser.RenameSchemaContext context) { return new RenameSchema( getLocation(context), getQualifiedName(context.qualifiedName()), (Identifier) visit(context.identifier())); }
@Override public Node visitCall(SqlBaseParser.CallContext context) { return new Call( getLocation(context), getQualifiedName(context.qualifiedName()), visit(context.callArgument(), CallArgument.class)); }
@Override public Node visitPrepare(SqlBaseParser.PrepareContext context) { return new Prepare( getLocation(context), (Identifier) visit(context.identifier()), (Statement) visit(context.statement())); }
@Override public Node visitRevokeRoles(SqlBaseParser.RevokeRolesContext context) { return new RevokeRoles( getLocation(context), ImmutableSet.copyOf(getIdentifiers(context.roles().identifier())), ImmutableSet.copyOf(getPrincipalSpecifications(context.principal())), context.OPTION() != null, getGrantorSpecificationIfPresent(context.grantor())); }
@Override public Node visitSimpleCase(SqlBaseParser.SimpleCaseContext context) { return new SimpleCaseExpression( getLocation(context), (Expression) visit(context.valueExpression()), visit(context.whenClause(), WhenClause.class), visitIfPresent(context.elseExpression, Expression.class)); }