/** * Determines the origin of a column, provided the column maps to a single * column that isn't derived. * * @see #getColumnOrigins(org.apache.calcite.rel.RelNode, int) * * @param rel the RelNode of the column * @param column the offset of the column whose origin we are trying to * determine * * @return the origin of a column provided it's a simple column; otherwise, * returns null */ public RelColumnOrigin getColumnOrigin(RelNode rel, int column) { final Set<RelColumnOrigin> origins = getColumnOrigins(rel, column); if (origins == null || origins.size() != 1) { return null; } final RelColumnOrigin origin = Iterables.getOnlyElement(origins); return origin.isDerived() ? null : origin; }
/** * Determines the origin of a column, provided the column maps to a single * column that isn't derived. * * @see #getColumnOrigins(org.apache.calcite.rel.RelNode, int) * * @param rel the RelNode of the column * @param column the offset of the column whose origin we are trying to * determine * * @return the origin of a column provided it's a simple column; otherwise, * returns null */ public RelColumnOrigin getColumnOrigin(RelNode rel, int column) { final Set<RelColumnOrigin> origins = getColumnOrigins(rel, column); if (origins == null || origins.size() != 1) { return null; } final RelColumnOrigin origin = Iterables.getOnlyElement(origins); return origin.isDerived() ? null : origin; }
List<String> table = Origins.getTable(relColumnOrigin); String colName = Origins.getColName(relColumnOrigin); namedOrigins.add(new Origin(colName, relColumnOrigin.isDerived()).setTableList(table));
if (origins == null || origins.size() != 1 || origins.iterator().next().isDerived()) { throw failed();
public static void checkColumnOrigin( RelColumnOrigin rco, String expectedTableName, String expectedColumnName, boolean expectedDerived) { RelOptTable actualTable = rco.getOriginTable(); List<String> actualTableName = actualTable.getQualifiedName(); assertEquals( Iterables.getLast(actualTableName), expectedTableName); assertEquals( actualTable.getRowType() .getFieldList() .get(rco.getOriginColumnOrdinal()) .getName(), expectedColumnName); assertEquals( rco.isDerived(), expectedDerived); }
public static void checkColumnOrigin( RelColumnOrigin rco, String expectedTableName, String expectedColumnName, boolean expectedDerived) { RelOptTable actualTable = rco.getOriginTable(); List<String> actualTableName = actualTable.getQualifiedName(); assertEquals( Iterables.getLast(actualTableName), expectedTableName); assertEquals( actualTable.getRowType() .getFieldList() .get(rco.getOriginColumnOrdinal()) .getName(), expectedColumnName); assertEquals( rco.isDerived(), expectedDerived); }