Java Code Examples for org.apache.flink.table.catalog.GenericInMemoryCatalog#createTable()
The following examples show how to use
org.apache.flink.table.catalog.GenericInMemoryCatalog#createTable() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JavaCatalogTableTest.java From flink with Apache License 2.0 | 6 votes |
@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.verifyPlan(table); }
Example 2
Source File: JavaCatalogTableTest.java From flink with Apache License 2.0 | 6 votes |
@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.verifyPlan("SELECT COUNT(*) FROM testCatalog.`default`.testTable " + "GROUP BY TUMBLE(proctime, INTERVAL '10' MINUTE)"); }
Example 3
Source File: JavaCatalogTableTest.java From flink with Apache License 2.0 | 6 votes |
@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.verifyPlan(table); }
Example 4
Source File: JavaCatalogTableTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testResolvingSchemaOfCustomCatalogTableSql() 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); tableEnvironment.executeSql("CREATE VIEW testTable2 AS SELECT * FROM testCatalog.`default`.testTable"); testUtil.verifyPlan( "SELECT COUNT(*) FROM testTable2 GROUP BY TUMBLE(rowtime, INTERVAL '10' MINUTE)"); }
Example 5
Source File: SimpleCatalogFactory.java From flink with Apache License 2.0 | 4 votes |
@Override public Catalog createCatalog(String name, Map<String, String> properties) { String database = properties.getOrDefault( CatalogDescriptorValidator.CATALOG_DEFAULT_DATABASE, "default_database"); GenericInMemoryCatalog genericInMemoryCatalog = new GenericInMemoryCatalog(name, database); String tableName = properties.getOrDefault(TEST_TABLE_NAME, TEST_TABLE_NAME); StreamTableSource<Row> tableSource = new StreamTableSource<Row>() { @Override public DataStream<Row> getDataStream(StreamExecutionEnvironment execEnv) { return execEnv.fromCollection(TABLE_CONTENTS) .returns(new RowTypeInfo( new TypeInformation[]{Types.INT(), Types.STRING()}, new String[]{"id", "string"})); } @Override public TableSchema getTableSchema() { return TableSchema.builder() .field("id", DataTypes.INT()) .field("string", DataTypes.STRING()) .build(); } @Override public DataType getProducedDataType() { return DataTypes.ROW( DataTypes.FIELD("id", DataTypes.INT()), DataTypes.FIELD("string", DataTypes.STRING()) ); } }; try { genericInMemoryCatalog.createTable( new ObjectPath(database, tableName), ConnectorCatalogTable.source(tableSource, false), false ); } catch (Exception e) { throw new WrappingRuntimeException(e); } return genericInMemoryCatalog; }
Example 6
Source File: SimpleCatalogFactory.java From flink with Apache License 2.0 | 4 votes |
@Override public Catalog createCatalog(String name, Map<String, String> properties) { String database = properties.getOrDefault( CatalogDescriptorValidator.CATALOG_DEFAULT_DATABASE, "default_database"); GenericInMemoryCatalog genericInMemoryCatalog = new GenericInMemoryCatalog(name, database); String tableName = properties.getOrDefault(TEST_TABLE_NAME, TEST_TABLE_NAME); StreamTableSource<Row> tableSource = new StreamTableSource<Row>() { @Override public DataStream<Row> getDataStream(StreamExecutionEnvironment execEnv) { return execEnv.fromCollection(TABLE_CONTENTS) .returns(new RowTypeInfo( new TypeInformation[]{Types.INT(), Types.STRING()}, new String[]{"id", "string"})); } @Override public TableSchema getTableSchema() { return TableSchema.builder() .field("id", DataTypes.INT()) .field("string", DataTypes.STRING()) .build(); } @Override public DataType getProducedDataType() { return DataTypes.ROW( DataTypes.FIELD("id", DataTypes.INT()), DataTypes.FIELD("string", DataTypes.STRING()) ); } }; try { genericInMemoryCatalog.createTable( new ObjectPath(database, tableName), ConnectorCatalogTable.source(tableSource, false), false ); } catch (Exception e) { throw new WrappingRuntimeException(e); } return genericInMemoryCatalog; }