io.prestosql.testing.QueryRunner.execute()方法的使用及代码示例

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

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

QueryRunner.execute介绍

暂无

代码示例

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

private void doTestCreateTable(String tableName, String createTable)
{
  String dropTable = "DROP TABLE IF EXISTS " + tableName;
  queryRunner.execute(dropTable);
  queryRunner.execute(createTable);
  String insert = "INSERT INTO " + tableName + " VALUES (1, TIMESTAMP '2001-08-22 03:04:05.321', 2.5)";
  queryRunner.execute(insert);
  MaterializedResult result = queryRunner.execute("SELECT id FROM " + tableName);
  assertEquals(result.getRowCount(), 1);
}

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

protected static void assertQueryFails(QueryRunner queryRunner, Session session, @Language("SQL") String sql, @Language("RegExp") String expectedMessageRegExp)
{
  try {
    queryRunner.execute(session, sql);
    fail(format("Expected query to fail: %s", sql));
  }
  catch (RuntimeException ex) {
    assertExceptionMessage(sql, ex, expectedMessageRegExp);
  }
}

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

@AfterClass(alwaysRun = true)
  public final void destroy()
  {
    System.setProperty("kudu.schema-emulation.prefix", oldPrefix);
    if (queryRunner != null) {
      queryRunner.execute(DROP_TABLE);
      queryRunner.execute(DROP_SCHEMA);
      queryRunner.close();
      queryRunner = null;
    }
  }
}

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

@Test
public void testAdminCanRead()
{
  Session admin = getSession("hive");
  queryRunner.execute(admin, "SELECT * FROM nation");
}

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

@Test(expectedExceptions = RuntimeException.class, expectedExceptionsMessageRegExp = ".*Access Denied: Cannot select from table tpch.nation.*")
public void testNonAdminCannotRead()
{
  Session bob = getSession("bob");
  queryRunner.execute(bob, "SELECT * FROM nation");
}

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

private MaterializedResult execute(String sql)
  {
    return getQueryRunner().execute(SESSION, sql);
  }
}

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

@Test(timeOut = 60_000, expectedExceptions = RuntimeException.class, expectedExceptionsMessageRegExp = ".*Query exceeded distributed total memory limit of 2kB.*")
public void testQueryTotalMemoryLimit()
    throws Exception
{
  Map<String, String> properties = ImmutableMap.<String, String>builder()
      .put("query.max-memory", "1kB")
      .put("query.max-total-memory", "2kB")
      .build();
  try (QueryRunner queryRunner = createQueryRunner(SESSION, properties)) {
    queryRunner.execute(SESSION, "SELECT COUNT(*), repeat(orderstatus, 1000) FROM orders GROUP BY 2");
  }
}

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

@Test
public void testAdminCanRead()
{
  Session admin = getSession("hive");
  queryRunner.execute(admin, "SELECT * FROM nation");
}

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

@Test
public void testAdminCanRead()
{
  Session admin = getSession("user");
  queryRunner.execute(admin, "SELECT * FROM orders");
}

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

@Test(expectedExceptions = RuntimeException.class, expectedExceptionsMessageRegExp = ".*Access Denied: Cannot select from table tpch.orders.*")
public void testNonAdminCannotRead()
{
  Session bob = getSession("bob");
  queryRunner.execute(bob, "SELECT * FROM orders");
}

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

@Benchmark
public MaterializedResult queryInformationSchema(BenchmarkData benchmarkData)
{
  return benchmarkData.queryRunner.execute(benchmarkData.query);
}

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

@Test
public void testAdminCanRead()
{
  Session admin = getSession("admin");
  queryRunner.execute(admin, "SELECT * FROM disks");
}

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

@Test
public void testLegacyGroupBy()
{
  MaterializedResult result = runner.execute("select * from (values nan(), nan(), nan()) group by 1");
  List<MaterializedRow> rows = result.getMaterializedRows();
  assertEquals(rows.size(), 3);
  rows.stream()
      .forEach(row -> assertTrue(Double.isNaN((Double) row.getField(0))));
}

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

private void assertThatQueryReturnsValue(@Language("SQL") String sql, Object expected)
  {
    MaterializedResult rows = queryRunner.execute(sql);
    MaterializedRow materializedRow = Iterables.getOnlyElement(rows);
    int fieldCount = materializedRow.getFieldCount();
    assertTrue(fieldCount == 1, format("Expected only one column, but got '%d'", fieldCount));
    Object value = materializedRow.getField(0);
    assertEquals(value, expected);
    assertTrue(Iterables.getOnlyElement(rows).getFieldCount() == 1);
  }
}

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

@Test
public void testSelectWithUnenforcedConstraint()
{
  createBlackholeAllTypesTable();
  MaterializedResult rows = queryRunner.execute("SELECT * FROM blackhole_all_types where _bigint > 10");
  assertEquals(rows.getRowCount(), 0);
  dropBlackholeAllTypesTable();
}

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

protected void assertAccessAllowed(Session session, @Language("SQL") String sql, TestingPrivilege... deniedPrivileges)
{
  executeExclusively(() -> {
    try {
      queryRunner.getAccessControl().deny(deniedPrivileges);
      queryRunner.execute(session, sql);
    }
    finally {
      queryRunner.getAccessControl().reset();
    }
  });
}

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

@Benchmark
public MaterializedResult benchmarkReorderJoins(BenchmarkInfo benchmarkInfo)
{
  return benchmarkInfo.getQueryRunner().execute(benchmarkInfo.getQuery());
}

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

private static void copyTable(QueryRunner queryRunner, String catalog, Session session, String schema, TpchTable<?> table, String properties)
{
  QualifiedObjectName source = new QualifiedObjectName(catalog, schema, table.getTableName());
  String target = table.getTableName();
  String with = properties.isEmpty() ? "" : format(" WITH (%s)", properties);
  @Language("SQL") String sql = format("CREATE TABLE %s%s AS SELECT * FROM %s", target, with, source);
  log.info("Running import for %s", target);
  long start = System.nanoTime();
  long rows = queryRunner.execute(session, sql).getUpdateCount().getAsLong();
  log.info("Imported %s rows for %s in %s", rows, target, nanosSince(start));
}

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

@Test(timeOut = 240_000, expectedExceptions = RuntimeException.class, expectedExceptionsMessageRegExp = ".*Query exceeded per-query local spill limit of 10B")
public void testQueryMaxSpillPerNodeLimit()
{
  try (QueryRunner queryRunner = createLocalQueryRunner(new NodeSpillConfig().setQueryMaxSpillPerNode(DataSize.succinctBytes(10)))) {
    queryRunner.execute(queryRunner.getDefaultSession(), "SELECT COUNT(DISTINCT clerk) as count, orderdate FROM orders GROUP BY orderdate ORDER BY count, orderdate");
  }
}

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

private void assertOneNotNullResult(@Language("SQL") String query)
{
  MaterializedResult results = getQueryRunner().execute(getSession(), query).toTestTypes();
  assertEquals(results.getRowCount(), 1);
  assertEquals(results.getMaterializedRows().get(0).getFieldCount(), 1);
  assertNotNull(results.getMaterializedRows().get(0).getField(0));
}

相关文章