Ejemplo n.º 1
0
  /**
   * Iterate through the nodes in the FROM clause to build a column resolver used to lookup a column
   * given the name and alias.
   *
   * @param statement the select statement
   * @return the column resolver
   * @throws SQLException
   * @throws SQLFeatureNotSupportedException if unsupported constructs appear in the FROM clause
   * @throws TableNotFoundException if table name not found in schema
   */
  public static ColumnResolver getResolverForQuery(
      SelectStatement statement, PhoenixConnection connection) throws SQLException {
    List<TableNode> fromNodes = statement.getFrom();
    if (!statement.isJoin() && fromNodes.get(0) instanceof NamedTableNode)
      return new SingleTableColumnResolver(connection, (NamedTableNode) fromNodes.get(0), true);

    MultiTableColumnResolver visitor = new MultiTableColumnResolver(connection);
    for (TableNode node : fromNodes) {
      node.accept(visitor);
    }
    return visitor;
  }