com.facebook.presto.sql.tree.QuerySpecification.getHaving()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(9.1k)|赞(0)|评价(0)|浏览(69)

本文整理了Java中com.facebook.presto.sql.tree.QuerySpecification.getHaving方法的一些代码示例,展示了QuerySpecification.getHaving的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。QuerySpecification.getHaving方法的具体详情如下:
包路径:com.facebook.presto.sql.tree.QuerySpecification
类名称:QuerySpecification
方法名:getHaving

QuerySpecification.getHaving介绍

暂无

代码示例

代码示例来源:origin: prestodb/presto

private boolean hasAggregates(QuerySpecification node)
{
  ImmutableList.Builder<Node> toExtractBuilder = ImmutableList.builder();
  toExtractBuilder.addAll(node.getSelect().getSelectItems().stream()
      .filter(SingleColumn.class::isInstance)
      .collect(toImmutableList()));
  toExtractBuilder.addAll(getSortItemsFromOrderBy(node.getOrderBy()));
  node.getHaving().ifPresent(toExtractBuilder::add);
  List<FunctionCall> aggregates = extractAggregateFunctions(toExtractBuilder.build(), metadata.getFunctionRegistry());
  return !aggregates.isEmpty();
}

代码示例来源:origin: prestodb/presto

private void analyzeHaving(QuerySpecification node, Scope scope)
{
  if (node.getHaving().isPresent()) {
    Expression predicate = node.getHaving().get();
    ExpressionAnalysis expressionAnalysis = analyzeExpression(predicate, scope);
    expressionAnalysis.getWindowFunctions().stream()
        .findFirst()
        .ifPresent(function -> {
          throw new SemanticException(NESTED_WINDOW, function.getNode(), "HAVING clause cannot contain window functions");
        });
    analysis.recordSubqueries(node, expressionAnalysis);
    Type predicateType = expressionAnalysis.getType(predicate);
    if (!predicateType.equals(BOOLEAN) && !predicateType.equals(UNKNOWN)) {
      throw new SemanticException(TYPE_MISMATCH, predicate, "HAVING clause must evaluate to a boolean: actual type %s", predicateType);
    }
    analysis.setHaving(node, predicate);
  }
}

代码示例来源:origin: prestodb/presto

if (node.getHaving().isPresent()) {
  append(indent, "HAVING " + formatExpression(node.getHaving().get(), parameters))
      .append('\n');

代码示例来源:origin: prestodb/presto

@Override
protected R visitQuerySpecification(QuerySpecification node, C context)
{
  process(node.getSelect(), context);
  if (node.getFrom().isPresent()) {
    process(node.getFrom().get(), context);
  }
  if (node.getWhere().isPresent()) {
    process(node.getWhere().get(), context);
  }
  if (node.getGroupBy().isPresent()) {
    process(node.getGroupBy().get(), context);
  }
  if (node.getHaving().isPresent()) {
    process(node.getHaving().get(), context);
  }
  if (node.getOrderBy().isPresent()) {
    process(node.getOrderBy().get(), context);
  }
  return null;
}

代码示例来源:origin: prestodb/presto

querySpecification.getWhere(),
querySpecification.getGroupBy(),
querySpecification.getHaving(),
querySpecification.getOrderBy(),
Optional.of("0"));

代码示例来源:origin: prestodb/presto

private void validateShowStatsSubquery(ShowStats node, Query query, QuerySpecification querySpecification, Plan plan)
{
  // The following properties of SELECT subquery are required:
  //  - only one relation in FROM
  //  - only predicates that can be pushed down can be in the where clause
  //  - no group by
  //  - no having
  //  - no set quantifier
  Optional<FilterNode> filterNode = searchFrom(plan.getRoot())
      .where(FilterNode.class::isInstance)
      .findSingle();
  check(!filterNode.isPresent(), node, "Only predicates that can be pushed down are supported in the SHOW STATS WHERE clause");
  check(querySpecification.getFrom().isPresent(), node, "There must be exactly one table in query passed to SHOW STATS SELECT clause");
  check(querySpecification.getFrom().get() instanceof Table, node, "There must be exactly one table in query passed to SHOW STATS SELECT clause");
  check(!query.getWith().isPresent(), node, "WITH is not supported by SHOW STATS SELECT clause");
  check(!querySpecification.getOrderBy().isPresent(), node, "ORDER BY is not supported in SHOW STATS SELECT clause");
  check(!querySpecification.getLimit().isPresent(), node, "LIMIT is not supported by SHOW STATS SELECT clause");
  check(!querySpecification.getHaving().isPresent(), node, "HAVING is not supported in SHOW STATS SELECT clause");
  check(!querySpecification.getGroupBy().isPresent(), node, "GROUP BY is not supported in SHOW STATS SELECT clause");
  check(!querySpecification.getSelect().isDistinct(), node, "DISTINCT is not supported by SHOW STATS SELECT clause");
  List<SelectItem> selectItems = querySpecification.getSelect().getSelectItems();
  check(selectItems.size() == 1 && selectItems.get(0) instanceof AllColumns, node, "Only SELECT * is supported in SHOW STATS SELECT clause");
}

代码示例来源:origin: prestodb/presto

node.getHaving().ifPresent(sourceExpressions::add);

