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

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

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

QuerySpecification.<init>介绍

暂无

代码示例

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

public static Query simpleQuery(Select select, Relation from, Optional<Expression> where, Optional<GroupBy> groupBy, Optional<Expression> having, Optional<OrderBy> orderBy, Optional<String> limit)
{
  return query(new QuerySpecification(
      select,
      Optional.of(from),
      where,
      groupBy,
      having,
      orderBy,
      limit));
}

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

public static Query simpleQuery(Select select)
{
  return query(new QuerySpecification(
      select,
      Optional.empty(),
      Optional.empty(),
      Optional.empty(),
      Optional.empty(),
      Optional.empty(),
      Optional.empty()));
}

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

public static Query simpleQuery(Select select, Relation from, Optional<Expression> where, Optional<GroupBy> groupBy, Optional<Expression> having, Optional<OrderBy> orderBy, Optional<String> limit)
{
  return query(new QuerySpecification(
      select,
      Optional.of(from),
      where,
      groupBy,
      having,
      orderBy,
      limit));
}

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

public static Query simpleQuery(Select select)
{
  return query(new QuerySpecification(
      select,
      Optional.empty(),
      Optional.empty(),
      Optional.empty(),
      Optional.empty(),
      Optional.empty(),
      Optional.empty()));
}

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

private String checksumSql(List<Column> columns, QualifiedName table)
    throws QueryRewriteException
{
  if (columns.isEmpty()) {
    throw new QueryRewriteException("Table " + table + " has no columns");
  }
  ImmutableList.Builder<SelectItem> selectItems = ImmutableList.builder();
  for (Column column : columns) {
    Expression expression = new Identifier(column.getName());
    if (column.isApproximateType()) {
      expression = new FunctionCall(QualifiedName.of("round"), ImmutableList.of(expression, new LongLiteral(Integer.toString(doublePrecision))));
    }
    selectItems.add(new SingleColumn(new FunctionCall(QualifiedName.of("checksum"), ImmutableList.of(expression))));
  }
  Select select = new Select(false, selectItems.build());
  return formatSql(new QuerySpecification(select, Optional.of(new Table(table)), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()), Optional.empty());
}

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

private static QuerySpecification createSelect123()
{
  return new QuerySpecification(
      selectList(new LongLiteral("123")),
      Optional.empty(),
      Optional.empty(),
      Optional.empty(),
      Optional.empty(),
      Optional.empty(),
      Optional.empty());
}

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

