public void addOnCondition(ParseNode node) throws SQLException { node.accept(onNodeVisitor); }
private SubselectRewriter(ColumnResolver resolver, List<AliasedNode> aliasedNodes, String tableAlias) { super(resolver, aliasedNodes.size()); this.tableAlias = tableAlias; this.aliasMap = new HashMap<String, ParseNode>(); for (AliasedNode aliasedNode : aliasedNodes) { String alias = aliasedNode.getAlias(); ParseNode node = aliasedNode.getNode(); if (alias == null) { alias = SchemaUtil.normalizeIdentifier(node.getAlias()); } if (alias != null) { aliasMap.put(SchemaUtil.getColumnName(tableAlias, alias), node); } } }
if (child instanceof RowValueConstructorParseNode) { if (flattenedChildren == children) { flattenedChildren = Lists.newArrayListWithExpectedSize(children.size() + child.getChildren().size()); flattenedChildren.addAll(children.subList(0, i)); flattenedChildren.addAll(child.getChildren());
ExpressionCompiler.throwNonAggExpressionInAggException(node.toString()); Expression expression = node.accept(selectVisitor); projectedExpressions.add(expression); expression = coerceIfNecessary(index, targetColumns, expression); context.getBindManager().addParamMetaData((BindParseNode)node, expression); if (!node.isStateless()) { if (!selectVisitor.isAggregate() && statement.isAggregate()) { ExpressionCompiler.throwNonAggExpressionInAggException(expression.toString()); String columnAlias = aliasedNode.getAlias() != null ? aliasedNode.getAlias() : SchemaUtil.normalizeIdentifier(aliasedNode.getNode().getAlias()); boolean isCaseSensitive = aliasedNode.getAlias() != null ? aliasedNode.isCaseSensitve() : (columnAlias != null ? SchemaUtil.isCaseSensitive(aliasedNode.getNode().getAlias()) : selectVisitor.isCaseSensitive); String name = columnAlias == null ? expression.toString() : columnAlias; projectedColumns.add(new ExpressionProjector(name, tableRef.getTableAlias() == null ? (table.getName() == null ? "" : table.getName().getString()) : tableRef.getTableAlias(), expression, isCaseSensitive));
@Override public final String toString() { StringBuilder buf = new StringBuilder(); toSQL(null, buf); return buf.toString(); }
} else { whereNode = StatementNormalizer.normalize(whereNode, resolver); if (whereNode.isStateless()) { throw new SQLExceptionInfo.Builder(SQLExceptionCode.VIEW_WHERE_IS_CONSTANT) .build().buildException(); whereNode = select.getWhere(); Expression where = whereNode.accept(expressionCompiler); if (where != null && !LiteralExpression.isTrue(where)) { TableName baseTableName = create.getBaseTableName(); StringBuilder buf = new StringBuilder(); whereNode.toSQL(resolver, buf); viewStatementToBe = QueryUtil.getViewStatement(baseTableName.getSchemaName(), baseTableName.getTableName(), buf.toString()); context.getBindManager().addParamMetaData((BindParseNode) node, VARBINARY_DATUM); if (node.isStateless()) { Expression expression = node.accept(expressionCompiler); if (expression.evaluate(null, ptr)) {; splits[i] = ByteUtil.copyKeyBytesIfNecessary(ptr);
CompoundParseNode(List<ParseNode> children) { this.children = Collections.unmodifiableList(children); boolean isStateless = true; for (ParseNode child : children) { isStateless &= child.isStateless(); if (!isStateless) { break; } } this.isStateless = isStateless; }
boolean hasWhereSubquery = select.getWhere() != null && select.getWhere().hasSubquery(); runOnServer = (sameTable || (serverUpsertSelectEnabled && !hasGlobalMutableIndexes)) && isAutoCommit if (!valueNode.isStateless()) { throw new SQLExceptionInfo.Builder(SQLExceptionCode.VALUE_IN_UPSERT_NOT_CONSTANT).build().buildException(); Expression expression = valueNode.accept(expressionBuilder); if (expression.getDataType() != null && !expression.getDataType().isCastableTo(column.getDataType())) { throw TypeMismatchException.newException( ParseNode updateNode = columnPair.getSecond(); compiler.setColumn(updateColumn); Expression updateExpression = updateNode.accept(compiler);
if (aliasedNode.getNode() instanceof DistinctCountParseNode) { groupByNodes.addAll(aliasedNode.getNode().getChildren()); } else { for (int i = 0; i < groupByNodes.size(); i++) { ParseNode node = groupByNodes.get(i); Expression expression = node.accept(compiler); if (!expression.isStateless()) { if (compiler.isAggregate()) {
for (int i = 0; i < splits.length; i++) { ParseNode node = splitNodes.get(i); if (!node.isStateless()) { throw new SQLExceptionInfo.Builder(SQLExceptionCode.SPLIT_POINT_NOT_CONSTANT) .setMessage("Node: " + node).build().buildException(); LiteralExpression expression = (LiteralExpression)node.accept(expressionCompiler); splits[i] = expression.getBytes();
@Override public String toString() { return child.toString() + (orderAscending ? " asc" : " desc") + " nulls " + (nullsLast ? "last" : "first"); }
&& !select.isJoin() && select.getInnerSelectStatement() == null && (select.getWhere() == null || !select.getWhere().hasSubquery())) { return getApplicablePlansForSingleFlatQuery(dataPlan, statement, targetColumns, parallelIteratorFactory, stopAtBestPlan); || (select.getWhere() != null && select.getWhere().hasSubquery())) { JoinCompiler.JoinTable join = JoinCompiler.compile(statement, select, resolver); Map<TableRef, TableRef> replacement = null; if (stmt.getWhere() != null && stmt.getWhere().hasSubquery()) { StatementContext context = new StatementContext(statement, resolver, new Scan(), new SequenceManager(statement));;
ExpressionCompiler.throwNonAggExpressionInAggException(node.toString()); Expression expression = node.accept(selectVisitor); projectedExpressions.add(expression); expression = coerceIfNecessary(index, targetColumns, expression); context.getBindManager().addParamMetaData((BindParseNode)node, expression); if (!node.isStateless()) { if (!selectVisitor.isAggregate() && statement.isAggregate()) { ExpressionCompiler.throwNonAggExpressionInAggException(expression.toString()); String columnAlias = aliasedNode.getAlias() != null ? aliasedNode.getAlias() : SchemaUtil.normalizeIdentifier(aliasedNode.getNode().getAlias()); boolean isCaseSensitive = aliasedNode.getAlias() != null ? aliasedNode.isCaseSensitve() : (columnAlias != null ? SchemaUtil.isCaseSensitive(aliasedNode.getNode().getAlias()) : selectVisitor.isCaseSensitive); String name = columnAlias == null ? expression.toString() : columnAlias; projectedColumns.add(new ExpressionProjector(name, tableRef.getTableAlias() == null ? (table.getName() == null ? "" : table.getName().getString()) : tableRef.getTableAlias(), expression, isCaseSensitive));
public void toSQL(ColumnResolver resolver, StringBuilder buf) { child.toSQL(resolver, buf); if (!orderAscending) buf.append(" DESC"); if (nullsLast) buf.append(" NULLS LAST "); } }
private static int countConstants(List<ParseNode> nodes) { int count = 0; for (int i = 0; i < nodes.size(); i++) { if (nodes.get(i).isStateless()) { count++; } } return count; }
if (aliasedNode.getNode() instanceof DistinctCountParseNode) { groupByNodes.addAll(aliasedNode.getNode().getChildren()); } else { for (int i = 0; i < groupByNodes.size(); i++) { ParseNode node = groupByNodes.get(i); Expression expression = node.accept(compiler); if (!expression.isStateless()) { if (compiler.isAggregate()) {
ParseNode defaultParseNode = new SQLParser(this.getExpression()).parseExpression(); Expression defaultExpression = defaultParseNode.accept(compiler); if (!defaultParseNode.isStateless() || defaultExpression.getDeterminism() != Determinism.ALWAYS) { throw new SQLExceptionInfo.Builder(SQLExceptionCode.CANNOT_CREATE_DEFAULT)
/** * Fall through visit method. Anything coming through * here means that a more specific method wasn't found * and thus this Node is not yet supported. */ @Override public E visit(ParseNode expressionNode) throws SQLException { throw new SQLFeatureNotSupportedException(expressionNode.toString()); }
&& !select.isJoin() && select.getInnerSelectStatement() == null && (select.getWhere() == null || !select.getWhere().hasSubquery())) { return getApplicablePlansForSingleFlatQuery(dataPlan, statement, targetColumns, parallelIteratorFactory, stopAtBestPlan); || (select.getWhere() != null && select.getWhere().hasSubquery())) { JoinCompiler.JoinTable join = JoinCompiler.compile(statement, select, resolver); Map<TableRef, TableRef> replacement = null; if (stmt.getWhere() != null && stmt.getWhere().hasSubquery()) { StatementContext context = new StatementContext(statement, resolver, new Scan(), new SequenceManager(statement));;
ExpressionCompiler.throwNonAggExpressionInAggException(node.toString()); Expression expression = node.accept(selectVisitor); projectedExpressions.add(expression); expression = coerceIfNecessary(index, targetColumns, expression); context.getBindManager().addParamMetaData((BindParseNode)node, expression); if (!node.isStateless()) { if (!selectVisitor.isAggregate() && statement.isAggregate()) { ExpressionCompiler.throwNonAggExpressionInAggException(expression.toString()); String columnAlias = aliasedNode.getAlias() != null ? aliasedNode.getAlias() : SchemaUtil.normalizeIdentifier(aliasedNode.getNode().getAlias()); columnAlias = Strings.isNullOrEmpty(columnAlias)? columnAlias : SchemaUtil.getUnEscapedFullColumnName(columnAlias); boolean isCaseSensitive = aliasedNode.getAlias() != null ? aliasedNode.isCaseSensitve() : (columnAlias != null ? SchemaUtil.isCaseSensitive(aliasedNode.getNode().getAlias()) : selectVisitor.isCaseSensitive); String name = columnAlias == null ? expression.toString() : columnAlias; projectedColumns.add(new ExpressionProjector(name, tableRef.getTableAlias() == null ? (table.getName() == null ? "" : table.getName().getString()) : tableRef.getTableAlias(), expression, isCaseSensitive));