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

项目:presto    文件:SqlToRowExpressionTranslator.java   
@Override
protected RowExpression visitGenericLiteral(GenericLiteral node, Void context)
{
    Type type = typeManager.getType(parseTypeSignature(node.getType()));
    if (type == null) {
        throw new IllegalArgumentException("Unsupported type: " + node.getType());
    }

    if (JSON.equals(type)) {
        return call(
                new Signature("json_parse", SCALAR, types.get(node).getTypeSignature(), VARCHAR.getTypeSignature()),
                types.get(node),
                constant(utf8Slice(node.getValue()), VARCHAR));
    }

    return call(
            castSignature(types.get(node), VARCHAR),
            types.get(node),
            constant(utf8Slice(node.getValue()), VARCHAR));
}
项目:presto    文件:ExpressionAnalyzer.java   
@Override
protected Type visitGenericLiteral(GenericLiteral node, StackableAstVisitorContext<AnalysisContext> context)
{
    Type type = typeManager.getType(parseTypeSignature(node.getType()));
    if (type == null) {
        throw new SemanticException(TYPE_MISMATCH, node, "Unknown type: " + node.getType());
    }

    if (!JSON.equals(type)) {
        try {
            functionRegistry.getCoercion(VARCHAR, type);
        }
        catch (IllegalArgumentException e) {
            throw new SemanticException(TYPE_MISMATCH, node, "No literal form for type %s", type);
        }
    }

    expressionTypes.put(node, type);
    return type;
}
项目: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);
}
项目:hue    文件:VeroGenExpFormatter.java   
@Override
protected String visitGenericLiteral(GenericLiteral node, Void context)
{
    return node.getType() + " '" + node.getValue() + "'";
}
项目:presto-query-formatter    文件:ExpressionFormatter.java   
@Override
protected String visitGenericLiteral(GenericLiteral node, StackableAstVisitorContext<Integer> indent)
{
    return node.getType() + " " + formatStringLiteral(node.getValue());
}
项目:presto    文件:ExpressionFormatter.java   
@Override
protected String visitGenericLiteral(GenericLiteral node, Boolean unmangleNames)
{
    return node.getType() + " '" + node.getValue() + "'";
}
项目:presto    文件:TestSqlParser.java   
public static void assertGenericLiteral(String type)
{
    assertExpression(type + " 'abc'", new GenericLiteral(type, "abc"));
}
项目:EchoQuery    文件:ExpressionFormatter.java   
@Override
protected String visitGenericLiteral(GenericLiteral node, Boolean unmangleNames)
{
    return node.getType() + " '" + node.getValue() + "'";
}