Ejemplo n.º 1
0
    def test_create_temporary_table_from_descriptor(self):
        from pyflink.table.schema import Schema

        t_env = self.t_env
        catalog = t_env.get_current_catalog()
        database = t_env.get_current_database()
        schema = Schema.new_builder().column("f0", DataTypes.INT()).build()
        t_env.create_temporary_table(
            "T",
            TableDescriptor.for_connector("fake")
             .schema(schema)
             .option("a", "Test")
             .build())

        self.assertFalse(t_env.get_catalog(catalog).table_exists(ObjectPath(database, "T")))
        gateway = get_gateway()

        catalog_table = CatalogBaseTable(
            t_env._j_tenv.getCatalogManager()
                 .getTable(gateway.jvm.ObjectIdentifier.of(catalog, database, "T"))
                 .get()
                 .getTable())
        self.assertEqual(schema, catalog_table.get_unresolved_schema())
        self.assertEqual("fake", catalog_table.get_options().get("connector"))
        self.assertEqual("Test", catalog_table.get_options().get("a"))
Ejemplo n.º 2
0
 def create_another_view():
     gateway = get_gateway()
     table_schema = CatalogTestBase.create_another_table_schema()
     j_view = gateway.jvm.GenericCatalogView(
         "select * from t2", "select * from test-catalog.db2.t2",
         table_schema._j_table_schema, {}, "This is another view")
     return CatalogBaseTable(j_view)
Ejemplo n.º 3
0
 def create_view():
     gateway = get_gateway()
     table_schema = CatalogTestBase.create_table_schema()
     j_view = gateway.jvm.CatalogViewImpl(
         "select * from t1", "select * from test-catalog.db1.t1",
         table_schema._j_table_schema, {}, "This is a view")
     return CatalogBaseTable(j_view)
Ejemplo n.º 4
0
 def create_another_partitioned_table():
     gateway = get_gateway()
     table_schema = CatalogTestBase.create_another_table_schema()
     j_table = gateway.jvm.CatalogTableImpl(
         table_schema._j_table_schema, CatalogTestBase.create_partition_keys(),
         CatalogTestBase.get_batch_table_properties(), CatalogTestBase.test_comment)
     return CatalogBaseTable(j_table)
Ejemplo n.º 5
0
 def create_stream_table():
     gateway = get_gateway()
     table_schema = CatalogTestBase.create_table_schema()
     j_table = gateway.jvm.CatalogTableImpl(
         table_schema._j_table_schema, CatalogTestBase.get_streaming_table_properties(),
         CatalogTestBase.test_comment)
     return CatalogBaseTable(j_table)
Ejemplo n.º 6
0
 def create_another_table():
     gateway = get_gateway()
     table_schema = CatalogTestBase.create_another_table_schema()
     j_table = gateway.jvm.GenericCatalogTable(
         table_schema._j_table_schema, CatalogTestBase.get_batch_table_properties(),
         CatalogTestBase.test_comment)
     return CatalogBaseTable(j_table)
Ejemplo n.º 7
0
    def test_table_from_descriptor(self):
        from pyflink.table.schema import Schema

        schema = Schema.new_builder().column("f0", DataTypes.INT()).build()
        descriptor = TableDescriptor.for_connector("fake").schema(
            schema).build()

        table = self.t_env.from_descriptor(descriptor)
        self.assertEqual(
            schema,
            Schema(Schema.new_builder()._j_builder.fromResolvedSchema(
                table._j_table.getResolvedSchema()).build()))
        table = CatalogBaseTable(
            self.t_env._j_tenv.getCatalogManager().getTable(
                table._j_table.getQueryOperation().getTableIdentifier()).get(
                ).getTable())
        self.assertEqual("fake", table.get_options().get("connector"))
Ejemplo n.º 8
0
 def create_another_view():
     table_schema = CatalogTestBase.create_another_table_schema()
     return CatalogBaseTable.create_view(
         "select * from t2",
         "select * from test-catalog.db2.t2",
         table_schema,
         {},
         "This is another view")
Ejemplo n.º 9
0
 def create_view():
     table_schema = CatalogTestBase.create_table_schema()
     return CatalogBaseTable.create_view(
         "select * from t1",
         "select * from test-catalog.db1.t1",
         table_schema,
         {},
         "This is a view")
Ejemplo n.º 10
0
 def create_another_partitioned_table():
     return CatalogBaseTable.create_table(
         schema=CatalogTestBase.create_another_table_schema(),
         partition_keys=CatalogTestBase.create_partition_keys(),
         properties=CatalogTestBase.get_batch_table_properties(),
         comment=CatalogTestBase.test_comment)
Ejemplo n.º 11
0
 def create_stream_table():
     return CatalogBaseTable.create_table(
         schema=CatalogTestBase.create_table_schema(),
         properties=CatalogTestBase.get_streaming_table_properties(),
         comment=CatalogTestBase.test_comment)