@Override protected R visitSingleColumn(SingleColumn node, C context) { process(node.getExpression(), context); return null; }
private Multimap<QualifiedName, Expression> extractNamedOutputExpressions(Select node) { // Compute aliased output terms so we can resolve order by expressions against them first ImmutableMultimap.Builder<QualifiedName, Expression> assignments = ImmutableMultimap.builder(); for (SelectItem item : node.getSelectItems()) { if (item instanceof SingleColumn) { SingleColumn column = (SingleColumn) item; Optional<Identifier> alias = column.getAlias(); if (alias.isPresent()) { assignments.put(QualifiedName.of(alias.get().getValue()), column.getExpression()); // TODO: need to know if alias was quoted } else if (column.getExpression() instanceof Identifier) { assignments.put(QualifiedName.of(((Identifier) column.getExpression()).getValue()), column.getExpression()); } } } return assignments.build(); }
@Override protected Void visitSingleColumn(SingleColumn node, Integer indent) { builder.append(formatExpression(node.getExpression(), parameters)); if (node.getAlias().isPresent()) { builder.append(' ') .append(formatExpression(node.getAlias().get(), parameters)); } return null; }
SingleColumn column = (SingleColumn) item; Expression expression = column.getExpression(); Optional<Identifier> field = column.getAlias();
ExpressionAnalysis expressionAnalysis = analyzeExpression(column.getExpression(), scope); analysis.recordSubqueries(node, expressionAnalysis); outputExpressionBuilder.add(column.getExpression()); Type type = expressionAnalysis.getType(column.getExpression()); if (node.getSelect().isDistinct() && !type.isComparable()) { throw new SemanticException(TYPE_MISMATCH, node.getSelect(), "DISTINCT can only be applied to comparable types (actual: %s): %s", type, column.getExpression());
private Optional<Integer> findSelectIndex(List<Set<Expression>> items, List<SelectItem> selectItems) { if (items.size() == 1) { Set<Expression> item = items.get(0); if (item.size() == 1) { Expression next = item.iterator().next(); if (next instanceof LongLiteral) { return Optional.of(((int) ((LongLiteral) next).getValue())); } else if (next instanceof Identifier) { for (int i = 0; i < selectItems.size(); i++) { if (selectItems.get(i) instanceof SingleColumn) { if (((SingleColumn) selectItems.get(i)).getExpression().equals(next)) { return Optional.of(i + 1); } } } } return Optional.empty(); } } return Optional.empty(); }
@Override protected Void visitSingleColumn(SingleColumn node, Integer indent) { builder.append(formatExpression(node.getExpression(), tableNameMapper, columnNameMapper, queryWithTables, escapeIdentifier)); if (node.getAlias().isPresent()) { builder.append(' ') .append(formatExpression(node.getAlias().get(), tableNameMapper, columnNameMapper, queryWithTables, escapeIdentifier)); } return null; }
if (singleColumn.getExpression() instanceof FunctionCall) { throw new RakamException("Function call in SELECT is not supported", BAD_REQUEST); String select = RakamSqlFormatter.formatExpression(singleColumn.getExpression(), qualifiedNameStringFunction, columnMappingFunction, ' '); if (!reportRequest.dimensions.stream().anyMatch(e -> e.name.equals(select))) { reportRequest.metrics.add(new GARequest.ReportRequest.Metric(select));
@Override protected R visitSingleColumn(SingleColumn node, C context) { process(node.getExpression(), context); return null; }
@Override protected R visitSingleColumn(SingleColumn node, C context) { process(node.getExpression(), context); return null; }
@Override protected Void visitSingleColumn(SingleColumn node, Integer indent) { builder.append(formatExpression(node.getExpression())); if (node.getAlias().isPresent()) { builder.append(' ') .append('"') .append(node.getAlias().get()) .append('"'); // TODO: handle quoting properly } return null; }
@Override protected Void visitSingleColumn(SingleColumn node, Integer indent) { builder.append(formatExpression(node.getExpression())); if (node.getAlias().isPresent()) { builder.append(' ') .append('"') .append(node.getAlias().get()) .append('"'); // TODO: handle quoting properly } return null; }
@Override protected Void visitSingleColumn(SingleColumn node, Integer indent) { builder.append(formatExpression(node.getExpression(), parameters)); if (node.getAlias().isPresent()) { builder.append(' ') .append(formatExpression(node.getAlias().get(), parameters)); } return null; }
Expression expression = column.getExpression();
ExpressionAnalysis expressionAnalysis = analyzeExpression(column.getExpression(), tupleDescriptor, context); analysis.recordSubqueries(node, expressionAnalysis); outputExpressionBuilder.add(new FieldOrExpression(column.getExpression())); Type type = expressionAnalysis.getType(column.getExpression()); if (node.getSelect().isDistinct() && !type.isComparable()) { throw new SemanticException(TYPE_MISMATCH, node.getSelect(), "DISTINCT can only be applied to comparable types (actual: %s): %s", type, column.getExpression());
private List<FunctionCall> extractAggregates(QuerySpecification node) { AggregateExtractor extractor = new AggregateExtractor(metadata); for (SelectItem item : node.getSelect().getSelectItems()) { if (item instanceof SingleColumn) { extractor.process(((SingleColumn) item).getExpression(), null); } } for (SortItem item : node.getOrderBy()) { extractor.process(item.getSortKey(), null); } if (node.getHaving().isPresent()) { extractor.process(node.getHaving().get(), null); } List<FunctionCall> aggregates = extractor.getAggregates(); analysis.setAggregates(node, aggregates); return aggregates; }
Optional<String> alias = ((SingleColumn) item).getAlias(); if (alias.isPresent()) { byAliasBuilder.put(QualifiedName.of(alias.get()), ((SingleColumn) item).getExpression()); // TODO: need to know if alias was quoted
if(node instanceof SingleColumn){ SingleColumn sc = (SingleColumn)node; Column column = (Column) process(sc.getExpression(), state); if(column != null){ String alias = null;