@Override public void createTable(ObjectPath tableName, CatalogTable table, boolean ignoreIfExists) throws TableAlreadyExistException, DatabaseNotExistException { if (!dbExists(tableName.getDbName())) { throw new DatabaseNotExistException(catalogName, tableName.getDbName()); } if (tableExists(tableName)) { if (!ignoreIfExists) { throw new TableAlreadyExistException(catalogName, tableName.getFullName()); } } else { tables.put(tableName, table); if (table.isPartitioned()) { partitions.put(tableName, new LinkedHashMap<>()); } } }
@Override public void createTable(ObjectPath path, CatalogTable table, boolean ignoreIfExists) throws TableAlreadyExistException, DatabaseNotExistException { try { if (tableExists(path)) { if (!ignoreIfExists) { throw new TableAlreadyExistException(catalogName, path.getFullName()); } } else { // Testing shows that createTable() API in Hive 2.3.4 doesn't throw UnknownDBException as it claims // Thus we have to manually check if the db exists or not if (!dbExists(path.getDbName())) { throw new DatabaseNotExistException(catalogName, path.getDbName()); } client.createTable(HiveMetadataUtil.createHiveTable(path, table)); } } catch (TException e) { throw new FlinkHiveException( String.format("Failed to create table %s", path.getFullName()), e); } }