public SqlMoniker lookupQualifiedName(SqlNode topNode, SqlParserPos pos) { final String posString = pos.toString(); IdInfo info = idPositions.get(posString); if (info != null) { final SqlQualified qualified = info.scope.fullyQualify(info.id); return new SqlIdentifierMoniker(qualified.identifier); } else { return null; } }
id = scope.fullyQualify(id).identifier; final SqlValidatorScope.ResolvedImpl resolved = new SqlValidatorScope.ResolvedImpl(); scope.resolve(id.names.subList(0, i), nameMatcher, false, resolved); if (resolved.count() == 1) { RelDataType colType = scope.resolveColumn(id.names.get(0), id); if (colType != null) { type = colType;
public void validateCall( SqlCall call, SqlValidatorScope scope) { final SqlOperator operator = call.getOperator(); if ((call.operandCount() == 0) && (operator.getSyntax() == SqlSyntax.FUNCTION_ID) && !call.isExpanded() && !conformance.allowNiladicParentheses()) { // For example, "LOCALTIME()" is illegal. (It should be // "LOCALTIME", which would have been handled as a // SqlIdentifier.) throw handleUnresolvedFunction(call, (SqlFunction) operator, ImmutableList.of(), null); } SqlValidatorScope operandScope = scope.getOperandScope(call); if (operator instanceof SqlFunction && ((SqlFunction) operator).getFunctionType() == SqlFunctionCategory.MATCH_RECOGNIZE && !(operandScope instanceof MatchRecognizeScope)) { throw newValidationError(call, Static.RESOURCE.functionMatchRecognizeOnly(call.toString())); } // Delegate validation to the operator. operator.validateCall(call, this, scope, operandScope); }
new SqlValidatorScope.ResolvedImpl(); final SqlNameMatcher nameMatcher = catalogReader.nameMatcher(); scope.resolve(ImmutableList.of(name), nameMatcher, false, resolved); if (resolved.count() == 1) { ns = resolved.only().namespace; scope.findAliases(hintList);
/** * Resolves a multi-part identifier such as "SCHEMA.EMP.EMPNO" to a * namespace. The returned namespace, never null, may represent a * schema, table, column, etc. */ public static SqlValidatorNamespace lookup( SqlValidatorScope scope, List<String> names) { assert names.size() > 0; final SqlNameMatcher nameMatcher = scope.getValidator().getCatalogReader().nameMatcher(); final SqlValidatorScope.ResolvedImpl resolved = new SqlValidatorScope.ResolvedImpl(); scope.resolve(ImmutableList.of(names.get(0)), nameMatcher, false, resolved); assert resolved.count() == 1; SqlValidatorNamespace namespace = resolved.only().namespace; for (String name : Util.skip(names)) { namespace = namespace.lookupChild(name); assert namespace != null; } return namespace; }
if (scope instanceof AggregatingSelectScope) { SqlNodeList selectList = ((SqlSelect) scope.getNode()).getSelectList(); scope.lookupWindow(((SqlIdentifier) over).getSimple()); window.getPartitionList().accept(this); window.getOrderList().accept(this); SqlValidatorScope newScope = scope.getOperandScope(call); scopes.push(newScope);
public SqlNode visit(SqlIdentifier id) { // First check for builtin functions which don't have parentheses, // like "LOCALTIME". final SqlCall call = SqlUtil.makeCall(getScope().getValidator().getOperatorTable(), id); if (call != null) { return call; } return getScope().fullyQualify(id).identifier; }
protected SqlWindow getWindowByName( SqlIdentifier id, SqlValidatorScope scope) { SqlWindow window = null; if (id.isSimple()) { final String name = id.getSimple(); window = scope.lookupWindow(name); } if (window == null) { throw newValidationError(id, RESOURCE.windowNotFound(id.toString())); } return window; }
/** * Creates a <code>DelegatingScope</code>. * * @param parent Parent scope */ DelegatingScope(SqlValidatorScope parent) { super(); assert parent != null; this.validator = (SqlValidatorImpl) parent.getValidator(); this.parent = parent; }
public void found(SqlValidatorNamespace namespace, boolean nullable, SqlValidatorScope scope, Path path, List<String> remainingNames) { if (scope instanceof TableScope) { scope = scope.getValidator().getSelectScope((SqlSelect) scope.getNode()); } if (scope instanceof AggregatingSelectScope) { scope = ((AggregatingSelectScope) scope).parent; assert scope instanceof SelectScope; } resolves.add( new Resolve(namespace, nullable, scope, path, remainingNames)); }
public SqlMonotonicity getMonotonicity(SqlNode expr) { return parent.getMonotonicity(expr); }
public SqlNodeList getOrderList() { return parent.getOrderList(); }
public void resolve(List<String> names, SqlNameMatcher nameMatcher, boolean deep, Resolved resolved) { parent.resolve(names, nameMatcher, deep, resolved); }
s = ((JoinScope) s).getUsingScope(); final SqlNode node2 = s != null ? s.getNode() : node; final TableScope tableScope = new TableScope(parentScope, node2); if (usingScope instanceof ListScope) {
/** * Registers a new namespace, and adds it as a child of its parent scope. * Derived class can override this method to tinker with namespaces as they * are created. * * @param usingScope Parent scope (which will want to look for things in * this namespace) * @param alias Alias by which parent will refer to this namespace * @param ns Namespace * @param forceNullable Whether to force the type of namespace to be nullable */ protected void registerNamespace( SqlValidatorScope usingScope, String alias, SqlValidatorNamespace ns, boolean forceNullable) { namespaces.put(ns.getNode(), ns); if (usingScope != null) { usingScope.addChild(ns, alias, forceNullable); } }
public void findAliases(Collection<SqlMoniker> result) { parent.findAliases(result); }
/** * Resolves a multi-part identifier such as "SCHEMA.EMP.EMPNO" to a * namespace. The returned namespace, never null, may represent a * schema, table, column, etc. */ public static SqlValidatorNamespace lookup( SqlValidatorScope scope, List<String> names) { assert names.size() > 0; final SqlNameMatcher nameMatcher = scope.getValidator().getCatalogReader().nameMatcher(); final SqlValidatorScope.ResolvedImpl resolved = new SqlValidatorScope.ResolvedImpl(); scope.resolve(ImmutableList.of(names.get(0)), nameMatcher, false, resolved); assert resolved.count() == 1; SqlValidatorNamespace namespace = resolved.only().namespace; for (String name : Util.skip(names)) { namespace = namespace.lookupChild(name); assert namespace != null; } return namespace; }
if (scope instanceof AggregatingSelectScope) { SqlNodeList selectList = ((SqlSelect) scope.getNode()).getSelectList(); scope.lookupWindow(((SqlIdentifier) over).getSimple()); window.getPartitionList().accept(this); window.getOrderList().accept(this); SqlValidatorScope newScope = scope.getOperandScope(call); scopes.push(newScope);
public SqlNode visit(SqlIdentifier id) { // First check for builtin functions which don't have parentheses, // like "LOCALTIME". final SqlCall call = SqlUtil.makeCall(getScope().getValidator().getOperatorTable(), id); if (call != null) { return call; } return getScope().fullyQualify(id).identifier; }
public SqlWindow resolveWindow( SqlNode windowOrRef, SqlValidatorScope scope, boolean populateBounds) { SqlWindow window; if (windowOrRef instanceof SqlIdentifier) { window = getWindowByName((SqlIdentifier) windowOrRef, scope); } else { window = (SqlWindow) windowOrRef; } while (true) { final SqlIdentifier refId = window.getRefName(); if (refId == null) { break; } final String refName = refId.getSimple(); SqlWindow refWindow = scope.lookupWindow(refName); if (refWindow == null) { throw newValidationError(refId, RESOURCE.windowNotFound(refName)); } window = window.overlay(refWindow, this); } if (populateBounds) { window.populateBounds(); } return window; }