private Expression createEmptyColumnStatsRow(String columnName) { ImmutableList.Builder<Expression> rowValues = ImmutableList.builder(); rowValues.add(new StringLiteral(columnName)); rowValues.add(NULL_DOUBLE); rowValues.add(NULL_DOUBLE); rowValues.add(NULL_DOUBLE); rowValues.add(NULL_DOUBLE); rowValues.add(NULL_VARCHAR); rowValues.add(NULL_VARCHAR); return new Row(rowValues.build()); }
@Override protected Void visitStringLiteral(StringLiteral node, Integer indentLevel) { print(indentLevel, "String[" + node.getValue() + "]"); return null; }
@Override protected Slice visitStringLiteral(StringLiteral node, ConnectorSession session) { return node.getSlice(); }
private Expression createEmptyColumnStatsRow(String columnName) { ImmutableList.Builder<Expression> rowValues = ImmutableList.builder(); rowValues.add(new StringLiteral(columnName)); rowValues.add(NULL_DOUBLE); rowValues.add(NULL_DOUBLE); rowValues.add(NULL_DOUBLE); rowValues.add(NULL_DOUBLE); rowValues.add(NULL_VARCHAR); rowValues.add(NULL_VARCHAR); return new Row(rowValues.build()); }
@Override protected Void visitStringLiteral(StringLiteral node, Integer indentLevel) { print(indentLevel, "String[" + node.getValue() + "]"); return null; }
@Override protected Slice visitStringLiteral(StringLiteral node, ConnectorSession session) { return node.getSlice(); }
private static StringLiteral stringLiteral(String value) { return new StringLiteral(value); }
@Override protected String visitStringLiteral(StringLiteral node, Void context) { return formatStringLiteral(node.getValue()); }
private static Expression toStringLiteral(Type type, double value) { if (type.equals(BigintType.BIGINT) || type.equals(IntegerType.INTEGER) || type.equals(SmallintType.SMALLINT) || type.equals(TinyintType.TINYINT)) { return new StringLiteral(Long.toString(round(value))); } if (type.equals(DoubleType.DOUBLE) || type instanceof DecimalType) { return new StringLiteral(Double.toString(value)); } if (type.equals(RealType.REAL)) { return new StringLiteral(Float.toString((float) value)); } if (type.equals(DATE)) { return new StringLiteral(LocalDate.ofEpochDay(round(value)).toString()); } throw new IllegalArgumentException("Unexpected type: " + type); } }
@Override protected String visitStringLiteral(StringLiteral node, Void context) { return formatStringLiteral(node.getValue()); }
private static StringLiteral stringLiteral(String value) { return new StringLiteral(value); }
private Regex getConstantPattern(LikePredicate node) { Regex result = likePatternCache.get(node); if (result == null) { StringLiteral pattern = (StringLiteral) node.getPattern(); if (node.getEscape().isPresent()) { Slice escape = ((StringLiteral) node.getEscape().get()).getSlice(); result = LikeFunctions.likePattern(pattern.getSlice(), escape); } else { result = LikeFunctions.likePattern(pattern.getSlice()); } likePatternCache.put(node, result); } return result; }
private static Expression toStringLiteral(Type type, double value) { if (type.equals(BigintType.BIGINT) || type.equals(IntegerType.INTEGER) || type.equals(SmallintType.SMALLINT) || type.equals(TinyintType.TINYINT)) { return new StringLiteral(Long.toString(round(value))); } if (type.equals(DoubleType.DOUBLE) || type instanceof DecimalType) { return new StringLiteral(Double.toString(value)); } if (type.equals(RealType.REAL)) { return new StringLiteral(Float.toString((float) value)); } if (type.equals(DATE)) { return new StringLiteral(LocalDate.ofEpochDay(round(value)).toString()); } throw new IllegalArgumentException("Unexpected type: " + type); } }
private Regex getConstantPattern(LikePredicate node) { Regex result = likePatternCache.get(node); if (result == null) { StringLiteral pattern = (StringLiteral) node.getPattern(); if (node.getEscape().isPresent()) { Slice escape = ((StringLiteral) node.getEscape().get()).getSlice(); result = LikeFunctions.likePattern(pattern.getSlice(), escape); } else { result = LikeFunctions.likePattern(pattern.getSlice()); } likePatternCache.put(node, result); } return result; }
public static SelectItem aliasedNullToEmpty(String column, String alias) { return new SingleColumn(new CoalesceExpression(identifier(column), new StringLiteral("")), identifier(alias)); }
@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)); }