in xtable-core/src/main/java/org/apache/xtable/iceberg/IcebergTableManager.java [68:101]
Table getOrCreateTable(
IcebergCatalogConfig catalogConfig,
TableIdentifier tableIdentifier,
String basePath,
Schema schema,
PartitionSpec partitionSpec) {
if (tableExists(catalogConfig, tableIdentifier, basePath)) {
return getTable(catalogConfig, tableIdentifier, basePath);
} else {
try {
return getCatalog(catalogConfig)
.map(
catalog ->
catalog.createTable(
tableIdentifier,
schema,
partitionSpec,
basePath,
getDefaultMappingProperties(schema)))
.orElseGet(
() ->
getHadoopTables()
.create(
schema,
partitionSpec,
SortOrder.unsorted(),
getDefaultMappingProperties(schema),
basePath));
} catch (AlreadyExistsException ex) {
log.info("Table {} not created since it already exists", tableIdentifier);
return getTable(catalogConfig, tableIdentifier, basePath);
}
}
}