本文整理了Java中io.prestosql.testing.QueryRunner.tableExists
方法的一些代码示例,展示了QueryRunner.tableExists
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。QueryRunner.tableExists
方法的具体详情如下:
包路径:io.prestosql.testing.QueryRunner
类名称:QueryRunner
方法名:tableExists
暂无
代码示例来源:origin: prestosql/presto
@Test
public void testDropTableIfExists()
{
assertFalse(getQueryRunner().tableExists(getSession(), "test_drop_if_exists"));
assertUpdate("DROP TABLE IF EXISTS test_drop_if_exists");
assertFalse(getQueryRunner().tableExists(getSession(), "test_drop_if_exists"));
}
代码示例来源:origin: prestosql/presto
@Test
public void testRenameTable()
{
assertUpdate("CREATE TABLE test_rename AS SELECT 123 x", 1);
assertUpdate("ALTER TABLE test_rename RENAME TO test_rename_new");
MaterializedResult materializedRows = computeActual("SELECT x FROM test_rename_new");
assertEquals(getOnlyElement(materializedRows.getMaterializedRows()).getField(0), 123);
// provide new table name in uppercase
assertUpdate("ALTER TABLE test_rename_new RENAME TO TEST_RENAME");
materializedRows = computeActual("SELECT x FROM test_rename");
assertEquals(getOnlyElement(materializedRows.getMaterializedRows()).getField(0), 123);
assertUpdate("DROP TABLE test_rename");
assertFalse(getQueryRunner().tableExists(getSession(), "test_rename"));
assertFalse(getQueryRunner().tableExists(getSession(), "test_rename_new"));
}
代码示例来源:origin: prestosql/presto
protected void assertCreateTableAsSelect(Session session, String table, @Language("SQL") String query, @Language("SQL") String expectedQuery, @Language("SQL") String rowCountQuery)
{
assertUpdate(session, "CREATE TABLE " + table + " AS " + query, rowCountQuery);
assertQuery(session, "SELECT * FROM " + table, expectedQuery);
assertUpdate(session, "DROP TABLE " + table);
assertFalse(getQueryRunner().tableExists(session, table));
}
代码示例来源:origin: prestosql/presto
@Test
public void testDropTable()
{
assertUpdate("CREATE TABLE test_drop AS SELECT 123 x", 1);
assertTrue(getQueryRunner().tableExists(getSession(), "test_drop"));
assertUpdate("DROP TABLE test_drop");
assertFalse(getQueryRunner().tableExists(getSession(), "test_drop"));
}
代码示例来源:origin: prestosql/presto
@Test
public void testDropTable()
{
assertUpdate("CREATE TABLE test_drop AS SELECT 123 x", 1);
assertTrue(getQueryRunner().tableExists(getSession(), "test_drop"));
assertUpdate("DROP TABLE test_drop");
assertFalse(getQueryRunner().tableExists(getSession(), "test_drop"));
}
代码示例来源:origin: prestosql/presto
@Test
public void testRenameColumn()
{
assertUpdate("CREATE TABLE test_rename_column AS SELECT 123 x", 1);
assertUpdate("ALTER TABLE test_rename_column RENAME COLUMN x TO y");
MaterializedResult materializedRows = computeActual("SELECT y FROM test_rename_column");
assertEquals(getOnlyElement(materializedRows.getMaterializedRows()).getField(0), 123);
assertUpdate("ALTER TABLE test_rename_column RENAME COLUMN y TO Z");
materializedRows = computeActual("SELECT z FROM test_rename_column");
assertEquals(getOnlyElement(materializedRows.getMaterializedRows()).getField(0), 123);
assertUpdate("DROP TABLE test_rename_column");
assertFalse(getQueryRunner().tableExists(getSession(), "test_rename_column"));
}
代码示例来源:origin: prestosql/presto
@Test
public void testNameEscaping()
{
Session session = testSessionBuilder()
.setCatalog("mysql")
.setSchema("test_database")
.build();
assertFalse(getQueryRunner().tableExists(session, "test_table"));
assertUpdate(session, "CREATE TABLE test_table AS SELECT 123 x", 1);
assertTrue(getQueryRunner().tableExists(session, "test_table"));
assertQuery(session, "SELECT * FROM test_table", "SELECT 123");
assertUpdate(session, "DROP TABLE test_table");
assertFalse(getQueryRunner().tableExists(session, "test_table"));
}
代码示例来源:origin: prestosql/presto
public void testCreateEmptyBucketedPartition(HiveStorageFormat storageFormat)
{
String tableName = "test_insert_empty_partitioned_bucketed_table";
createPartitionedBucketedTable(tableName, storageFormat);
List<String> orderStatusList = ImmutableList.of("F", "O", "P");
for (int i = 0; i < orderStatusList.size(); i++) {
String sql = format("CALL system.create_empty_partition('%s', '%s', ARRAY['orderstatus'], ARRAY['%s'])", TPCH_SCHEMA, tableName, orderStatusList.get(i));
assertUpdate(sql);
assertQuery(
format("SELECT count(*) FROM \"%s$partitions\"", tableName),
"SELECT " + (i + 1));
assertQueryFails(sql, "Partition already exists.*");
}
assertUpdate("DROP TABLE " + tableName);
assertFalse(getQueryRunner().tableExists(getSession(), tableName));
}
代码示例来源:origin: io.prestosql/presto-hive
public void testCreateEmptyBucketedPartition(HiveStorageFormat storageFormat)
{
String tableName = "test_insert_empty_partitioned_bucketed_table";
createPartitionedBucketedTable(tableName, storageFormat);
List<String> orderStatusList = ImmutableList.of("F", "O", "P");
for (int i = 0; i < orderStatusList.size(); i++) {
String sql = format("CALL system.create_empty_partition('%s', '%s', ARRAY['orderstatus'], ARRAY['%s'])", TPCH_SCHEMA, tableName, orderStatusList.get(i));
assertUpdate(sql);
assertQuery(
format("SELECT count(*) FROM \"%s$partitions\"", tableName),
"SELECT " + (i + 1));
assertQueryFails(sql, "Partition already exists.*");
}
assertUpdate("DROP TABLE " + tableName);
assertFalse(getQueryRunner().tableExists(getSession(), tableName));
}
代码示例来源:origin: prestosql/presto
@Test
public void testMaterializedView()
throws Exception
{
execute("CREATE MATERIALIZED VIEW tpch.test_mv as SELECT * FROM tpch.orders");
assertTrue(getQueryRunner().tableExists(getSession(), "test_mv"));
assertQuery("SELECT orderkey FROM test_mv", "SELECT orderkey FROM orders");
execute("DROP MATERIALIZED VIEW tpch.test_mv");
}
代码示例来源:origin: prestosql/presto
@Test
public void testViews()
throws Exception
{
execute("CREATE OR REPLACE VIEW tpch.test_view AS SELECT * FROM tpch.orders");
assertTrue(getQueryRunner().tableExists(getSession(), "test_view"));
assertQuery("SELECT orderkey FROM test_view", "SELECT orderkey FROM orders");
execute("DROP VIEW IF EXISTS tpch.test_view");
}
代码示例来源:origin: prestosql/presto
private void testInsertPartitionedBucketedTable(HiveStorageFormat storageFormat)
{
String tableName = "test_insert_partitioned_bucketed_table";
createPartitionedBucketedTable(tableName, storageFormat);
List<String> orderStatusList = ImmutableList.of("F", "O", "P");
for (int i = 0; i < orderStatusList.size(); i++) {
String orderStatus = orderStatusList.get(i);
assertUpdate(
// make sure that we will get one file per bucket regardless of writer count configured
getParallelWriteSession(),
format(
"INSERT INTO " + tableName + " " +
"SELECT custkey, custkey AS custkey2, comment, orderstatus " +
"FROM tpch.tiny.orders " +
"WHERE orderstatus = '%s'",
orderStatus),
format("SELECT count(*) from orders where orderstatus = '%s'", orderStatus));
}
verifyPartitionedBucketedTable(storageFormat, tableName);
assertUpdate("DROP TABLE " + tableName);
assertFalse(getQueryRunner().tableExists(getSession(), tableName));
}
代码示例来源:origin: io.prestosql/presto-hive
private void testInsertPartitionedBucketedTable(HiveStorageFormat storageFormat)
{
String tableName = "test_insert_partitioned_bucketed_table";
createPartitionedBucketedTable(tableName, storageFormat);
List<String> orderStatusList = ImmutableList.of("F", "O", "P");
for (int i = 0; i < orderStatusList.size(); i++) {
String orderStatus = orderStatusList.get(i);
assertUpdate(
// make sure that we will get one file per bucket regardless of writer count configured
getParallelWriteSession(),
format(
"INSERT INTO " + tableName + " " +
"SELECT custkey, custkey AS custkey2, comment, orderstatus " +
"FROM tpch.tiny.orders " +
"WHERE orderstatus = '%s'",
orderStatus),
format("SELECT count(*) from orders where orderstatus = '%s'", orderStatus));
}
verifyPartitionedBucketedTable(storageFormat, tableName);
assertUpdate("DROP TABLE " + tableName);
assertFalse(getQueryRunner().tableExists(getSession(), tableName));
}
代码示例来源:origin: prestosql/presto
@Test
public void testForeignTable()
throws Exception
{
execute("CREATE SERVER devnull FOREIGN DATA WRAPPER file_fdw");
execute("CREATE FOREIGN TABLE tpch.test_ft (x bigint) SERVER devnull OPTIONS (filename '/dev/null')");
assertTrue(getQueryRunner().tableExists(getSession(), "test_ft"));
computeActual("SELECT * FROM test_ft");
execute("DROP FOREIGN TABLE tpch.test_ft");
execute("DROP SERVER devnull");
}
代码示例来源:origin: io.prestosql/presto-hive
@Test
public void testDeleteFromUnpartitionedTable()
{
assertUpdate("CREATE TABLE test_delete_unpartitioned AS SELECT orderstatus FROM tpch.tiny.orders", "SELECT count(*) from orders");
assertUpdate("DELETE FROM test_delete_unpartitioned");
MaterializedResult result = computeActual("SELECT * from test_delete_unpartitioned");
assertEquals(result.getRowCount(), 0);
assertUpdate("DROP TABLE test_delete_unpartitioned");
assertFalse(getQueryRunner().tableExists(getSession(), "test_delete_unpartitioned"));
}
代码示例来源:origin: prestosql/presto
@Test
public void testDeleteFromUnpartitionedTable()
{
assertUpdate("CREATE TABLE test_delete_unpartitioned AS SELECT orderstatus FROM tpch.tiny.orders", "SELECT count(*) from orders");
assertUpdate("DELETE FROM test_delete_unpartitioned");
MaterializedResult result = computeActual("SELECT * from test_delete_unpartitioned");
assertEquals(result.getRowCount(), 0);
assertUpdate("DROP TABLE test_delete_unpartitioned");
assertFalse(getQueryRunner().tableExists(getSession(), "test_delete_unpartitioned"));
}
代码示例来源:origin: io.prestosql/presto-hive
private void testCreatePartitionedTableAs(Session session, HiveStorageFormat storageFormat)
{
@Language("SQL") String createTable = "" +
"CREATE TABLE test_create_partitioned_table_as " +
"WITH (" +
"format = '" + storageFormat + "', " +
"partitioned_by = ARRAY[ 'SHIP_PRIORITY', 'ORDER_STATUS' ]" +
") " +
"AS " +
"SELECT orderkey AS order_key, shippriority AS ship_priority, orderstatus AS order_status " +
"FROM tpch.tiny.orders";
assertUpdate(session, createTable, "SELECT count(*) from orders");
TableMetadata tableMetadata = getTableMetadata(catalog, TPCH_SCHEMA, "test_create_partitioned_table_as");
assertEquals(tableMetadata.getMetadata().getProperties().get(STORAGE_FORMAT_PROPERTY), storageFormat);
assertEquals(tableMetadata.getMetadata().getProperties().get(PARTITIONED_BY_PROPERTY), ImmutableList.of("ship_priority", "order_status"));
List<?> partitions = getPartitions("test_create_partitioned_table_as");
assertEquals(partitions.size(), 3);
assertQuery(session, "SELECT * from test_create_partitioned_table_as", "SELECT orderkey, shippriority, orderstatus FROM orders");
assertUpdate(session, "DROP TABLE test_create_partitioned_table_as");
assertFalse(getQueryRunner().tableExists(session, "test_create_partitioned_table_as"));
}
代码示例来源:origin: prestosql/presto
private void testCreatePartitionedTableAs(Session session, HiveStorageFormat storageFormat)
{
@Language("SQL") String createTable = "" +
"CREATE TABLE test_create_partitioned_table_as " +
"WITH (" +
"format = '" + storageFormat + "', " +
"partitioned_by = ARRAY[ 'SHIP_PRIORITY', 'ORDER_STATUS' ]" +
") " +
"AS " +
"SELECT orderkey AS order_key, shippriority AS ship_priority, orderstatus AS order_status " +
"FROM tpch.tiny.orders";
assertUpdate(session, createTable, "SELECT count(*) from orders");
TableMetadata tableMetadata = getTableMetadata(catalog, TPCH_SCHEMA, "test_create_partitioned_table_as");
assertEquals(tableMetadata.getMetadata().getProperties().get(STORAGE_FORMAT_PROPERTY), storageFormat);
assertEquals(tableMetadata.getMetadata().getProperties().get(PARTITIONED_BY_PROPERTY), ImmutableList.of("ship_priority", "order_status"));
List<?> partitions = getPartitions("test_create_partitioned_table_as");
assertEquals(partitions.size(), 3);
assertQuery(session, "SELECT * from test_create_partitioned_table_as", "SELECT orderkey, shippriority, orderstatus FROM orders");
assertUpdate(session, "DROP TABLE test_create_partitioned_table_as");
assertFalse(getQueryRunner().tableExists(session, "test_create_partitioned_table_as"));
}
代码示例来源:origin: io.prestosql/presto-hive
private void testCreatePartitionedBucketedTableAs(HiveStorageFormat storageFormat)
{
String tableName = "test_create_partitioned_bucketed_table_as";
@Language("SQL") String createTable = "" +
"CREATE TABLE " + tableName + " " +
"WITH (" +
"format = '" + storageFormat + "', " +
"partitioned_by = ARRAY[ 'orderstatus' ], " +
"bucketed_by = ARRAY[ 'custkey', 'custkey2' ], " +
"bucket_count = 11 " +
") " +
"AS " +
"SELECT custkey, custkey AS custkey2, comment, orderstatus " +
"FROM tpch.tiny.orders";
assertUpdate(
// make sure that we will get one file per bucket regardless of writer count configured
getParallelWriteSession(),
createTable,
"SELECT count(*) from orders");
verifyPartitionedBucketedTable(storageFormat, tableName);
assertUpdate("DROP TABLE " + tableName);
assertFalse(getQueryRunner().tableExists(getSession(), tableName));
}
代码示例来源:origin: prestosql/presto
private void testCreatePartitionedBucketedTableAs(HiveStorageFormat storageFormat)
{
String tableName = "test_create_partitioned_bucketed_table_as";
@Language("SQL") String createTable = "" +
"CREATE TABLE " + tableName + " " +
"WITH (" +
"format = '" + storageFormat + "', " +
"partitioned_by = ARRAY[ 'orderstatus' ], " +
"bucketed_by = ARRAY[ 'custkey', 'custkey2' ], " +
"bucket_count = 11 " +
") " +
"AS " +
"SELECT custkey, custkey AS custkey2, comment, orderstatus " +
"FROM tpch.tiny.orders";
assertUpdate(
// make sure that we will get one file per bucket regardless of writer count configured
getParallelWriteSession(),
createTable,
"SELECT count(*) from orders");
verifyPartitionedBucketedTable(storageFormat, tableName);
assertUpdate("DROP TABLE " + tableName);
assertFalse(getQueryRunner().tableExists(getSession(), tableName));
}
内容来源于网络,如有侵权,请联系作者删除!