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
2 changes: 1 addition & 1 deletion .github/trigger_files/IO_Iceberg_Integration_Tests.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"comment": "Modify this file in a trivial way to cause this test suite to run.",
"modification": 1
"modification": 2
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
Expand Down Expand Up @@ -97,7 +98,6 @@
import org.apache.iceberg.Table;
import org.apache.iceberg.TableProperties;
import org.apache.iceberg.avro.Avro;
import org.apache.iceberg.catalog.Catalog;
import org.apache.iceberg.catalog.TableIdentifier;
import org.apache.iceberg.exceptions.AlreadyExistsException;
import org.apache.iceberg.exceptions.NoSuchTableException;
Expand Down Expand Up @@ -532,17 +532,23 @@ private Table getOrCreateTable(String filePath, FileFormat format) throws IOExce
org.apache.iceberg.Schema schema = getSchema(filePath, format);
PartitionSpec spec = PartitionUtils.toPartitionSpec(partitionFields, schema);
SortOrder sortOrder = SortOrderUtils.toSortOrder(sortFields, schema);

Catalog.TableBuilder builder =
catalogConfig
.catalog()
.buildTable(tableId, schema)
.withPartitionSpec(spec)
.withSortOrder(sortOrder);
if (tableProps != null) {
builder.withProperties(tableProps);
Map<String, String> properties =
tableProps != null ? new HashMap<>(tableProps) : new HashMap<>();
if (properties.get(TableProperties.DEFAULT_NAME_MAPPING) == null) {
// Forces Name based resolution instead of position based resolution
NameMapping mapping = MappingUtil.create(schema);
String mappingJson = NameMappingParser.toJson(mapping);
properties.put(TableProperties.DEFAULT_NAME_MAPPING, mappingJson);
}
return builder.create();

return catalogConfig
.catalog()
.buildTable(tableId, schema)
.withPartitionSpec(spec)
.withSortOrder(sortOrder)
.withProperties(properties)
.create();

} catch (AlreadyExistsException e2) { // if table already exists, just load it
return catalogConfig.catalog().loadTable(TableIdentifier.parse(identifier));
}
Expand Down
Loading