com.facebook.presto.sql.tree.Window类的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(10.0k)|赞(0)|评价(0)|浏览(137)

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

Window介绍

暂无

代码示例

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

@Override
public R visitWindow(Window node, C context)
{
  for (Expression expression : node.getPartitionBy()) {
    process(expression, context);
  }
  if (node.getOrderBy().isPresent()) {
    process(node.getOrderBy().get(), context);
  }
  if (node.getFrame().isPresent()) {
    process(node.getFrame().get(), context);
  }
  return null;
}

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

@Override
public Node visitOver(SqlBaseParser.OverContext context)
{
  Optional<OrderBy> orderBy = Optional.empty();
  if (context.ORDER() != null) {
    orderBy = Optional.of(new OrderBy(getLocation(context.ORDER()), visit(context.sortItem(), SortItem.class)));
  }
  return new Window(
      getLocation(context),
      visit(context.partition, Expression.class),
      orderBy,
      visitIfPresent(context.windowFrame(), WindowFrame.class));
}

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

@Override
public boolean equals(Object object)
{
  if (this == object) {
    return true;
  }
  if (object == null || !(object instanceof FunctionCall)) {
    return false;
  }
  FunctionCall other = (FunctionCall) object;
  return Objects.equals(name, other.getName()) &&
      other.getWindow().isPresent() &&
      Objects.equals(frame, other.getWindow().get().getFrame()) &&
      Objects.equals(distinct, other.isDistinct()) &&
      Objects.equals(getArguments(), other.getArguments());
}

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

@Override
public String visitWindow(Window node, Void context)
{
  List<String> parts = new ArrayList<>();
  if (!node.getPartitionBy().isEmpty()) {
    parts.add("PARTITION BY " + joinExpressions(node.getPartitionBy()));
  }
  if (node.getOrderBy().isPresent()) {
    parts.add(formatOrderBy(node.getOrderBy().get(), parameters));
  }
  if (node.getFrame().isPresent()) {
    parts.add(process(node.getFrame().get(), context));
  }
  return '(' + Joiner.on(' ').join(parts) + ')';
}

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

ExpectedValueProvider<WindowNode.Specification> specificationAB = specification(ImmutableList.of(columnAAlias, columnBAlias), ImmutableList.of(), ImmutableMap.of());
Optional<Window> windowAB = Optional.of(new Window(ImmutableList.of(new SymbolReference("a"), new SymbolReference("b")), Optional.empty(), Optional.empty()));
Optional<Window> windowA = Optional.of(new Window(ImmutableList.of(new SymbolReference("a")), Optional.empty(), Optional.empty()));

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

@Override
public Boolean visitWindow(Window node, Void context)
{
  for (Expression expression : node.getPartitionBy()) {
    if (!process(expression, context)) {
      throw new SemanticException(MUST_BE_AGGREGATE_OR_GROUP_BY,
          expression,
          "PARTITION BY expression '%s' must be an aggregate expression or appear in GROUP BY clause",
          expression);
    }
  }
  for (SortItem sortItem : getSortItemsFromOrderBy(node.getOrderBy())) {
    Expression expression = sortItem.getSortKey();
    if (!process(expression, context)) {
      throw new SemanticException(MUST_BE_AGGREGATE_OR_GROUP_BY,
          expression,
          "ORDER BY expression '%s' must be an aggregate expression or appear in GROUP BY clause",
          expression);
    }
  }
  if (node.getFrame().isPresent()) {
    process(node.getFrame().get(), context);
  }
  return true;
}

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

@Test
  public void dependentWindowsAreNotReordered()
  {
    Optional<Window> windowA = Optional.of(new Window(ImmutableList.of(new SymbolReference("a")), Optional.empty(), Optional.empty()));

    tester().assertThat(new GatherAndMergeWindows.SwapAdjacentWindowsBySpecifications(0))
        .on(p ->
            p.window(new WindowNode.Specification(
                    ImmutableList.of(p.symbol("a")),
                    Optional.empty()),
                ImmutableMap.of(p.symbol("avg_1"),
                    new WindowNode.Function(new FunctionCall(QualifiedName.of("avg"), windowA, false, ImmutableList.of(new SymbolReference("avg_2"))), signature, frame)),
                p.window(new WindowNode.Specification(
                        ImmutableList.of(p.symbol("a"), p.symbol("b")),
                        Optional.empty()),
                    ImmutableMap.of(p.symbol("avg_2"),
                        new WindowNode.Function(new FunctionCall(QualifiedName.of("avg"), windowA, false, ImmutableList.of(new SymbolReference("a"))), signature, frame)),
                    p.values(p.symbol("a"), p.symbol("b")))))
        .doesNotFire();
  }
}

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

