1
0

[HUDI-3132] Minor fixes for HoodieCatalog

close apache/hudi#4486
This commit is contained in:
fengli
2021-12-31 23:25:04 +08:00
committed by yuzhao.cyz
parent eee715b3ff
commit 205e48f53f
2 changed files with 8 additions and 1 deletions

View File

@@ -305,7 +305,9 @@ public class HoodieCatalog extends AbstractCatalog {
try { try {
StreamerUtil.initTableIfNotExists(conf); StreamerUtil.initTableIfNotExists(conf);
// prepare the non-table-options properties // prepare the non-table-options properties
options.put(TableOptionProperties.COMMENT, resolvedTable.getComment()); if (!StringUtils.isNullOrWhitespaceOnly(resolvedTable.getComment())) {
options.put(TableOptionProperties.COMMENT, resolvedTable.getComment());
}
TableOptionProperties.createProperties(tablePathStr, hadoopConf, options); TableOptionProperties.createProperties(tablePathStr, hadoopConf, options);
} catch (IOException e) { } catch (IOException e) {
throw new CatalogException(String.format("Initialize table path %s exception.", tablePathStr), e); throw new CatalogException(String.format("Initialize table path %s exception.", tablePathStr), e);

View File

@@ -37,6 +37,7 @@ import org.apache.flink.table.catalog.ResolvedCatalogTable;
import org.apache.flink.table.catalog.ResolvedSchema; import org.apache.flink.table.catalog.ResolvedSchema;
import org.apache.flink.table.catalog.UniqueConstraint; import org.apache.flink.table.catalog.UniqueConstraint;
import org.apache.flink.table.catalog.exceptions.CatalogException; import org.apache.flink.table.catalog.exceptions.CatalogException;
import org.apache.flink.table.catalog.exceptions.DatabaseAlreadyExistException;
import org.apache.flink.table.catalog.exceptions.DatabaseNotExistException; import org.apache.flink.table.catalog.exceptions.DatabaseNotExistException;
import org.apache.flink.table.catalog.exceptions.TableAlreadyExistException; import org.apache.flink.table.catalog.exceptions.TableAlreadyExistException;
import org.apache.flink.table.catalog.exceptions.TableNotExistException; import org.apache.flink.table.catalog.exceptions.TableNotExistException;
@@ -158,6 +159,10 @@ public class TestHoodieCatalog {
assertTrue(catalog.listDatabases().contains("db1")); assertTrue(catalog.listDatabases().contains("db1"));
assertEquals(expected.getProperties(), actual.getProperties()); assertEquals(expected.getProperties(), actual.getProperties());
// create exist database
assertThrows(DatabaseAlreadyExistException.class,
() -> catalog.createDatabase("db1", expected, false));
// drop exist database // drop exist database
catalog.dropDatabase("db1", true); catalog.dropDatabase("db1", true);
assertFalse(catalog.listDatabases().contains("db1")); assertFalse(catalog.listDatabases().contains("db1"));