public SqlNode validateParameterizedExpression( SqlNode topNode, final Map<String, RelDataType> nameToTypeMap) { SqlValidatorScope scope = new ParameterScope(this, nameToTypeMap); return validateScopedExpression(topNode, scope); }
private void lookupSelectHints( SqlValidatorNamespace ns, SqlParserPos pos, Collection<SqlMoniker> hintList) { final SqlNode node = ns.getNode(); if (node instanceof SqlSelect) { lookupSelectHints((SqlSelect) node, pos, hintList); } }
public SqlNode expandOrderExpr(SqlSelect select, SqlNode orderExpr) { final SqlNode newSqlNode = new OrderExpressionExpander(select, orderExpr).go(); if (newSqlNode != orderExpr) { final SqlValidatorScope scope = getOrderScope(select); inferUnknownTypes(unknownType, scope, newSqlNode); final RelDataType type = deriveType(scope, newSqlNode); setValidatedNodeType(newSqlNode, type); } return newSqlNode; }
private SqlValidatorNamespace getNamespace(SqlIdentifier id, DelegatingScope scope) { if (id.isSimple()) { final SqlNameMatcher nameMatcher = catalogReader.nameMatcher(); final SqlValidatorScope.ResolvedImpl resolved = new SqlValidatorScope.ResolvedImpl(); scope.resolve(id.names, nameMatcher, false, resolved); if (resolved.count() == 1) { return resolved.only().namespace; } } return getNamespace(id); }
/** * Validates a namespace. * * @param namespace Namespace * @param targetRowType Desired row type, must not be null, may be the data * type 'unknown'. */ protected void validateNamespace(final SqlValidatorNamespace namespace, RelDataType targetRowType) { namespace.validate(targetRowType); if (namespace.getNode() != null) { setValidatedNodeType(namespace.getNode(), namespace.getType()); } }
public void validateDelete(SqlDelete call) { final SqlSelect sqlSelect = call.getSourceSelect(); validateSelect(sqlSelect, unknownType); final SqlValidatorNamespace targetNamespace = getNamespace(call); validateNamespace(targetNamespace, unknownType); final SqlValidatorTable table = targetNamespace.getTable(); validateAccess(call.getTargetTable(), table, SqlAccessEnum.DELETE); }
SqlValidatorNamespace lookupFieldNamespace(RelDataType rowType, String name) { final SqlNameMatcher nameMatcher = catalogReader.nameMatcher(); final RelDataTypeField field = nameMatcher.field(rowType, name); return new FieldNamespace(this, field.getType()); }
public SqlNode validate(SqlNode topNode) { SqlValidatorScope scope = new EmptyScope(this); scope = new CatalogScope(scope, ImmutableList.of("CATALOG")); final SqlNode topNode2 = validateScopedExpression(topNode, scope); final RelDataType type = getValidatedNodeType(topNode2); Util.discard(type); return topNode2; }
/** If there is at least one call to an aggregate function, returns the * first. */ private SqlNode getAgg(SqlSelect select) { final SelectScope selectScope = getRawSelectScope(select); if (selectScope != null) { final List<SqlNode> selectList = selectScope.getExpandedSelectList(); if (selectList != null) { return aggFinder.findAgg(selectList); } } return aggFinder.findAgg(select.getSelectList()); }
OrderExpressionExpander(SqlSelect select, SqlNode root) { super(getOrderScope(select)); this.select = select; this.root = root; this.aliasList = getNamespace(select).getRowType().getFieldNames(); }
private RelDataTypeField field(String name) { return catalogReader.nameMatcher().field(rowType, name); }
public SelectScope getRawSelectScope(SqlSelect select) { SqlValidatorScope scope = getSelectScope(select); if (scope instanceof AggregatingSelectScope) { scope = ((AggregatingSelectScope) scope).getParent(); } return (SelectScope) scope; }
/** * Validates an item in the GROUP BY clause of a SELECT statement. * * @param select Select statement * @param groupByItem GROUP BY clause item */ private void validateGroupByItem(SqlSelect select, SqlNode groupByItem) { final SqlValidatorScope groupByScope = getGroupScope(select); groupByScope.validateExpr(groupByItem); }
public SqlNode expand(SqlNode expr, SqlValidatorScope scope) { final Expander expander = new Expander(this, scope); SqlNode newExpr = expr.accept(expander); if (expr != newExpr) { setOriginal(newExpr, expr); } return newExpr; }
public SqlNode expandGroupByOrHavingExpr(SqlNode expr, SqlValidatorScope scope, SqlSelect select, boolean havingExpression) { final Expander expander = new ExtendedExpander(this, scope, select, expr, havingExpression); SqlNode newExpr = expr.accept(expander); if (expr != newExpr) { setOriginal(newExpr, expr); } return newExpr; }
public String deriveAlias( SqlNode node, int ordinal) { return SqlValidatorUtil.getAlias(node, ordinal); }
@Override public CalciteContextException apply( SqlNode v0, Resources.ExInst<SqlValidatorException> v1) { return newValidationError(v0, v1); } }
protected MatchRecognizeNamespace createMatchRecognizeNameSpace( SqlMatchRecognize call, SqlNode enclosingNode) { return new MatchRecognizeNamespace(this, call, enclosingNode); }
protected SqlNode visitScoped(SqlCall call) { // Don't attempt to expand sub-queries. We haven't implemented // these yet. if (call instanceof SqlSelect) { return call; } return super.visitScoped(call); } }