use of org.apache.drill.metastore.metadata.TableInfo in project drill by apache.
the class AbstractBasicTablesRequestsTest method testMetastoreTableInfoAbsentTable.
@Test
public void testMetastoreTableInfoAbsentTable() {
TableInfo tableInfo = TableInfo.builder().storagePlugin("dfs").workspace("tmp").name("absent").build();
MetastoreTableInfo metastoreTableInfo = basicRequests.metastoreTableInfo(tableInfo);
assertFalse(metastoreTableInfo.isExists());
assertEquals(tableInfo, metastoreTableInfo.tableInfo());
assertNull(metastoreTableInfo.lastModifiedTime());
}
use of org.apache.drill.metastore.metadata.TableInfo in project drill by apache.
the class AbstractBasicTablesRequestsTest method testHasMetastoreTableInfoChangedTrue.
@Test
public void testHasMetastoreTableInfoChangedTrue() {
TableMetadataUnit unit = nationTable.toBuilder().tableName("changingTable").lastModifiedTime(1L).build();
tables.modify().overwrite(unit).execute();
TableInfo tableInfo = TableInfo.builder().metadataUnit(unit).build();
MetastoreTableInfo metastoreTableInfo = basicRequests.metastoreTableInfo(tableInfo);
TableMetadataUnit updatedUnit = unit.toBuilder().lastModifiedTime(2L).build();
tables.modify().overwrite(updatedUnit).execute();
assertTrue(basicRequests.hasMetastoreTableInfoChanged(metastoreTableInfo));
}
use of org.apache.drill.metastore.metadata.TableInfo in project drill by apache.
the class AbstractTablesMetastoreTest method testFilterByAbsentColumns.
@Test
public void testFilterByAbsentColumns() {
TableInfo tableInfo = TableInfo.builder().storagePlugin("dfs").workspace("tmp").name("nation").build();
TableMetadataUnit unit = TableMetadataUnit.builder().storagePlugin(tableInfo.storagePlugin()).workspace(tableInfo.workspace()).tableName(tableInfo.name()).metadataKey(MetadataInfo.GENERAL_INFO_KEY).metadataType(MetadataType.TABLE.name()).lastModifiedTime(System.currentTimeMillis()).build();
tables.modify().overwrite(unit).execute();
List<TableMetadataUnit> units = tables.read().metadataType(MetadataType.TABLE).filter(FilterExpression.equal(MetastoreColumn.PATH, "abc")).columns(MetastoreColumn.TABLE_NAME).execute();
assertEquals(0, units.size());
units = tables.read().metadataType(MetadataType.TABLE).filter(FilterExpression.and(FilterExpression.equal(MetastoreColumn.TABLE_NAME, "nation"), FilterExpression.isNull(MetastoreColumn.PARTITION_VALUES), FilterExpression.notEqual(MetastoreColumn.PATH, "abc"), FilterExpression.isNull(MetastoreColumn.COLUMN), FilterExpression.notIn(MetastoreColumn.ROW_GROUP_INDEX, 1, 2))).columns(MetastoreColumn.TABLE_NAME).execute();
assertEquals(TableMetadataUnit.builder().tableName("nation").build(), units.get(0));
}
use of org.apache.drill.metastore.metadata.TableInfo in project drill by apache.
the class AbstractTablesMetastoreTest method testOverwriteDeleteOrder.
@Test
public void testOverwriteDeleteOrder() {
TableInfo tableInfo = TableInfo.builder().storagePlugin("dfs").workspace("tmp").name("nation").build();
TableMetadataUnit initialUnit = TableMetadataUnit.builder().storagePlugin(tableInfo.storagePlugin()).workspace(tableInfo.workspace()).tableName(tableInfo.name()).metadataKey(MetadataInfo.GENERAL_INFO_KEY).metadataType(MetadataType.TABLE.name()).lastModifiedTime(System.currentTimeMillis()).tableType("parquet").build();
TableMetadataUnit updatedUnit = initialUnit.toBuilder().tableType("text").build();
// add initial unit
tables.modify().overwrite(initialUnit).execute();
// first delete, then overwrite
tables.modify().delete(Delete.builder().metadataType(MetadataType.TABLE).build()).overwrite(updatedUnit).execute();
// check that unit is present and updated
List<TableMetadataUnit> resultAfterDeleteOverwrite = tables.read().metadataType(MetadataType.TABLE).execute();
assertEquals(1, resultAfterDeleteOverwrite.size());
assertEquals(updatedUnit, resultAfterDeleteOverwrite.get(0));
// first overwrite, then delete
tables.modify().overwrite(initialUnit).delete(Delete.builder().metadataType(MetadataType.TABLE).build()).execute();
// check that units are absent
List<TableMetadataUnit> resultAfterOverwriteDelete = tables.read().metadataType(MetadataType.TABLE).execute();
assertEquals(0, resultAfterOverwriteDelete.size());
}
use of org.apache.drill.metastore.metadata.TableInfo in project drill by apache.
the class TestTableMetadataUnitConversion method testFileMetadata.
@Test
public void testFileMetadata() {
TableInfo tableInfo = data.basicTableInfo;
MetadataInfo metadataInfo = MetadataInfo.builder().type(MetadataType.FILE).key("part_int=3").identifier("part_int=3/part_varchar=g/0_0_0.parquet").build();
Path path = new Path("/tmp/nation/part_int=3/part_varchar=g/0_0_0.parquet");
FileMetadata metadata = FileMetadata.builder().tableInfo(tableInfo).metadataInfo(metadataInfo).schema(data.schema).columnsStatistics(data.columnsStatistics).metadataStatistics(data.metadataStatistics).lastModifiedTime(data.lastModifiedTime).path(path).build();
TableMetadataUnit expectedUnit = TableMetadataUnit.builder().storagePlugin(tableInfo.storagePlugin()).workspace(tableInfo.workspace()).tableName(tableInfo.name()).metadataType(metadataInfo.type().name()).metadataKey(metadataInfo.key()).metadataIdentifier(metadataInfo.identifier()).schema(data.unitSchema).columnsStatistics(data.unitColumnsStatistics).metadataStatistics(data.unitMetadataStatistics).lastModifiedTime(data.lastModifiedTime).path(path.toUri().getPath()).location(path.getParent().toUri().getPath()).build();
TableMetadataUnit actualUnit = metadata.toMetadataUnit();
assertEquals(expectedUnit, actualUnit);
assertNotNull(FileMetadata.builder().metadataUnit(actualUnit).build());
}
Aggregations