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

项目:sql4es    文件:RelationParser.java   
@Override
protected List<QuerySource> visitRelation(Relation node, QueryState state){
    if(node instanceof Join){
        return node.accept(this, state);
    }else if( node instanceof SampledRelation){
        state.addException("Sampled relations are not supported");
        return null;
    }else if( node instanceof AliasedRelation){
        AliasedRelation ar = (AliasedRelation)node;
        state.setKeyValue("table_alias", ar.getAlias());
        List<QuerySource> relations = ar.getRelation().accept(this, state);
        for(QuerySource rr : relations) rr.setAlias(ar.getAlias());
        return relations;
    }else if( node instanceof QueryBody){
        return node.accept(this, state);
    }else{
        state.addException("Unable to parse node because it has an unknown type :"+node.getClass());
        return null;
    }
}
项目:presto    文件:StatementAnalyzer.java   
@Override
protected RelationType visitAliasedRelation(AliasedRelation relation, AnalysisContext context)
{
    RelationType child = process(relation.getRelation(), context);

    // todo this check should be inside of TupleDescriptor.withAlias, but the exception needs the node object
    if (relation.getColumnNames() != null) {
        int totalColumns = child.getVisibleFieldCount();
        if (totalColumns != relation.getColumnNames().size()) {
            throw new SemanticException(MISMATCHED_COLUMN_ALIASES, relation, "Column alias list has %s entries but '%s' has %s columns available", relation.getColumnNames().size(), relation.getAlias(), totalColumns);
        }
    }

    RelationType descriptor = child.withAlias(relation.getAlias(), relation.getColumnNames());

    analysis.setOutputDescriptor(relation, descriptor);
    return descriptor;
}
项目:presto-query-formatter    文件:StatementFormatter.java   
@Override
protected Void visitAliasedRelation(AliasedRelation node, Integer indent)
{
    process(node.getRelation(), indent);

    builder.append(' ')
            .append(formatName(node.getAlias()));
    appendAliasColumns(builder, node.getColumnNames());

    return null;
}
项目:presto    文件:RelationPlanner.java   
@Override
protected RelationPlan visitAliasedRelation(AliasedRelation node, Void context)
{
    RelationPlan subPlan = process(node.getRelation(), context);

    RelationType outputDescriptor = analysis.getOutputDescriptor(node);

    return new RelationPlan(subPlan.getRoot(), outputDescriptor, subPlan.getOutputSymbols(), subPlan.getSampleWeight());
}
项目:presto    文件:SqlFormatter.java   
@Override
protected Void visitAliasedRelation(AliasedRelation node, Integer indent)
{
    process(node.getRelation(), indent);

    builder.append(' ')
            .append(node.getAlias());

    appendAliasColumns(builder, node.getColumnNames());

    return null;
}
项目:presto    文件:AstBuilder.java   
@Override
public Node visitAliasedRelation(SqlBaseParser.AliasedRelationContext context)
{
    Relation child = (Relation) visit(context.relationPrimary());

    if (context.identifier() == null) {
        return child;
    }

    return new AliasedRelation(getLocation(context), child, context.identifier().getText(), getColumnAliases(context.columnAliases()));
}
项目:EchoQuery    文件:SqlFormatter.java   
@Override
protected Void visitAliasedRelation(AliasedRelation node, Integer indent)
{
    process(node.getRelation(), indent);

    builder.append(' ')
            .append(node.getAlias());

    appendAliasColumns(builder, node.getColumnNames());

    return null;
}
项目:presto    文件:QueryUtil.java   
public static Relation aliased(Relation relation, String alias, List<String> columnAliases)
{
    return new AliasedRelation(relation, alias, columnAliases);
}