if (innerQuery instanceof QuerySpecification) {
  QuerySpecification querySpecification = (QuerySpecification) innerQuery;
  innerQuery = new QuerySpecification(
      querySpecification.getSelect(),
      querySpecification.getFrom(),

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

@Override
public Node visitQuerySpecification(SqlBaseParser.QuerySpecificationContext context)
{
  Optional<Relation> from = Optional.empty();
  List<SelectItem> selectItems = visit(context.selectItem(), SelectItem.class);
  List<Relation> relations = visit(context.relation(), Relation.class);
  if (!relations.isEmpty()) {
    // synthesize implicit join nodes
    Iterator<Relation> iterator = relations.iterator();
    Relation relation = iterator.next();
    while (iterator.hasNext()) {
      relation = new Join(getLocation(context), Join.Type.IMPLICIT, relation, iterator.next(), Optional.empty());
    }
    from = Optional.of(relation);
  }
  return new QuerySpecification(
      getLocation(context),
      new Select(getLocation(context.SELECT()), isDistinct(context.setQuantifier()), selectItems),
      from,
      visitIfPresent(context.where, Expression.class),
      visitIfPresent(context.groupBy(), GroupBy.class),
      visitIfPresent(context.having, Expression.class),
      Optional.empty(),
      Optional.empty());
}

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

@Override
public Node visitQuerySpecification(SqlBaseParser.QuerySpecificationContext context)
{
  Optional<Relation> from = Optional.empty();
  List<SelectItem> selectItems = visit(context.selectItem(), SelectItem.class);
  List<Relation> relations = visit(context.relation(), Relation.class);
  if (!relations.isEmpty()) {
    // synthesize implicit join nodes
    Iterator<Relation> iterator = relations.iterator();
    Relation relation = iterator.next();
    while (iterator.hasNext()) {
      relation = new Join(getLocation(context), Join.Type.IMPLICIT, relation, iterator.next(), Optional.empty());
    }
    from = Optional.of(relation);
  }
  return new QuerySpecification(
      getLocation(context),
      new Select(getLocation(context.SELECT()), isDistinct(context.setQuantifier()), selectItems),
      from,
      visitIfPresent(context.where, Expression.class),
      visitIfPresent(context.groupBy(), GroupBy.class),
      visitIfPresent(context.having, Expression.class),
      Optional.empty(),
      Optional.empty());
}

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

@Test
public void testAtTimeZone()
{
  assertStatement("SELECT timestamp '2012-10-31 01:00 UTC' AT TIME ZONE 'America/Los_Angeles'",
      new Query(
          Optional.empty(),
          new QuerySpecification(
              selectList(
                  new AtTimeZone(new TimestampLiteral("2012-10-31 01:00 UTC"), new StringLiteral("America/Los_Angeles"))),
              Optional.empty(),
              Optional.empty(),
              Optional.empty(),
              Optional.empty(),
              Optional.empty(),
              Optional.empty()),
          Optional.empty(),
          Optional.empty()));
}

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

getLocation(context),
Optional.empty(),
new QuerySpecification(
    getLocation(context),
    query.getSelect(),

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

getLocation(context),
Optional.empty(),
new QuerySpecification(
    getLocation(context),
    query.getSelect(),

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

new Query(
    Optional.empty(),
    new QuerySpecification(
        selectList(new FunctionCall(QualifiedName.of("substr"), Lists.newArrayList(new StringLiteral(givenString), new LongLiteral("2")))),
        Optional.empty(),
new Query(
    Optional.empty(),
    new QuerySpecification(
        selectList(new FunctionCall(QualifiedName.of("substr"), Lists.newArrayList(new StringLiteral(givenString), new LongLiteral("2"), new LongLiteral("3")))),
        Optional.empty(),

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

new Query(
    Optional.empty(),
    new QuerySpecification(
        selectList(new FunctionCall(QualifiedName.of("substring"), Lists.newArrayList(new StringLiteral(givenString), new LongLiteral("2")))),
        Optional.empty(),
new Query(
    Optional.empty(),
    new QuerySpecification(
        selectList(new FunctionCall(QualifiedName.of("substring"), Lists.newArrayList(new StringLiteral(givenString), new LongLiteral("2"), new LongLiteral("3")))),
        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

SingleColumn columnC = new SingleColumn(new FunctionCall(QualifiedName.of("checksum"), ImmutableList.of(new Identifier("C"))));
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

new Query(
    Optional.empty(),
    new QuerySpecification(
        selectList(new AllColumns()),
        Optional.of(new Table(QualifiedName.of("table1"))),
new Query(
    Optional.empty(),
    new QuerySpecification(
        selectList(new AllColumns()),
        Optional.of(new Table(QualifiedName.of("table1"))),
new Query(
    Optional.empty(),
    new QuerySpecification(
        selectList(new AllColumns()),
        Optional.of(new Table(QualifiedName.of("table1"))),
new Query(
    Optional.empty(),
    new QuerySpecification(
        selectList(new AllColumns()),
        Optional.of(new Table(QualifiedName.of("table1"))),
new Query(
    Optional.empty(),
    new QuerySpecification(
        selectList(
            DereferenceExpression.from(QualifiedName.of("a")),

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

new Query(
    Optional.empty(),
    new QuerySpecification(
        selectList(
            new SubscriptExpression(new DereferenceExpression(new Identifier("col1"), identifier("f1")), new LongLiteral("0")),
new Query(
    Optional.empty(),
    new QuerySpecification(
        selectList(
            new DereferenceExpression(new Cast(new Row(Lists.newArrayList(new LongLiteral("11"), new LongLiteral("12"))), "ROW(COL0 INTEGER,COL1 INTEGER)"), identifier("col0"))),

相关文章