@Override protected Void visitStringLiteral(StringLiteral node, Integer indentLevel) { print(indentLevel, "String[" + node.getValue() + "]"); return null; }
@Override protected Void visitStringLiteral(StringLiteral node, Integer indentLevel) { print(indentLevel, "String[" + node.getValue() + "]"); return null; }
@Override protected String visitStringLiteral(StringLiteral node, Void context) { return formatStringLiteral(node.getValue()); }
@Override protected String visitStringLiteral(StringLiteral node, Void context) { return formatStringLiteral(node.getValue()); }
@Override public Node visitInterval(SqlBaseParser.IntervalContext context) { return new IntervalLiteral( getLocation(context), ((StringLiteral) visit(context.string())).getValue(), Optional.ofNullable(context.sign) .map(AstBuilder::getIntervalSign) .orElse(IntervalLiteral.Sign.POSITIVE), getIntervalFieldType((Token) context.from.getChild(0).getPayload()), Optional.ofNullable(context.to) .map((x) -> x.getChild(0).getPayload()) .map(Token.class::cast) .map(AstBuilder::getIntervalFieldType)); }
@Override public Node visitInterval(SqlBaseParser.IntervalContext context) { return new IntervalLiteral( getLocation(context), ((StringLiteral) visit(context.string())).getValue(), Optional.ofNullable(context.sign) .map(AstBuilder::getIntervalSign) .orElse(IntervalLiteral.Sign.POSITIVE), getIntervalFieldType((Token) context.from.getChild(0).getPayload()), Optional.ofNullable(context.to) .map((x) -> x.getChild(0).getPayload()) .map(Token.class::cast) .map(AstBuilder::getIntervalFieldType)); }
@Override public Node visitColumnDefinition(SqlBaseParser.ColumnDefinitionContext context) { Optional<String> comment = Optional.empty(); if (context.COMMENT() != null) { comment = Optional.of(((StringLiteral) visit(context.string())).getValue()); } List<Property> properties = ImmutableList.of(); if (context.properties() != null) { properties = visit(context.properties().property(), Property.class); } return new ColumnDefinition( getLocation(context), (Identifier) visit(context.identifier()), getType(context.type()), properties, comment); }
@Override public Node visitColumnDefinition(SqlBaseParser.ColumnDefinitionContext context) { Optional<String> comment = Optional.empty(); if (context.COMMENT() != null) { comment = Optional.of(((StringLiteral) visit(context.string())).getValue()); } List<Property> properties = ImmutableList.of(); if (context.properties() != null) { properties = visit(context.properties().property(), Property.class); } return new ColumnDefinition( getLocation(context), (Identifier) visit(context.identifier()), getType(context.type()), properties, comment); }
@Override public Node visitCreateTable(SqlBaseParser.CreateTableContext context) { Optional<String> comment = Optional.empty(); if (context.COMMENT() != null) { comment = Optional.of(((StringLiteral) visit(context.string())).getValue()); } List<Property> properties = ImmutableList.of(); if (context.properties() != null) { properties = visit(context.properties().property(), Property.class); } return new CreateTable( getLocation(context), getQualifiedName(context.qualifiedName()), visit(context.tableElement(), TableElement.class), context.EXISTS() != null, properties, comment); }
@Override public Node visitCreateTable(SqlBaseParser.CreateTableContext context) { Optional<String> comment = Optional.empty(); if (context.COMMENT() != null) { comment = Optional.of(((StringLiteral) visit(context.string())).getValue()); } List<Property> properties = ImmutableList.of(); if (context.properties() != null) { properties = visit(context.properties().property(), Property.class); } return new CreateTable( getLocation(context), getQualifiedName(context.qualifiedName()), visit(context.tableElement(), TableElement.class), context.EXISTS() != null, properties, comment); }
@Override public Node visitTypeConstructor(SqlBaseParser.TypeConstructorContext context) { String value = ((StringLiteral) visit(context.string())).getValue(); if (context.DOUBLE_PRECISION() != null) { // TODO: Temporary hack that should be removed with new planner. return new GenericLiteral(getLocation(context), "DOUBLE", value); } String type = context.identifier().getText(); if (type.equalsIgnoreCase("time")) { return new TimeLiteral(getLocation(context), value); } if (type.equalsIgnoreCase("timestamp")) { return new TimestampLiteral(getLocation(context), value); } if (type.equalsIgnoreCase("decimal")) { return new DecimalLiteral(getLocation(context), value); } if (type.equalsIgnoreCase("char")) { return new CharLiteral(getLocation(context), value); } return new GenericLiteral(getLocation(context), type, value); }
@Override public Node visitCreateTableAsSelect(SqlBaseParser.CreateTableAsSelectContext context) { Optional<String> comment = Optional.empty(); if (context.COMMENT() != null) { comment = Optional.of(((StringLiteral) visit(context.string())).getValue()); } Optional<List<Identifier>> columnAliases = Optional.empty(); if (context.columnAliases() != null) { columnAliases = Optional.of(visit(context.columnAliases().identifier(), Identifier.class)); } List<Property> properties = ImmutableList.of(); if (context.properties() != null) { properties = visit(context.properties().property(), Property.class); } return new CreateTableAsSelect( getLocation(context), getQualifiedName(context.qualifiedName()), (Query) visit(context.query()), context.EXISTS() != null, properties, context.NO() == null, columnAliases, comment); }
@Override public Node visitTypeConstructor(SqlBaseParser.TypeConstructorContext context) { String value = ((StringLiteral) visit(context.string())).getValue(); if (context.DOUBLE_PRECISION() != null) { // TODO: Temporary hack that should be removed with new planner. return new GenericLiteral(getLocation(context), "DOUBLE", value); } String type = context.identifier().getText(); if (type.equalsIgnoreCase("time")) { return new TimeLiteral(getLocation(context), value); } if (type.equalsIgnoreCase("timestamp")) { return new TimestampLiteral(getLocation(context), value); } if (type.equalsIgnoreCase("decimal")) { return new DecimalLiteral(getLocation(context), value); } if (type.equalsIgnoreCase("char")) { return new CharLiteral(getLocation(context), value); } return new GenericLiteral(getLocation(context), type, value); }
@Override public Node visitCreateTableAsSelect(SqlBaseParser.CreateTableAsSelectContext context) { Optional<String> comment = Optional.empty(); if (context.COMMENT() != null) { comment = Optional.of(((StringLiteral) visit(context.string())).getValue()); } Optional<List<Identifier>> columnAliases = Optional.empty(); if (context.columnAliases() != null) { columnAliases = Optional.of(visit(context.columnAliases().identifier(), Identifier.class)); } List<Property> properties = ImmutableList.of(); if (context.properties() != null) { properties = visit(context.properties().property(), Property.class); } return new CreateTableAsSelect( getLocation(context), getQualifiedName(context.qualifiedName()), (Query) visit(context.query()), context.EXISTS() != null, properties, context.NO() == null, columnAliases, comment); }