use of org.apache.flink.table.api.TableEnvironment in project flink by apache.
the class HiveTableSinkITCase method testHiveTableSinkWithParallelismInStreaming.
@Test
public void testHiveTableSinkWithParallelismInStreaming() {
final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
final TableEnvironment tEnv = HiveTestUtils.createTableEnvInStreamingMode(env, SqlDialect.HIVE);
testHiveTableSinkWithParallelismBase(tEnv, "/explain/testHiveTableSinkWithParallelismInStreaming.out");
}
use of org.apache.flink.table.api.TableEnvironment in project flink by apache.
the class HiveTableSinkITCase method testHiveTableSinkWithParallelismInBatch.
@Test
public void testHiveTableSinkWithParallelismInBatch() {
final TableEnvironment tEnv = HiveTestUtils.createTableEnvInBatchMode(SqlDialect.HIVE);
testHiveTableSinkWithParallelismBase(tEnv, "/explain/testHiveTableSinkWithParallelismInBatch.out");
}
use of org.apache.flink.table.api.TableEnvironment in project flink by apache.
the class HiveTableSinkITCase method testBatchAppend.
@Test
public void testBatchAppend() throws Exception {
TableEnvironment tEnv = HiveTestUtils.createTableEnvInBatchMode(SqlDialect.HIVE);
tEnv.registerCatalog(hiveCatalog.getName(), hiveCatalog);
tEnv.useCatalog(hiveCatalog.getName());
tEnv.executeSql("create database db1");
tEnv.useDatabase("db1");
try {
tEnv.executeSql("create table append_table (i int, j int)");
tEnv.executeSql("insert into append_table select 1, 1").await();
tEnv.executeSql("insert into append_table select 2, 2").await();
List<Row> rows = CollectionUtil.iteratorToList(tEnv.executeSql("select * from append_table").collect());
rows.sort(Comparator.comparingInt(o -> (int) o.getField(0)));
Assert.assertEquals(Arrays.asList(Row.of(1, 1), Row.of(2, 2)), rows);
} finally {
tEnv.executeSql("drop database db1 cascade");
}
}
use of org.apache.flink.table.api.TableEnvironment in project flink by apache.
the class TableEnvHiveConnectorITCase method testGetNonExistingFunction.
@Test
public void testGetNonExistingFunction() throws Exception {
TableEnvironment tableEnv = getTableEnvWithHiveCatalog();
tableEnv.executeSql("create database db1");
tableEnv.executeSql("create table db1.src (d double, s string)");
tableEnv.executeSql("create table db1.dest (x bigint)");
// just make sure the query runs through, no need to verify result
tableEnv.executeSql("insert into db1.dest select count(d) from db1.src").await();
tableEnv.executeSql("drop database db1 cascade");
}
use of org.apache.flink.table.api.TableEnvironment in project flink by apache.
the class TableEnvHiveConnectorITCase method testDateTimestampPartitionColumns.
@Test
public void testDateTimestampPartitionColumns() throws Exception {
TableEnvironment tableEnv = getTableEnvWithHiveCatalog();
tableEnv.executeSql("create database db1");
try {
tableEnv.executeSql("create table db1.part(x int) partitioned by (dt date,ts timestamp)");
HiveTestUtils.createTextTableInserter(hiveCatalog, "db1", "part").addRow(new Object[] { 1 }).addRow(new Object[] { 2 }).commit("dt='2019-12-23',ts='2019-12-23 00:00:00'");
HiveTestUtils.createTextTableInserter(hiveCatalog, "db1", "part").addRow(new Object[] { 3 }).commit("dt='2019-12-25',ts='2019-12-25 16:23:43.012'");
List<Row> results = CollectionUtil.iteratorToList(tableEnv.sqlQuery("select * from db1.part order by x").execute().collect());
assertEquals("[+I[1, 2019-12-23, 2019-12-23T00:00], +I[2, 2019-12-23, 2019-12-23T00:00], +I[3, 2019-12-25, 2019-12-25T16:23:43.012]]", results.toString());
results = CollectionUtil.iteratorToList(tableEnv.sqlQuery("select x from db1.part where dt=cast('2019-12-25' as date)").execute().collect());
assertEquals("[+I[3]]", results.toString());
tableEnv.executeSql("insert into db1.part select 4,cast('2019-12-31' as date),cast('2019-12-31 12:00:00.0' as timestamp)").await();
results = CollectionUtil.iteratorToList(tableEnv.sqlQuery("select max(dt) from db1.part").execute().collect());
assertEquals("[+I[2019-12-31]]", results.toString());
} finally {
tableEnv.executeSql("drop database db1 cascade");
}
}
Aggregations