io.prestosql.sql.tree.QuerySpecification.getHaving()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(70)

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

QuerySpecification.getHaving介绍

暂无

代码示例

代码示例来源:origin: prestosql/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: io.prestosql/presto-main

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: prestosql/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: io.prestosql/presto-main

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: io.prestosql/presto-parser

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

代码示例来源:origin: io.prestosql/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: prestosql/presto

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

代码示例来源:origin: prestosql/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: prestosql/presto

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

代码示例来源:origin: prestosql/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: prestosql/presto

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

代码示例来源:origin: io.prestosql/presto-main

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: io.prestosql/presto-main

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

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

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

代码示例来源:origin: io.prestosql/presto-parser

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

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

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

代码示例来源:origin: io.prestosql/presto-parser

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

相关文章