Tabnine Logo
AliasedRelation
Code IndexAdd Tabnine to your IDE (free)

How to use
AliasedRelation
in
com.facebook.presto.sql.tree

Best Java code snippets using com.facebook.presto.sql.tree.AliasedRelation (Showing top 20 results out of 315)

origin: prestodb/presto

@Override
protected Void visitAliasedRelation(AliasedRelation node, Integer indent)
{
  process(node.getRelation(), indent);
  builder.append(' ')
      .append(formatExpression(node.getAlias(), parameters));
  appendAliasColumns(builder, node.getColumnNames());
  return null;
}
origin: prestodb/presto

public static Relation aliased(Relation relation, String alias, List<String> columnAliases)
{
  return new AliasedRelation(
      relation,
      identifier(alias),
      columnAliases.stream()
          .map(QueryUtil::identifier)
          .collect(Collectors.toList()));
}
origin: prestodb/presto

private boolean isLateralRelation(Relation node)
{
  if (node instanceof AliasedRelation) {
    return isLateralRelation(((AliasedRelation) node).getRelation());
  }
  return node instanceof Unnest || node instanceof Lateral;
}
origin: prestodb/presto

@Override
protected RelationPlan visitAliasedRelation(AliasedRelation node, Void context)
{
  RelationPlan subPlan = process(node.getRelation(), context);
  PlanNode root = subPlan.getRoot();
  List<Symbol> mappings = subPlan.getFieldMappings();
  if (node.getColumnNames() != null) {
    ImmutableList.Builder<Symbol> newMappings = ImmutableList.<Symbol>builder();
    Assignments.Builder assignments = Assignments.builder();
    // project only the visible columns from the underlying relation
    for (int i = 0; i < subPlan.getDescriptor().getAllFieldCount(); i++) {
      Field field = subPlan.getDescriptor().getFieldByIndex(i);
      if (!field.isHidden()) {
        Symbol aliasedColumn = symbolAllocator.newSymbol(field);
        assignments.put(aliasedColumn, subPlan.getFieldMappings().get(i).toSymbolReference());
        newMappings.add(aliasedColumn);
      }
    }
    root = new ProjectNode(idAllocator.getNextId(), subPlan.getRoot(), assignments.build());
    mappings = newMappings.build();
  }
  return new RelationPlan(root, analysis.getScope(node), mappings);
}
origin: Anchormen/sql4es

@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()); //.getValue());
    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;
  }
}

origin: prestodb/presto

@Override
protected Void visitAliasedRelation(AliasedRelation node, Integer indentLevel)
{
  print(indentLevel, "Alias[" + node.getAlias() + "]");
  super.visitAliasedRelation(node, indentLevel + 1);
  return null;
}
origin: prestodb/presto

@Override
protected R visitAliasedRelation(AliasedRelation node, C context)
{
  return process(node.getRelation(), context);
}
origin: com.facebook.presto/presto-parser

@Override
protected Void visitAliasedRelation(AliasedRelation node, Integer indentLevel)
{
  print(indentLevel, "Alias[" + node.getAlias() + "]");
  super.visitAliasedRelation(node, indentLevel + 1);
  return null;
}
origin: prestodb/presto

@Override
protected Scope visitAliasedRelation(AliasedRelation relation, Optional<Scope> scope)
{
  Scope relationScope = process(relation.getRelation(), scope);
  // todo this check should be inside of TupleDescriptor.withAlias, but the exception needs the node object
  RelationType relationType = relationScope.getRelationType();
  if (relation.getColumnNames() != null) {
    int totalColumns = relationType.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);
    }
  }
  List<String> aliases = null;
  if (relation.getColumnNames() != null) {
    aliases = relation.getColumnNames().stream()
        .map(Identifier::getValue)
        .collect(Collectors.toList());
  }
  RelationType descriptor = relationType.withAlias(relation.getAlias().getValue(), aliases);
  return createAndAssignScope(relation, scope, descriptor);
}
origin: prestodb/presto

private Optional<Unnest> getUnnest(Relation relation)
{
  if (relation instanceof AliasedRelation) {
    return getUnnest(((AliasedRelation) relation).getRelation());
  }
  if (relation instanceof Unnest) {
    return Optional.of((Unnest) relation);
  }
  return Optional.empty();
}
origin: uk.co.nichesolutions.presto/presto-parser

