Exemplo n.º 1
0
  /**
   * Try to find a ResultColumn in the table represented by this FromBaseTable that matches the name
   * in the given ColumnReference.
   *
   * @param columnReference The columnReference whose name we're looking for in the given table.
   * @return A ResultColumn whose expression is the ColumnNode that matches the ColumnReference.
   *     Returns null if there is no match.
   * @exception StandardException Thrown on error
   */
  public ResultColumn getMatchingColumn(ColumnReference columnReference) throws StandardException {
    ResultColumn resultColumn = null;
    String columnsTableName;

    /*
     ** RESOLVE: When we add support for schemas, check to see if
     ** the column name specifies a schema, and if so, if this
     ** table is in that schema.
     */

    columnsTableName = columnReference.getTableName();

    // post 681, 1 may be no longer needed. 5 is the default case
    // now but what happens if the condition is false? Investigate.
    if (columnReference.getGeneratedToReplaceAggregate()) // 1
    {
      resultColumn = resultColumns.getResultColumn(columnReference.getColumnName());
    } else if (columnsTableName == null || columnsTableName.equals(correlationName)) // 5?
    {
      resultColumn =
          resultColumns.getAtMostOneResultColumn(columnReference, correlationName, false);
    }

    if (resultColumn != null) {
      columnReference.setTableNumber(tableNumber);
      columnReference.setColumnNumber(resultColumn.getColumnPosition());
    }

    return resultColumn;
  }