代码示例来源:origin: prestodb/presto

if (node.getHaving().isPresent()) {
  print(indentLevel, "Having");
  process(node.getHaving().get(), indentLevel + 1);

代码示例来源:origin: prestodb/presto

query.getWhere(),
query.getGroupBy(),
query.getHaving(),
orderBy,
getTextIfPresent(context.limit)),

代码示例来源:origin: rakam-io/rakam

@Override
protected Void visitQuerySpecification(QuerySpecification node, Integer indent) {
  process(node.getSelect(), indent);
  if (node.getFrom().isPresent()) {
    append(indent, "FROM");
    builder.append('\n');
    append(indent, "  ");
    process(node.getFrom().get(), indent);
  }
  builder.append('\n');
  if (node.getWhere().isPresent()) {
    append(indent, "WHERE " + formatExpression(node.getWhere().get(), tableNameMapper, columnNameMapper, queryWithTables, escapeIdentifier))
        .append('\n');
  }
  if (node.getGroupBy().isPresent()) {
    append(indent, "GROUP BY " + (node.getGroupBy().get().isDistinct() ? " DISTINCT " : "") + formatGroupBy(node.getGroupBy().get().getGroupingElements())).append('\n');
  }
  if (node.getHaving().isPresent()) {
    append(indent, "HAVING " + formatExpression(node.getHaving().get(), tableNameMapper, columnNameMapper, queryWithTables, escapeIdentifier))
        .append('\n');
  }
  if (node.getOrderBy().isPresent()) {
    process(node.getOrderBy().get(), indent);
  }
  if (node.getLimit().isPresent()) {
    append(indent, "LIMIT " + node.getLimit().get())
        .append('\n');
  }
  return null;
}

代码示例来源:origin: rakam-io/rakam

if (node.getHaving().isPresent()) {
  throw new IllegalArgumentException();

代码示例来源:origin: uk.co.nichesolutions.presto/presto-main

private void analyzeHaving(QuerySpecification node, RelationType tupleDescriptor, AnalysisContext context)
{
  if (node.getHaving().isPresent()) {
    Expression predicate = node.getHaving().get();
    ExpressionAnalysis expressionAnalysis = analyzeExpression(predicate, tupleDescriptor, context);
    analysis.recordSubqueries(node, expressionAnalysis);
    Type predicateType = expressionAnalysis.getType(predicate);
    if (!predicateType.equals(BOOLEAN) && !predicateType.equals(UNKNOWN)) {
      throw new SemanticException(TYPE_MISMATCH, predicate, "HAVING clause must evaluate to a boolean: actual type %s", predicateType);
    }
    analysis.setHaving(node, predicate);
  }
}

代码示例来源:origin: uk.co.nichesolutions.presto/presto-main

if (node.getHaving().isPresent()) {
  verifyAggregations(node, distinctGroupingColumns, tupleDescriptor, new FieldOrExpression(node.getHaving().get()), columnReferences);

代码示例来源:origin: com.facebook.presto/presto-parser

@Override
protected R visitQuerySpecification(QuerySpecification node, C context)
{
  process(node.getSelect(), context);
  if (node.getFrom().isPresent()) {
    process(node.getFrom().get(), context);
  }
  if (node.getWhere().isPresent()) {
    process(node.getWhere().get(), context);
  }
  if (node.getGroupBy().isPresent()) {
    process(node.getGroupBy().get(), context);
  }
  if (node.getHaving().isPresent()) {
    process(node.getHaving().get(), context);
  }
  if (node.getOrderBy().isPresent()) {
    process(node.getOrderBy().get(), context);
  }
  return null;
}

代码示例来源:origin: vqtran/EchoQuery

if (node.getHaving().isPresent()) {
  append(indent, "HAVING " + formatExpression(node.getHaving().get()))
      .append('\n');

代码示例来源:origin: uk.co.nichesolutions.presto/presto-parser

if (node.getHaving().isPresent()) {
  append(indent, "HAVING " + formatExpression(node.getHaving().get()))
      .append('\n');

代码示例来源:origin: com.facebook.presto/presto-parser

if (node.getHaving().isPresent()) {
  append(indent, "HAVING " + formatExpression(node.getHaving().get(), parameters))
      .append('\n');

代码示例来源:origin: uk.co.nichesolutions.presto/presto-parser

@Override
protected R visitQuerySpecification(QuerySpecification node, C context)
{
  process(node.getSelect(), context);
  if (node.getFrom().isPresent()) {
    process(node.getFrom().get(), context);
  }
  if (node.getWhere().isPresent()) {
    process(node.getWhere().get(), context);
  }
  if (node.getGroupBy().isPresent()) {
    for (GroupingElement groupingElement : node.getGroupBy().get().getGroupingElements()) {
      process(groupingElement, context);
    }
  }
  if (node.getHaving().isPresent()) {
    process(node.getHaving().get(), context);
  }
  for (SortItem sortItem : node.getOrderBy()) {
    process(sortItem, context);
  }
  return null;
}

代码示例来源:origin: uk.co.nichesolutions.presto/presto-main

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;
}

代码示例来源:origin: com.facebook.presto/presto-parser

query.getWhere(),
query.getGroupBy(),
query.getHaving(),
orderBy,
getTextIfPresent(context.limit)),

相关文章