@Override
protected Void visitAliasedRelation(AliasedRelation node, Integer indentLevel)
{
  print(indentLevel, "Alias[" + node.getAlias() + "]");
  super.visitAliasedRelation(node, indentLevel + 1);
  return null;
}
origin: prestodb/presto

@Override
public Node visitAliasedRelation(SqlBaseParser.AliasedRelationContext context)
{
  Relation child = (Relation) visit(context.relationPrimary());
  if (context.identifier() == null) {
    return child;
  }
  List<Identifier> aliases = null;
  if (context.columnAliases() != null) {
    aliases = visit(context.columnAliases().identifier(), Identifier.class);
  }
  return new AliasedRelation(getLocation(context), child, (Identifier) visit(context.identifier()), aliases);
}
origin: rakam-io/rakam

@Override
protected Void visitAliasedRelation(AliasedRelation node, Integer indent) {
  process(node.getRelation(), indent);
  builder.append(' ')
      .append(formatExpression(node.getAlias(), tableNameMapper, columnNameMapper, queryWithTables, escapeIdentifier));
  appendAliasColumns(builder, node.getColumnNames());
  return null;
}
origin: prestodb/presto

private Optional<Lateral> getLateral(Relation relation)
{
  if (relation instanceof AliasedRelation) {
    return getLateral(((AliasedRelation) relation).getRelation());
  }
  if (relation instanceof Lateral) {
    return Optional.of((Lateral) relation);
  }
  return Optional.empty();
}
origin: prestodb/presto

Join.Type.IMPLICIT,
new Table(QualifiedName.of("t")),
new AliasedRelation(lateralRelation, identifier("a"), ImmutableList.of(identifier("x"))),
Optional.empty())));
origin: uk.co.nichesolutions.presto/presto-parser

@Override
protected Void visitAliasedRelation(AliasedRelation node, Integer indent)
{
  process(node.getRelation(), indent);
  builder.append(' ')
      .append(node.getAlias());
  appendAliasColumns(builder, node.getColumnNames());
  return null;
}
origin: com.facebook.presto/presto-parser

@Override
protected R visitAliasedRelation(AliasedRelation node, C context)
{
  return process(node.getRelation(), context);
}
origin: prestodb/presto

@Test
public void testUnnest()
{
  assertStatement("SELECT * FROM t CROSS JOIN UNNEST(a)",
      simpleQuery(
          selectList(new AllColumns()),
          new Join(
              Join.Type.CROSS,
              new Table(QualifiedName.of("t")),
              new Unnest(ImmutableList.of(new Identifier("a")), false),
              Optional.empty())));
  assertStatement("SELECT * FROM t CROSS JOIN UNNEST(a, b) WITH ORDINALITY",
      simpleQuery(
          selectList(new AllColumns()),
          new Join(
              Join.Type.CROSS,
              new Table(QualifiedName.of("t")),
              new Unnest(ImmutableList.of(new Identifier("a"), new Identifier("b")), true),
              Optional.empty())));
  assertStatement("SELECT * FROM t FULL JOIN UNNEST(a) AS tmp (c) ON true",
      simpleQuery(
          selectList(new AllColumns()),
          new Join(
              Join.Type.FULL,
              new Table(QualifiedName.of("t")),
              new AliasedRelation(new Unnest(ImmutableList.of(new Identifier("a")), false), new Identifier("tmp"), ImmutableList.of(new Identifier("c"))),
              Optional.of(new JoinOn(BooleanLiteral.TRUE_LITERAL)))));
}
origin: vqtran/EchoQuery

@Override
protected Void visitAliasedRelation(AliasedRelation node, Integer indent)
{
  process(node.getRelation(), indent);
  builder.append(' ')
      .append(node.getAlias());
  appendAliasColumns(builder, node.getColumnNames());
  return null;
}
origin: uk.co.nichesolutions.presto/presto-parser

@Override
protected R visitAliasedRelation(AliasedRelation node, C context)
{
  return process(node.getRelation(), context);
}
com.facebook.presto.sql.treeAliasedRelation

Most used methods

  • getAlias
  • getRelation
  • getColumnNames
  • <init>

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getSupportFragmentManager (FragmentActivity)
  • requestLocationUpdates (LocationManager)
  • onRequestPermissionsResult (Fragment)
  • FileOutputStream (java.io)
    An output stream that writes bytes to a file. If the output file exists, it can be replaced or appen
  • List (java.util)
    An ordered collection (also known as a sequence). The user of this interface has precise control ove
  • Notification (javax.management)
  • JOptionPane (javax.swing)
  • JTable (javax.swing)
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now