/** * Returns the <code>ordinal</code>th item in the select list. */ private SqlNode nthSelectItem(int ordinal, final SqlParserPos pos) { // TODO: Don't expand the list every time. Maybe keep an expanded // version of each expression -- select lists and identifiers -- in // the validator. SqlNodeList expandedSelectList = expandStar( select.getSelectList(), select, false); SqlNode expr = expandedSelectList.get(ordinal); expr = stripAs(expr); if (expr instanceof SqlIdentifier) { expr = getScope().fullyQualify((SqlIdentifier) expr).identifier; } // Create a copy of the expression with the position of the order // item. return expr.clone(pos); }
/** * Returns the <code>ordinal</code>th item in the select list. */ private SqlNode nthSelectItem(int ordinal, final SqlParserPos pos) { // TODO: Don't expand the list every time. Maybe keep an expanded // version of each expression -- select lists and identifiers -- in // the validator. SqlNodeList expandedSelectList = expandStar( select.getSelectList(), select, false); SqlNode expr = expandedSelectList.get(ordinal); expr = stripAs(expr); if (expr instanceof SqlIdentifier) { expr = getScope().fullyQualify((SqlIdentifier) expr).identifier; } // Create a copy of the expression with the position of the order // item. return expr.clone(pos); }
public SqlNode visit(SqlIdentifier id) { // Aliases, e.g. 'select a as x, b from t order by x'. if (id.isSimple() && getConformance().isSortByAlias()) { String alias = id.getSimple(); final SqlValidatorNamespace selectNs = getNamespace(select); final RelDataType rowType = selectNs.getRowTypeSansSystemColumns(); final SqlNameMatcher nameMatcher = catalogReader.nameMatcher(); RelDataTypeField field = nameMatcher.field(rowType, alias); if (field != null) { return nthSelectItem( field.getIndex(), id.getParserPosition()); } } // No match. Return identifier unchanged. return getScope().fullyQualify(id).identifier; }
public SqlNode visit(SqlIdentifier id) { // Aliases, e.g. 'select a as x, b from t order by x'. if (id.isSimple() && getConformance().isSortByAlias()) { String alias = id.getSimple(); final SqlValidatorNamespace selectNs = getNamespace(select); final RelDataType rowType = selectNs.getRowTypeSansSystemColumns(); final SqlNameMatcher nameMatcher = catalogReader.nameMatcher(); RelDataTypeField field = nameMatcher.field(rowType, alias); if (field != null) { return nthSelectItem( field.getIndex(), id.getParserPosition()); } } // No match. Return identifier unchanged. return getScope().fullyQualify(id).identifier; }
/** * Returns the <code>ordinal</code>th item in the select list. */ private SqlNode nthSelectItem(int ordinal, final SqlParserPos pos) { // TODO: Don't expand the list every time. Maybe keep an expanded // version of each expression -- select lists and identifiers -- in // the validator. SqlNodeList expandedSelectList = expandStar( select.getSelectList(), select, false); SqlNode expr = expandedSelectList.get(ordinal); expr = stripAs(expr); if (expr instanceof SqlIdentifier) { expr = getScope().fullyQualify((SqlIdentifier) expr).identifier; } // Create a copy of the expression with the position of the order // item. return expr.clone(pos); }
public SqlNode visit(SqlIdentifier id) { // Aliases, e.g. 'select a as x, b from t order by x'. if (id.isSimple() && getConformance().isSortByAlias()) { String alias = id.getSimple(); final SqlValidatorNamespace selectNs = getNamespace(select); final RelDataType rowType = selectNs.getRowTypeSansSystemColumns(); final SqlNameMatcher nameMatcher = catalogReader.nameMatcher(); RelDataTypeField field = nameMatcher.field(rowType, alias); if (field != null) { return nthSelectItem( field.getIndex(), id.getParserPosition()); } } // No match. Return identifier unchanged. return getScope().fullyQualify(id).identifier; }