toExtract.addAll(window.getPartitionBy());
window.getOrderBy().ifPresent(orderBy -> toExtract.addAll(orderBy.getSortItems()));
window.getFrame().ifPresent(toExtract::add);
if (window.getFrame().isPresent()) {
  analyzeWindowFrame(window.getFrame().get());

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

@Override
public Node visitOver(SqlBaseParser.OverContext context)
{
  Optional<OrderBy> orderBy = Optional.empty();
  if (context.ORDER() != null) {
    orderBy = Optional.of(new OrderBy(getLocation(context.ORDER()), visit(context.sortItem(), SortItem.class)));
  }
  return new Window(
      getLocation(context),
      visit(context.partition, Expression.class),
      orderBy,
      visitIfPresent(context.windowFrame(), WindowFrame.class));
}

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

Expression frameEnd = null;
if (window.getFrame().isPresent()) {
  WindowFrame frame = window.getFrame().get();
  frameType = frame.getType();
    .addAll(window.getPartitionBy())
    .addAll(Iterables.transform(getSortItemsFromOrderBy(window.getOrderBy()), SortItem::getSortKey));
for (Expression expression : window.getPartitionBy()) {
  partitionBySymbols.add(subPlan.translate(expression));
for (SortItem item : getSortItemsFromOrderBy(window.getOrderBy())) {
  Symbol symbol = subPlan.translate(item.getSortKey());

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

@Override
public Node visitOver(SqlBaseParser.OverContext context)
{
  return new Window(
      getLocation(context),
      visit(context.partition, Expression.class),
      visit(context.sortItem(), SortItem.class),
      visitIfPresent(context.windowFrame(), WindowFrame.class));
}

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

for (Expression expression : node.getWindow().get().getPartitionBy()) {
  process(expression, context);
  Type type = getExpressionType(expression);
for (SortItem sortItem : getSortItemsFromOrderBy(node.getWindow().get().getOrderBy())) {
  process(sortItem.getSortKey(), context);
  Type type = getExpressionType(sortItem.getSortKey());
if (node.getWindow().get().getFrame().isPresent()) {
  WindowFrame frame = node.getWindow().get().getFrame().get();

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

@Override
public String visitWindow(Window node, Void context) {
  List<String> parts = new ArrayList<>();
  if (!node.getPartitionBy().isEmpty()) {
    parts.add("PARTITION BY " + joinExpressions(node.getPartitionBy()));
  }
  if (node.getOrderBy().isPresent()) {
    parts.add(formatOrderBy(node.getOrderBy().get(), tableNameMapper, columnNameMapper, queryWithTables, escape));
  }
  if (node.getFrame().isPresent()) {
    parts.add(process(node.getFrame().get(), context));
  }
  return '(' + Joiner.on(' ').join(parts) + ')';
}

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

@Override
public R visitWindow(Window node, C context)
{
  for (Expression expression : node.getPartitionBy()) {
    process(expression, context);
  }
  if (node.getOrderBy().isPresent()) {
    process(node.getOrderBy().get(), context);
  }
  if (node.getFrame().isPresent()) {
    process(node.getFrame().get(), context);
  }
  return null;
}

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

@Override
public String visitWindow(Window node, Void context)
{
  List<String> parts = new ArrayList<>();
  if (!node.getPartitionBy().isEmpty()) {
    parts.add("PARTITION BY " + joinExpressions(node.getPartitionBy()));
  }
  if (node.getOrderBy().isPresent()) {
    parts.add(formatOrderBy(node.getOrderBy().get(), parameters));
  }
  if (node.getFrame().isPresent()) {
    parts.add(process(node.getFrame().get(), context));
  }
  return '(' + Joiner.on(' ').join(parts) + ')';
}

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

@Override
public String visitWindow(Window node, Boolean unmangleNames)
{
  List<String> parts = new ArrayList<>();
  if (!node.getPartitionBy().isEmpty()) {
    parts.add("PARTITION BY " + joinExpressions(node.getPartitionBy(), unmangleNames));
  }
  if (!node.getOrderBy().isEmpty()) {
    parts.add("ORDER BY " + formatSortItems(node.getOrderBy(), unmangleNames));
  }
  if (node.getFrame().isPresent()) {
    parts.add(process(node.getFrame().get(), unmangleNames));
  }
  return '(' + Joiner.on(' ').join(parts) + ')';
}

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

@Override
public String visitWindow(Window node, Boolean unmangleNames)
{
  List<String> parts = new ArrayList<>();
  if (!node.getPartitionBy().isEmpty()) {
    parts.add("PARTITION BY " + joinExpressions(node.getPartitionBy(), unmangleNames));
  }
  if (!node.getOrderBy().isEmpty()) {
    parts.add("ORDER BY " + formatSortItems(node.getOrderBy(), unmangleNames));
  }
  if (node.getFrame().isPresent()) {
    parts.add(process(node.getFrame().get(), unmangleNames));
  }
  return '(' + Joiner.on(' ').join(parts) + ')';
}

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

@Override
public R visitWindow(Window node, C context)
{
  for (Expression expression : node.getPartitionBy()) {
    process(expression, context);
  }
  for (SortItem sortItem : node.getOrderBy()) {
    process(sortItem.getSortKey(), context);
  }
  if (node.getFrame().isPresent()) {
    process(node.getFrame().get(), context);
  }
  return null;
}

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

@Override
public Boolean visitWindow(Window node, Void context)
{
  for (Expression expression : node.getPartitionBy()) {
    if (!process(expression, context)) {
      throw new SemanticException(MUST_BE_AGGREGATE_OR_GROUP_BY,
          expression,
          "PARTITION BY expression '%s' must be an aggregate expression or appear in GROUP BY clause",
          expression);
    }
  }
  for (SortItem sortItem : node.getOrderBy()) {
    Expression expression = sortItem.getSortKey();
    if (!process(expression, context)) {
      throw new SemanticException(MUST_BE_AGGREGATE_OR_GROUP_BY,
          expression,
          "ORDER BY expression '%s' must be an aggregate expression or appear in GROUP BY clause",
          expression);
    }
  }
  if (node.getFrame().isPresent()) {
    process(node.getFrame().get(), context);
  }
  return true;
}

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

Expression frameEnd = null;
if (window.getFrame().isPresent()) {
  WindowFrame frame = window.getFrame().get();
  frameType = frame.getType();
    .addAll(window.getPartitionBy())
    .addAll(Iterables.transform(window.getOrderBy(), SortItem::getSortKey));
for (Expression expression : window.getPartitionBy()) {
  partitionBySymbols.add(subPlan.translate(expression));
for (SortItem item : window.getOrderBy()) {
  Symbol symbol = subPlan.translate(item.getSortKey());
  orderings.put(symbol, toSortOrder(item));

相关文章