io.prestosql.sql.tree.Query.<init>()方法的使用及代码示例

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

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

Query.<init>介绍

暂无

代码示例

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

public static Query query(QueryBody body)
  {
    return new Query(
        Optional.empty(),
        body,
        Optional.empty(),
        Optional.empty());
  }
}

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

public static Query query(QueryBody body)
  {
    return new Query(
        Optional.empty(),
        body,
        Optional.empty(),
        Optional.empty());
  }
}

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

@Override
public Node visitShowStatsForQuery(SqlBaseParser.ShowStatsForQueryContext context)
{
  QuerySpecification specification = (QuerySpecification) visitQuerySpecification(context.querySpecification());
  Query query = new Query(Optional.empty(), specification, Optional.empty(), Optional.empty());
  return new ShowStats(Optional.of(getLocation(context)), new TableSubquery(query));
}

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

@Override
public Node visitShowStatsForQuery(SqlBaseParser.ShowStatsForQueryContext context)
{
  QuerySpecification specification = (QuerySpecification) visitQuerySpecification(context.querySpecification());
  Query query = new Query(Optional.empty(), specification, Optional.empty(), Optional.empty());
  return new ShowStats(Optional.of(getLocation(context)), new TableSubquery(query));
}

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

@Override
protected Node visitShowStats(ShowStats node, Void context)
{
  checkState(queryExplainer.isPresent(), "Query explainer must be provided for SHOW STATS SELECT");
  if (node.getRelation() instanceof TableSubquery) {
    Query query = ((TableSubquery) node.getRelation()).getQuery();
    QuerySpecification specification = (QuerySpecification) query.getQueryBody();
    Plan plan = queryExplainer.get().getLogicalPlan(session, new Query(Optional.empty(), specification, Optional.empty(), Optional.empty()), parameters, warningCollector);
    validateShowStatsSubquery(node, query, specification, plan);
    Table table = (Table) specification.getFrom().get();
    Constraint<ColumnHandle> constraint = getConstraint(plan);
    return rewriteShowStats(node, table, constraint);
  }
  else if (node.getRelation() instanceof Table) {
    Table table = (Table) node.getRelation();
    return rewriteShowStats(node, table, Constraint.alwaysTrue());
  }
  else {
    throw new IllegalArgumentException("Expected either TableSubquery or Table as relation");
  }
}

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

@Override
protected Node visitShowStats(ShowStats node, Void context)
{
  checkState(queryExplainer.isPresent(), "Query explainer must be provided for SHOW STATS SELECT");
  if (node.getRelation() instanceof TableSubquery) {
    Query query = ((TableSubquery) node.getRelation()).getQuery();
    QuerySpecification specification = (QuerySpecification) query.getQueryBody();
    Plan plan = queryExplainer.get().getLogicalPlan(session, new Query(Optional.empty(), specification, Optional.empty(), Optional.empty()), parameters, warningCollector);
    validateShowStatsSubquery(node, query, specification, plan);
    Table table = (Table) specification.getFrom().get();
    Constraint<ColumnHandle> constraint = getConstraint(plan);
    return rewriteShowStats(node, table, constraint);
  }
  else if (node.getRelation() instanceof Table) {
    Table table = (Table) node.getRelation();
    return rewriteShowStats(node, table, Constraint.alwaysTrue());
  }
  else {
    throw new IllegalArgumentException("Expected either TableSubquery or Table as relation");
  }
}

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

@Test
public void testUnion()
{
  assertStatement("SELECT 123 UNION DISTINCT SELECT 123 UNION ALL SELECT 123",
      new Query(
          Optional.empty(),
          new Union(ImmutableList.of(
              new Union(ImmutableList.of(createSelect123(), createSelect123()), true),
              createSelect123()
          ), false),
          Optional.empty(),
          Optional.empty()));
}

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

@Test
public void testIntersect()
{
  assertStatement("SELECT 123 INTERSECT DISTINCT SELECT 123 INTERSECT ALL SELECT 123",
      new Query(
          Optional.empty(),
          new Intersect(ImmutableList.of(
              new Intersect(ImmutableList.of(createSelect123(), createSelect123()), true),
              createSelect123()
          ), false),
          Optional.empty(),
          Optional.empty()));
}

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

@Override
public Node visitQuery(SqlBaseParser.QueryContext context)
{
  Query body = (Query) visit(context.queryNoWith());
  return new Query(
      getLocation(context),
      visitIfPresent(context.with(), With.class),
      body.getQueryBody(),
      body.getOrderBy(),
      body.getLimit());
}

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

@Override
public Node visitQuery(SqlBaseParser.QueryContext context)
{
  Query body = (Query) visit(context.queryNoWith());
  return new Query(
      getLocation(context),
      visitIfPresent(context.with(), With.class),
      body.getQueryBody(),
      body.getOrderBy(),
      body.getLimit());
}

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

