use of org.apache.flink.table.catalog.CatalogTableImpl in project flink by apache.
the class HiveCatalogTest method testCreateGenericTable.
@Test
public void testCreateGenericTable() {
Table hiveTable = HiveTableUtil.instantiateHiveTable(new ObjectPath("test", "test"), new CatalogTableImpl(schema, getLegacyFileSystemConnectorOptions("/test_path"), null), HiveTestUtils.createHiveConf(), false);
Map<String, String> prop = hiveTable.getParameters();
assertThat(HiveCatalog.isHiveTable(prop)).isFalse();
assertThat(prop.keySet()).allMatch(k -> k.startsWith(CatalogPropertiesUtil.FLINK_PROPERTY_PREFIX));
}
use of org.apache.flink.table.catalog.CatalogTableImpl in project flink by apache.
the class HiveCatalogTest method testAlterFlinkNonManagedTableToFlinkManagedTable.
@Test
public void testAlterFlinkNonManagedTableToFlinkManagedTable() throws Exception {
Map<String, String> originOptions = Collections.singletonMap(FactoryUtil.CONNECTOR.key(), DataGenTableSourceFactory.IDENTIFIER);
CatalogTable originTable = new CatalogTableImpl(schema, originOptions, "Flink non-managed table");
hiveCatalog.createTable(tablePath, originTable, false);
Map<String, String> newOptions = Collections.emptyMap();
CatalogTable newTable = new CatalogTableImpl(schema, newOptions, "Flink managed table");
assertThatThrownBy(() -> hiveCatalog.alterTable(tablePath, newTable, false)).isInstanceOf(IllegalArgumentException.class).hasMessageContaining("Changing catalog table type is not allowed. " + "Existing table type is 'FLINK_NON_MANAGED_TABLE', but new table type is 'FLINK_MANAGED_TABLE'");
}
use of org.apache.flink.table.catalog.CatalogTableImpl in project flink by apache.
the class HiveCatalogTest method testAlterFlinkManagedTableToFlinkManagedTable.
@Test
public void testAlterFlinkManagedTableToFlinkManagedTable() throws Exception {
Map<String, String> originOptions = Collections.emptyMap();
CatalogTable originTable = new CatalogTableImpl(schema, originOptions, "Flink managed table");
hiveCatalog.createTable(tablePath, originTable, false);
Map<String, String> newOptions = Collections.singletonMap(FactoryUtil.CONNECTOR.key(), DataGenTableSourceFactory.IDENTIFIER);
CatalogTable newTable = new CatalogTableImpl(schema, newOptions, "Flink non-managed table");
assertThatThrownBy(() -> hiveCatalog.alterTable(tablePath, newTable, false)).isInstanceOf(IllegalArgumentException.class).hasMessageContaining("Changing catalog table type is not allowed. " + "Existing table type is 'FLINK_MANAGED_TABLE', but new table type is 'FLINK_NON_MANAGED_TABLE'");
}
use of org.apache.flink.table.catalog.CatalogTableImpl in project flink by apache.
the class HiveCatalogTest method testCreateAndGetFlinkManagedTable.
@Test
public void testCreateAndGetFlinkManagedTable() throws Exception {
CatalogTable table = new CatalogTableImpl(schema, Collections.emptyMap(), "Flink managed table");
hiveCatalog.createTable(tablePath, table, false);
Table hiveTable = hiveCatalog.getHiveTable(tablePath);
assertThat(hiveTable.getParameters()).containsEntry(FLINK_PROPERTY_PREFIX + CONNECTOR.key(), ManagedTableFactory.DEFAULT_IDENTIFIER);
CatalogBaseTable retrievedTable = hiveCatalog.instantiateCatalogTable(hiveTable);
assertThat(retrievedTable.getOptions()).isEmpty();
}
use of org.apache.flink.table.catalog.CatalogTableImpl in project flink by apache.
the class HiveCatalogTest method testAlterFlinkManagedTableToHiveTable.
@Test
public void testAlterFlinkManagedTableToHiveTable() throws Exception {
Map<String, String> originOptions = Collections.emptyMap();
CatalogTable originTable = new CatalogTableImpl(schema, originOptions, "Flink managed table");
hiveCatalog.createTable(tablePath, originTable, false);
Map<String, String> newOptions = getLegacyFileSystemConnectorOptions("/test_path");
newOptions.put(FactoryUtil.CONNECTOR.key(), SqlCreateHiveTable.IDENTIFIER);
CatalogTable newTable = new CatalogTableImpl(schema, newOptions, "Hive table");
assertThatThrownBy(() -> hiveCatalog.alterTable(tablePath, newTable, false)).isInstanceOf(IllegalArgumentException.class).hasMessageContaining("Changing catalog table type is not allowed. " + "Existing table type is 'FLINK_MANAGED_TABLE', but new table type is 'HIVE_TABLE'");
}
Aggregations