Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,8 @@ private List<Path> getSchemaExternalPaths(List<TableSchema> schemas) {
})
.filter(Objects::nonNull)
.flatMap(externalPath -> Arrays.stream(externalPath.split(",")))
.map(String::trim)
.filter(path -> !path.isEmpty())
.map(Path::new)
.distinct()
.collect(Collectors.toList());
Expand Down Expand Up @@ -445,7 +447,8 @@ public void createTable(Identifier identifier, Schema schema, boolean ignoreIfEx
copyTableDefaultOptions(schema.options());
validateCreateTable(schema, false);

switch (Options.fromMap(schema.options()).get(TYPE)) {
TableType type = Options.fromMap(schema.options()).get(TYPE);
switch (type) {
case TABLE:
case MATERIALIZED_TABLE:
createTableImpl(identifier, schema);
Expand All @@ -456,6 +459,11 @@ public void createTable(Identifier identifier, Schema schema, boolean ignoreIfEx
case OBJECT_TABLE:
createObjectTable(identifier, schema);
break;
default:
// silently falling through would report a successful DDL without
// creating anything
throw new UnsupportedOperationException(
"Create table with type '" + type + "' is not supported.");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,11 @@ public void createTable(Identifier identifier, Schema schema, boolean ignoreIfEx
"Failed to create table " + identifier.getFullName(), e);
}
break;
default:
// silently falling through would report a successful DDL without
// creating anything
throw new UnsupportedOperationException(
"Create table with type '" + tableType + "' is not supported.");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,43 @@ public void testCreateTableCaseSensitive() throws Exception {
catalog.createTable(identifier, schema, false);
}

@Test
public void testCreateTableWithUnsupportedTypeFailsLoudly() throws Exception {
catalog.createDatabase("test_db", false);
Identifier identifier = Identifier.create("test_db", "iceberg_t");
Schema schema =
Schema.newBuilder()
.column("k", DataTypes.INT())
.option("type", "iceberg-table")
.build();

// falling through the switch silently would report a successful DDL without
// creating anything
assertThatThrownBy(() -> catalog.createTable(identifier, schema, false))
.isInstanceOf(UnsupportedOperationException.class)
.hasMessageContaining("iceberg-table");
assertThat(catalog.listTables("test_db")).doesNotContain(identifier.getObjectName());
}

@Test
public void testDropTableToleratesBlankExternalPaths() throws Exception {
catalog.createDatabase("test_db", false);
Identifier identifier = Identifier.create("test_db", "external_paths_t");
Path external = new Path(new Path(warehouse), "test_db/external_dir");
fileIO.mkdirs(external);
Schema schema =
Schema.newBuilder()
.column("k", DataTypes.INT())
.option("data-file.external-paths", " , " + external + " ,")
.build();
catalog.createTable(identifier, schema, false);

// the drop must not crash on the blank segments the create-time validation
// tolerates
catalog.dropTable(identifier, false);
assertThat(catalog.listTables("test_db")).doesNotContain(identifier.getObjectName());
}

@Test
public void testValidateFormatTableDefaultOptions() throws Exception {
String database = "format_table_default_validation_db";
Expand Down
Loading