return new Query(
    getLocation(context),
    Optional.empty(),

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

return new Query(
    getLocation(context),
    Optional.empty(),

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

@Test
public void testCreateTableAsSelect()
    throws Exception
{
  handle.execute("CREATE TABLE \"my_test_table\" (column1 BIGINT, column2 DOUBLE)");
  SqlParser parser = new SqlParser();
  Query query = new Query(CATALOG, SCHEMA, ImmutableList.of(), "CREATE TABLE my_test_table AS SELECT 1 column1, CAST('2.0' AS DOUBLE) column2 LIMIT 1", ImmutableList.of(), null, null, ImmutableMap.of());
  QueryRewriter rewriter = new QueryRewriter(parser, URL, QualifiedName.of("tmp_"), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), 1, new Duration(10, SECONDS));
  Query rewrittenQuery = rewriter.shadowQuery(query);
  assertEquals(rewrittenQuery.getPreQueries().size(), 1);
  assertEquals(rewrittenQuery.getPostQueries().size(), 1);
  CreateTableAsSelect createTableAs = (CreateTableAsSelect) parser.createStatement(rewrittenQuery.getPreQueries().get(0));
  assertEquals(createTableAs.getName().getParts().size(), 1);
  assertTrue(createTableAs.getName().getSuffix().startsWith("tmp_"));
  assertFalse(createTableAs.getName().getSuffix().contains("my_test_table"));
  assertEquals(statementToQueryType(parser, rewrittenQuery.getQuery()), READ);
  Table table = new Table(createTableAs.getName());
  SingleColumn column1 = new SingleColumn(new FunctionCall(QualifiedName.of("checksum"), ImmutableList.of(new Identifier("COLUMN1"))));
  SingleColumn column2 = new SingleColumn(new FunctionCall(QualifiedName.of("checksum"), ImmutableList.of(new FunctionCall(QualifiedName.of("round"), ImmutableList.of(new Identifier("COLUMN2"), new LongLiteral("1"))))));
  Select select = new Select(false, ImmutableList.of(column1, column2));
  QuerySpecification querySpecification = new QuerySpecification(select, Optional.of(table), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty());
  assertEquals(parser.createStatement(rewrittenQuery.getQuery()), new io.prestosql.sql.tree.Query(Optional.empty(), querySpecification, Optional.empty(), Optional.empty()));
  assertEquals(parser.createStatement(rewrittenQuery.getPostQueries().get(0)), new DropTable(createTableAs.getName(), true));
}

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

@Test
public void testSelectWithOrderBy()
{
  assertStatement("SELECT * FROM table1 ORDER BY a",
      new Query(
          Optional.empty(),
          new QuerySpecification(
              selectList(new AllColumns()),
              Optional.of(new Table(QualifiedName.of("table1"))),
              Optional.empty(),
              Optional.empty(),
              Optional.empty(),
              Optional.of(new OrderBy(ImmutableList.of(new SortItem(
                  new Identifier("a"),
                  ASCENDING,
                  UNDEFINED)))),
              Optional.empty()),
          Optional.empty(),
          Optional.empty()));
}

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

new Query(
    Optional.empty(),
    new QuerySpecification(
new Query(
    Optional.empty(),
    new QuerySpecification(

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

new Query(
    Optional.empty(),
    new QuerySpecification(

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

Query query = new Query(Optional.of(new With(false, ImmutableList.of(
    new WithQuery(identifier("t"),
        query(new Values(ImmutableList.of(new LongLiteral("1")))),

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

Select select = new Select(false, ImmutableList.of(columnA, columnB, columnC));
QuerySpecification querySpecification = new QuerySpecification(select, Optional.of(table), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty());
assertEquals(parser.createStatement(rewrittenQuery.getQuery()), new io.prestosql.sql.tree.Query(Optional.empty(), querySpecification, Optional.empty(), Optional.empty()));

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

@Test
public void testWith()
{
  assertStatement("WITH a (t, u) AS (SELECT * FROM x), b AS (SELECT * FROM y) TABLE z",
      new Query(Optional.of(new With(false, ImmutableList.of(
          new WithQuery(identifier("a"), simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("x"))), Optional.of(ImmutableList.of(identifier("t"), identifier("u")))),
          new WithQuery(identifier("b"), simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("y"))), Optional.empty())))),
          new Table(QualifiedName.of("z")),
          Optional.empty(),
          Optional.empty()));
  assertStatement("WITH RECURSIVE a AS (SELECT * FROM x) TABLE y",
      new Query(Optional.of(new With(true, ImmutableList.of(
          new WithQuery(identifier("a"), simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("x"))), Optional.empty())))),
          new Table(QualifiedName.of("y")),
          Optional.empty(),
          Optional.empty()));
}

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

@Test
public void testLateral()
  Lateral lateralRelation = new Lateral(new Query(
      Optional.empty(),
      new Values(ImmutableList.of(new LongLiteral("1"))),

相关文章