use of org.apache.iceberg.MetadataTableType in project iceberg by apache.
the class TestMetadataTablesWithPartitionEvolution method testMetadataTablesWithUnknownTransforms.
@Test
public void testMetadataTablesWithUnknownTransforms() {
sql("CREATE TABLE %s (id bigint NOT NULL, category string, data string) USING iceberg", tableName);
initTable();
sql("INSERT INTO TABLE %s VALUES (1, 'a1', 'b1')", tableName);
Table table = validationCatalog.loadTable(tableIdent);
PartitionSpec unknownSpec = PartitionSpecParser.fromJson(table.schema(), "{ \"spec-id\": 1, \"fields\": [ { \"name\": \"id_zero\", \"transform\": \"zero\", \"source-id\": 1 } ] }");
// replace the table spec to include an unknown transform
TableOperations ops = ((HasTableOperations) table).operations();
TableMetadata base = ops.current();
ops.commit(base, base.updatePartitionSpec(unknownSpec));
sql("REFRESH TABLE %s", tableName);
for (MetadataTableType tableType : Arrays.asList(FILES, ALL_DATA_FILES, ENTRIES, ALL_ENTRIES)) {
AssertHelpers.assertThrows("Should complain about the partition type", ValidationException.class, "Cannot build table partition type, unknown transforms", () -> loadMetadataTable(tableType));
}
}
use of org.apache.iceberg.MetadataTableType in project iceberg by apache.
the class TestStaticTable method testCannotDoIncrementalScanOnMetadataTable.
@Test
public void testCannotDoIncrementalScanOnMetadataTable() {
table.newAppend().appendFile(FILE_A).commit();
for (MetadataTableType type : MetadataTableType.values()) {
Table staticTable = getStaticTable(type);
AssertHelpers.assertThrows("Static tables do not support incremental scans", UnsupportedOperationException.class, String.format("Cannot incrementally scan table of type %s", type), () -> staticTable.newScan().appendsAfter(1));
}
}
use of org.apache.iceberg.MetadataTableType in project iceberg by apache.
the class TestStaticTable method testMetadataTables.
@Test
public void testMetadataTables() {
for (MetadataTableType type : MetadataTableType.values()) {
String enumName = type.name().replace("_", "").toLowerCase();
Assert.assertTrue("Should be able to get MetadataTable of type : " + type, getStaticTable(type).getClass().getName().toLowerCase().contains(enumName));
}
}
use of org.apache.iceberg.MetadataTableType in project iceberg by apache.
the class HadoopTables method load.
/**
* Loads the table location from a FileSystem path location.
*
* @param location a path URI (e.g. hdfs:///warehouse/my_table/)
* @return table implementation
*/
@Override
public Table load(String location) {
Table result;
Pair<String, MetadataTableType> parsedMetadataType = parseMetadataType(location);
if (parsedMetadataType != null) {
// Load a metadata table
result = loadMetadataTable(parsedMetadataType.first(), location, parsedMetadataType.second());
} else {
// Load a normal table
TableOperations ops = newTableOps(location);
if (ops.current() != null) {
result = new BaseTable(ops, location);
} else {
throw new NoSuchTableException("Table does not exist at location: %s", location);
}
}
LOG.info("Table location loaded: {}", result.location());
return result;
}
use of org.apache.iceberg.MetadataTableType in project drill by apache.
the class IcebergFormatLocationTransformer method transform.
@Override
public FileSelection transform(String location, Function<String, FileSelection> selectionFactory) {
MetadataTableType metadataTableType = getMetadataTableType(location);
location = StringUtils.substringBeforeLast(location, METADATA_SEPARATOR);
FileSelection fileSelection = selectionFactory.apply(location);
return fileSelection != null ? new IcebergMetadataFileSelection(fileSelection, metadataTableType) : null;
}
Aggregations