parentScope = ((DelegatingScope) parentScope).getParent(); } else { break;
columnName = identifier.names.get(0); tableName = findQualifyingTableName(columnName, identifier); final SqlValidatorNamespace fromNs = resolve(tableName, null, null); if (fromNs == null) { throw validator.newValidationError(identifier.getComponent(0),
public SqlIdentifier fullyQualify(SqlIdentifier identifier) { // If it's a simple identifier, look for an alias. if (identifier.isSimple() && validator.getConformance().isSortByAlias()) { String name = identifier.names.get(0); final SqlValidatorNamespace selectNs = validator.getNamespace(select); final RelDataType rowType = selectNs.getRowType(); if (validator.catalogReader.field(rowType, name) != null) { return identifier; } } return super.fullyQualify(identifier); }
public SqlValidatorScope getOperandScope(SqlCall call) { if (call.getOperator().isAggregator()) { // If we're the 'SUM' node in 'select a + sum(b + c) from t // group by a', then we should validate our arguments in // the non-aggregating scope, where 'b' and 'c' are valid // column references. return parent; } else { // Check whether expression is constant within the group. // // If not, throws. Example, 'empno' in // SELECT empno FROM emp GROUP BY deptno // // If it perfectly matches an expression in the GROUP BY // clause, we validate its arguments in the non-aggregating // scope. Example, 'empno + 1' in // // SELECT empno + 1 FROM emp GROUP BY empno + 1 final boolean matches = checkAggregateExpr(call, false); if (matches) { return parent; } } return super.getOperandScope(call); }
columnName = identifier.names[0]; tableName = findQualifyingTableName(columnName, identifier); final SqlValidatorNamespace fromNs = resolve(tableName, null, null); if (fromNs == null) { throw validator.newValidationError(
public SqlIdentifier fullyQualify(SqlIdentifier identifier) { // If it's a simple identifier, look for an alias. if (identifier.isSimple() && validator.getConformance().isSortByAlias()) { String name = identifier.names[0]; final SqlValidatorNamespace selectNs = validator.getNamespace(select); final RelDataType rowType = selectNs.getRowType(); if (SqlValidatorUtil.lookupField(rowType, name) != null) { return identifier; } } return super.fullyQualify(identifier); }
public SqlValidatorScope getOperandScope(SqlCall call) { if (call.getOperator().isAggregator()) { // If we're the 'SUM' node in 'select a + sum(b + c) from t // group by a', then we should validate our arguments in // the non-aggregating scope, where 'b' and 'c' are valid // column references. return parent; } else if (call instanceof SqlWindow) { return parent; } else { // Check whether expression is constant within the group. // // If not, throws. Example, 'empno' in // SELECT empno FROM emp GROUP BY deptno // // If it perfectly matches an expression in the GROUP BY // clause, we validate its arguments in the non-aggregating // scope. Example, 'empno + 1' in // // SELET empno + 1 FROM emp GROUP BY empno + 1 final boolean matches = checkAggregateExpr(call, false); if (matches) { return parent; } } return super.getOperandScope(call); }
public static SelectScope getEnclosingSelectScope(SqlValidatorScope scope) { while (scope instanceof DelegatingScope) { if (scope instanceof SelectScope) { return (SelectScope) scope; } scope = ((DelegatingScope) scope).getParent(); } return null; }
public static SelectScope getEnclosingSelectScope(SqlValidatorScope scope) { while (scope instanceof DelegatingScope) { if (scope instanceof SelectScope) { return (SelectScope) scope; } scope = ((DelegatingScope) scope).getParent(); } return null; }
createBlackboard( Util.first(validator.getJoinScope(left), ((DelegatingScope) bb.scope).getParent()), null); final Blackboard rightBlackboard = createBlackboard( Util.first(validator.getJoinScope(right), ((DelegatingScope) bb.scope).getParent()), null); convertFrom(leftBlackboard, left); RelNode leftRel = leftBlackboard.root;
parentScope = ((DelegatingScope) parentScope).getParent(); } else { break;
parentScope = ((DelegatingScope) parentScope).getParent(); } else { break;
private SqlValidatorNamespace getNamespace(SqlNode node, SqlValidatorScope scope) { if (node instanceof SqlIdentifier && scope instanceof DelegatingScope) { final SqlIdentifier id = (SqlIdentifier) node; final SqlValidatorScope parentScope = ((DelegatingScope) scope).getParent(); if (id.isSimple()) { SqlValidatorNamespace ns = parentScope.resolve(id.getSimple(), null, null); if (ns != null) { return ns; } } } return getNamespace(node); }
createBlackboard( Util.first(validator.getJoinScope(left), ((DelegatingScope) bb.scope).getParent()), null); final Blackboard rightBlackboard = createBlackboard( Util.first(validator.getJoinScope(right), ((DelegatingScope) bb.scope).getParent()), null); convertFrom(leftBlackboard, left); RelNode leftRel = leftBlackboard.root;