use of org.apache.flink.table.api.TableEnvironment in project flink by apache.
the class JavaCatalogTableTest method testResolvingSchemaOfCustomCatalogTableTableApi.
@Test
public void testResolvingSchemaOfCustomCatalogTableTableApi() throws Exception {
TableTestUtil testUtil = getTestUtil();
TableEnvironment tableEnvironment = testUtil.getTableEnv();
GenericInMemoryCatalog genericInMemoryCatalog = new GenericInMemoryCatalog("in-memory");
genericInMemoryCatalog.createTable(new ObjectPath("default", "testTable"), new CustomCatalogTable(isStreamingMode), false);
tableEnvironment.registerCatalog("testCatalog", genericInMemoryCatalog);
Table table = tableEnvironment.from("testCatalog.`default`.testTable").window(Tumble.over(lit(10).minute()).on($("rowtime")).as("w")).groupBy($("w")).select(lit(1).count());
testUtil.verifyExecPlan(table);
}
use of org.apache.flink.table.api.TableEnvironment in project flink by apache.
the class JavaCatalogTableTest method testResolvingProctimeOfCustomTableTableApi.
@Test
public void testResolvingProctimeOfCustomTableTableApi() throws Exception {
if (!isStreamingMode) {
// proctime not supported in batch
return;
}
TableTestUtil testUtil = getTestUtil();
TableEnvironment tableEnvironment = testUtil.getTableEnv();
GenericInMemoryCatalog genericInMemoryCatalog = new GenericInMemoryCatalog("in-memory");
genericInMemoryCatalog.createTable(new ObjectPath("default", "testTable"), new CustomCatalogTable(isStreamingMode), false);
tableEnvironment.registerCatalog("testCatalog", genericInMemoryCatalog);
Table table = tableEnvironment.from("testCatalog.`default`.testTable").window(Tumble.over(lit(10).minute()).on($("proctime")).as("w")).groupBy($("w")).select(lit(1).count());
testUtil.verifyExecPlan(table);
}
use of org.apache.flink.table.api.TableEnvironment in project flink by apache.
the class JavaCatalogTableTest method testResolvingProctimeOfCustomTableSql.
@Test
public void testResolvingProctimeOfCustomTableSql() throws Exception {
if (!isStreamingMode) {
// proctime not supported in batch
return;
}
TableTestUtil testUtil = getTestUtil();
TableEnvironment tableEnvironment = testUtil.getTableEnv();
GenericInMemoryCatalog genericInMemoryCatalog = new GenericInMemoryCatalog("in-memory");
genericInMemoryCatalog.createTable(new ObjectPath("default", "testTable"), new CustomCatalogTable(isStreamingMode), false);
tableEnvironment.registerCatalog("testCatalog", genericInMemoryCatalog);
testUtil.verifyExecPlan("SELECT COUNT(*) FROM testCatalog.`default`.testTable " + "GROUP BY TUMBLE(proctime, INTERVAL '10' MINUTE)");
}
use of org.apache.flink.table.api.TableEnvironment in project flink by apache.
the class BuiltInFunctionTestBase method testFunction.
@Test
public void testFunction() {
final TableEnvironment env = TableEnvironment.create(EnvironmentSettings.newInstance().build());
env.getConfig().addConfiguration(configuration());
testSpec.functions.forEach(f -> env.createTemporarySystemFunction(f.getSimpleName(), f));
final DataTypeFactory dataTypeFactory = ((TableEnvironmentInternal) env).getCatalogManager().getDataTypeFactory();
final Table inputTable;
if (testSpec.fieldDataTypes == null) {
inputTable = env.fromValues(Row.of(testSpec.fieldData));
} else {
final DataTypes.UnresolvedField[] fields = IntStream.range(0, testSpec.fieldDataTypes.length).mapToObj(i -> DataTypes.FIELD("f" + i, testSpec.fieldDataTypes[i])).toArray(DataTypes.UnresolvedField[]::new);
inputTable = env.fromValues(DataTypes.ROW(fields), Row.of(testSpec.fieldData));
}
for (TestItem testItem : testSpec.testItems) {
try {
if (testItem instanceof ResultTestItem<?>) {
testResult(dataTypeFactory, env, inputTable, (ResultTestItem<?>) testItem);
} else if (testItem instanceof ErrorTestItem<?>) {
testError(env, inputTable, (ErrorTestItem<?>) testItem);
}
} catch (Throwable t) {
throw new AssertionError("Failing test item: " + testItem, t);
}
}
}
use of org.apache.flink.table.api.TableEnvironment in project flink by apache.
the class CatalogITCase method testCreateCatalog.
@Test
public void testCreateCatalog() {
String name = "c1";
TableEnvironment tableEnv = getTableEnvironment();
String ddl = String.format("create catalog %s with('type'='%s')", name, GenericInMemoryCatalogFactoryOptions.IDENTIFIER);
tableEnv.executeSql(ddl);
assertTrue(tableEnv.getCatalog(name).isPresent());
assertTrue(tableEnv.getCatalog(name).get() instanceof GenericInMemoryCatalog);
}
Aggregations