Java 类com.facebook.presto.sql.tree.TimestampLiteral 实例源码

项目:presto    文件:ExpressionAnalyzer.java   
@Override
protected Type visitTimestampLiteral(TimestampLiteral node, StackableAstVisitorContext<AnalysisContext> context)
{
    try {
        parseTimestampLiteral(session.getTimeZoneKey(), node.getValue());
    }
    catch (Exception e) {
        throw new SemanticException(INVALID_LITERAL, node, "'%s' is not a valid timestamp literal", node.getValue());
    }

    Type type;
    if (timestampHasTimeZone(node.getValue())) {
        type = TIMESTAMP_WITH_TIME_ZONE;
    }
    else {
        type = TIMESTAMP;
    }
    expressionTypes.put(node, type);
    return type;
}
项目:sql4es    文件:UpdateParser.java   
private Object getObject(Literal literal){
    Object value = null;
    if(literal instanceof LongLiteral) value = ((LongLiteral)literal).getValue();
    else if(literal instanceof BooleanLiteral) value = ((BooleanLiteral)literal).getValue();
    else if(literal instanceof DoubleLiteral) value = ((DoubleLiteral)literal).getValue();
    else if(literal instanceof StringLiteral) value = ((StringLiteral)literal).getValue();
    else if(literal instanceof TimeLiteral) value = ((TimeLiteral)literal).getValue();
    else if(literal instanceof TimestampLiteral) value = ((TimestampLiteral)literal).getValue();
    return value;
}
项目:presto    文件:SqlToRowExpressionTranslator.java   
@Override
protected RowExpression visitTimestampLiteral(TimestampLiteral node, Void context)
{
    long value;
    if (types.get(node).equals(TIMESTAMP_WITH_TIME_ZONE)) {
        value = parseTimestampWithTimeZone(timeZoneKey, node.getValue());
    }
    else {
        // parse in time zone of client
        value = parseTimestampWithoutTimeZone(timeZoneKey, node.getValue());
    }
    return constant(value, types.get(node));
}
项目:presto    文件:LiteralInterpreter.java   
@Override
protected Long visitTimestampLiteral(TimestampLiteral node, ConnectorSession session)
{
    try {
        return parseTimestampLiteral(session.getTimeZoneKey(), node.getValue());
    }
    catch (Exception e) {
        throw new SemanticException(INVALID_LITERAL, node, "'%s' is not a valid timestamp literal", node.getValue());
    }
}
项目:presto    文件:AstBuilder.java   
@Override
public Node visitTypeConstructor(SqlBaseParser.TypeConstructorContext context)
{
    String type = context.identifier().getText();
    String value = unquote(context.STRING().getText());

    if (type.equalsIgnoreCase("time")) {
        return new TimeLiteral(getLocation(context), value);
    }
    if (type.equalsIgnoreCase("timestamp")) {
        return new TimestampLiteral(getLocation(context), value);
    }

    return new GenericLiteral(getLocation(context), type, value);
}
项目:presto    文件:TestSqlParser.java   
@Test
public void testLiterals()
        throws Exception
{
    assertExpression("TIME" + " 'abc'", new TimeLiteral("abc"));
    assertExpression("TIMESTAMP" + " 'abc'", new TimestampLiteral("abc"));
    assertExpression("INTERVAL '33' day", new IntervalLiteral("33", Sign.POSITIVE, IntervalField.DAY, Optional.empty()));
    assertExpression("INTERVAL '33' day to second", new IntervalLiteral("33", Sign.POSITIVE, IntervalField.DAY, Optional.of(IntervalField.SECOND)));
}
项目:hue    文件:VeroGenExpFormatter.java   
@Override
protected String visitTimestampLiteral(TimestampLiteral node, Void context)
{
    return "TIMESTAMP '" + node.getValue() + "'";
}
项目:presto-query-formatter    文件:ExpressionFormatter.java   
@Override
protected String visitTimestampLiteral(TimestampLiteral node, StackableAstVisitorContext<Integer> indent)
{
    return "TIMESTAMP '" + node.getValue() + "'";
}
项目:presto    文件:ExpressionFormatter.java   
@Override
protected String visitTimestampLiteral(TimestampLiteral node, Boolean unmangleNames)
{
    return "TIMESTAMP '" + node.getValue() + "'";
}
项目:EchoQuery    文件:ExpressionFormatter.java   
@Override
protected String visitTimestampLiteral(TimestampLiteral node, Boolean unmangleNames)
{
    return "TIMESTAMP '" + node.getValue() + "'";
}