Search in sources :

Example 31 with TableInfo

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());
}
Also used : TableInfo(org.apache.drill.metastore.metadata.TableInfo) BaseTest(org.apache.drill.test.BaseTest) Test(org.junit.Test) MetastoreTest(org.apache.drill.categories.MetastoreTest)

Example 32 with TableInfo

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));
}
Also used : TableInfo(org.apache.drill.metastore.metadata.TableInfo) BaseTest(org.apache.drill.test.BaseTest) Test(org.junit.Test) MetastoreTest(org.apache.drill.categories.MetastoreTest)

Example 33 with TableInfo

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));
}
Also used : TableInfo(org.apache.drill.metastore.metadata.TableInfo) BaseTest(org.apache.drill.test.BaseTest) Test(org.junit.Test) MetastoreTest(org.apache.drill.categories.MetastoreTest)

Example 34 with TableInfo

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());
}
Also used : TableInfo(org.apache.drill.metastore.metadata.TableInfo) BaseTest(org.apache.drill.test.BaseTest) Test(org.junit.Test) MetastoreTest(org.apache.drill.categories.MetastoreTest)

Example 35 with TableInfo

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());
}
Also used : Path(org.apache.hadoop.fs.Path) SchemaPath(org.apache.drill.common.expression.SchemaPath) MetadataInfo(org.apache.drill.metastore.metadata.MetadataInfo) FileMetadata(org.apache.drill.metastore.metadata.FileMetadata) TableInfo(org.apache.drill.metastore.metadata.TableInfo) BaseTest(org.apache.drill.test.BaseTest) Test(org.junit.Test) MetastoreTest(org.apache.drill.categories.MetastoreTest)

Aggregations

TableInfo (org.apache.drill.metastore.metadata.TableInfo)58 MetastoreTest (org.apache.drill.categories.MetastoreTest)50 Test (org.junit.Test)50 MetastoreTableInfo (org.apache.drill.metastore.components.tables.MetastoreTableInfo)39 SchemaPath (org.apache.drill.common.expression.SchemaPath)37 BaseTableMetadata (org.apache.drill.metastore.metadata.BaseTableMetadata)37 Path (org.apache.hadoop.fs.Path)36 ClusterTest (org.apache.drill.test.ClusterTest)33 SlowTest (org.apache.drill.categories.SlowTest)32 File (java.io.File)29 ColumnStatistics (org.apache.drill.metastore.statistics.ColumnStatistics)29 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)25 HashMap (java.util.HashMap)24 FileMetadata (org.apache.drill.metastore.metadata.FileMetadata)23 SegmentMetadata (org.apache.drill.metastore.metadata.SegmentMetadata)23 StatisticsHolder (org.apache.drill.metastore.statistics.StatisticsHolder)23 RowGroupMetadata (org.apache.drill.metastore.metadata.RowGroupMetadata)20 TupleMetadata (org.apache.drill.exec.record.metadata.TupleMetadata)18 BaseTest (org.apache.drill.test.BaseTest)17 MetadataInfo (org.apache.drill.metastore.metadata.MetadataInfo)16