Java Code Examples for org.apache.flink.table.catalog.ObjectPath#getObjectName()
The following examples show how to use
org.apache.flink.table.catalog.ObjectPath#getObjectName() .
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: KuduCatalog.java From bahir-flink with Apache License 2.0 | 6 votes |
@Override public CatalogTable getTable(ObjectPath tablePath) throws TableNotExistException { checkNotNull(tablePath); if (!tableExists(tablePath)) { throw new TableNotExistException(getName(), tablePath); } String tableName = tablePath.getObjectName(); try { KuduTable kuduTable = kuduClient.openTable(tableName); CatalogTableImpl table = new CatalogTableImpl( KuduTableUtils.kuduToFlinkSchema(kuduTable.getSchema()), createTableProperties(tableName, kuduTable.getSchema().getPrimaryKeyColumns()), tableName); return table; } catch (KuduException e) { throw new CatalogException(e); } }
Example 2
Source File: KuduCatalog.java From bahir-flink with Apache License 2.0 | 5 votes |
@Override public void dropTable(ObjectPath tablePath, boolean ignoreIfNotExists) throws TableNotExistException { String tableName = tablePath.getObjectName(); try { if (tableExists(tablePath)) { kuduClient.deleteTable(tableName); } else if (!ignoreIfNotExists) { throw new TableNotExistException(getName(), tablePath); } } catch (KuduException e) { throw new CatalogException("Could not delete table " + tableName, e); } }
Example 3
Source File: KuduCatalog.java From bahir-flink with Apache License 2.0 | 5 votes |
@Override public void renameTable(ObjectPath tablePath, String newTableName, boolean ignoreIfNotExists) throws TableNotExistException { String tableName = tablePath.getObjectName(); try { if (tableExists(tablePath)) { kuduClient.alterTable(tableName, new AlterTableOptions().renameTable(newTableName)); } else if (!ignoreIfNotExists) { throw new TableNotExistException(getName(), tablePath); } } catch (KuduException e) { throw new CatalogException("Could not rename table " + tableName, e); } }
Example 4
Source File: KuduCatalog.java From bahir-flink with Apache License 2.0 | 5 votes |
@Override public void createTable(ObjectPath tablePath, CatalogBaseTable table, boolean ignoreIfExists) throws TableAlreadyExistException { Map<String, String> tableProperties = table.getProperties(); TableSchema tableSchema = table.getSchema(); Set<String> optionalProperties = new HashSet<>(Arrays.asList(KUDU_REPLICAS)); Set<String> requiredProperties = new HashSet<>(Arrays.asList(KUDU_HASH_COLS)); if (!tableSchema.getPrimaryKey().isPresent()) { requiredProperties.add(KUDU_PRIMARY_KEY_COLS); } if (!tableProperties.keySet().containsAll(requiredProperties)) { throw new CatalogException("Missing required property. The following properties must be provided: " + requiredProperties.toString()); } Set<String> permittedProperties = Sets.union(requiredProperties, optionalProperties); if (!permittedProperties.containsAll(tableProperties.keySet())) { throw new CatalogException("Unpermitted properties were given. The following properties are allowed:" + permittedProperties.toString()); } String tableName = tablePath.getObjectName(); KuduTableInfo tableInfo = KuduTableUtils.createTableInfo(tableName, tableSchema, tableProperties); createTable(tableInfo, ignoreIfExists); }
Example 5
Source File: PulsarMetadataReader.java From pulsar-flink with Apache License 2.0 | 4 votes |
public static String objectPath2TopicName(ObjectPath objectPath) { NamespaceName ns = NamespaceName.get(objectPath.getDatabaseName()); String topic = objectPath.getObjectName(); TopicName fullName = TopicName.get(TopicDomain.persistent.toString(), ns, topic); return fullName.toString(); }
Example 6
Source File: KuduTableFactory.java From bahir-flink with Apache License 2.0 | 4 votes |
@Override public KuduTableSource createTableSource(ObjectPath tablePath, CatalogTable table) { String tableName = tablePath.getObjectName(); return createTableSource(tableName, table.getSchema(), table.getProperties()); }