use of org.apache.drill.metastore.components.tables.MetastoreTableInfo in project drill by apache.
the class TestIcebergBasicTablesRequests method testMetastoreTableInfoExistingTable.
@Test
public void testMetastoreTableInfoExistingTable() {
MetastoreTableInfo metastoreTableInfo = basicRequests.metastoreTableInfo(nationTableInfo);
assertTrue(metastoreTableInfo.isExists());
assertEquals(nationTableInfo, metastoreTableInfo.tableInfo());
assertEquals(nationTable.lastModifiedTime(), metastoreTableInfo.lastModifiedTime());
assertTrue(metastoreTableInfo.metastoreVersion() > 0);
}
use of org.apache.drill.metastore.components.tables.MetastoreTableInfo in project drill by apache.
the class MetadataControllerBatch method writeToMetastore.
private void writeToMetastore() {
MetadataControllerContext mdContext = popConfig.getContext();
FilterExpression deleteFilter = mdContext.tableInfo().toFilter();
for (MetadataInfo metadataInfo : mdContext.metadataToRemove()) {
deleteFilter = FilterExpression.and(deleteFilter, FilterExpression.equal(MetastoreColumn.METADATA_KEY, metadataInfo.key()));
}
Modify<TableMetadataUnit> modify = tables.modify();
if (!popConfig.getContext().metadataToRemove().isEmpty()) {
modify.delete(Delete.builder().metadataType(MetadataType.SEGMENT, MetadataType.FILE, MetadataType.ROW_GROUP, MetadataType.PARTITION).filter(deleteFilter).build());
}
MetastoreTableInfo metastoreTableInfo = mdContext.metastoreTableInfo();
if (tables.basicRequests().hasMetastoreTableInfoChanged(metastoreTableInfo)) {
throw UserException.executionError(null).message("Metadata for table [%s] was changed before analyze is finished", tableInfo.name()).build(logger);
}
modify.overwrite(metadataUnits).execute();
}
use of org.apache.drill.metastore.components.tables.MetastoreTableInfo in project drill by apache.
the class TestRdbmsBasicTablesRequests method testMetastoreTableInfoExistingTable.
@Test
public void testMetastoreTableInfoExistingTable() {
MetastoreTableInfo metastoreTableInfo = basicRequests.metastoreTableInfo(nationTableInfo);
assertTrue(metastoreTableInfo.isExists());
assertEquals(nationTableInfo, metastoreTableInfo.tableInfo());
assertEquals(nationTable.lastModifiedTime(), metastoreTableInfo.lastModifiedTime());
assertEquals(Metadata.UNDEFINED, metastoreTableInfo.metastoreVersion());
}
use of org.apache.drill.metastore.components.tables.MetastoreTableInfo in project drill by apache.
the class TestMetastoreCommands method testDropMetadata.
@Test
public void testDropMetadata() throws Exception {
String tableName = "tableDropMetadata";
TableInfo tableInfo = getTableInfo(tableName, "tmp");
try {
run("create table dfs.tmp.`%s` as\n" + "select * from cp.`tpch/region.parquet`", tableName);
testBuilder().sqlQuery("analyze table dfs.tmp.`%s` REFRESH METADATA", tableName).unOrdered().baselineColumns("ok", "summary").baselineValues(true, String.format("Collected / refreshed metadata for table [dfs.tmp.%s]", tableName)).go();
MetastoreTableInfo metastoreTableInfo = cluster.drillbit().getContext().getMetastoreRegistry().get().tables().basicRequests().metastoreTableInfo(tableInfo);
assertTrue(metastoreTableInfo.isExists());
BaseTableMetadata baseTableMetadata = cluster.drillbit().getContext().getMetastoreRegistry().get().tables().basicRequests().tableMetadata(tableInfo);
assertNotNull(baseTableMetadata);
List<RowGroupMetadata> rowGroupMetadata = cluster.drillbit().getContext().getMetastoreRegistry().get().tables().basicRequests().rowGroupsMetadata(tableInfo, (String) null, null);
assertEquals(1, rowGroupMetadata.size());
testBuilder().sqlQuery("analyze table dfs.tmp.`%s` drop metadata", tableName).unOrdered().baselineColumns("ok", "summary").baselineValues(true, String.format("Metadata for table [%s] dropped.", tableName)).go();
metastoreTableInfo = cluster.drillbit().getContext().getMetastoreRegistry().get().tables().basicRequests().metastoreTableInfo(tableInfo);
assertFalse(metastoreTableInfo.isExists());
baseTableMetadata = cluster.drillbit().getContext().getMetastoreRegistry().get().tables().basicRequests().tableMetadata(tableInfo);
assertNull(baseTableMetadata);
rowGroupMetadata = cluster.drillbit().getContext().getMetastoreRegistry().get().tables().basicRequests().rowGroupsMetadata(tableInfo, (String) null, null);
assertEquals(0, rowGroupMetadata.size());
} finally {
run("analyze table dfs.tmp.`%s` drop metadata if exists", tableName);
run("drop table if exists dfs.tmp.`%s`", tableName);
client.resetSession(ExecConstants.METASTORE_ENABLED);
}
}
use of org.apache.drill.metastore.components.tables.MetastoreTableInfo in project drill by apache.
the class TestMetastoreCommands method testAnalyzeWithLeadingSlash.
@Test
public void testAnalyzeWithLeadingSlash() throws Exception {
String tableName = "tableWithLeadingSlash";
TableInfo tableInfo = getTableInfo("/" + tableName, "tmp");
try {
run("create table dfs.tmp.`%s` as\n" + "select * from cp.`tpch/region.parquet`", tableName);
testBuilder().sqlQuery("analyze table dfs.tmp.`%s` REFRESH METADATA", tableName).unOrdered().baselineColumns("ok", "summary").baselineValues(true, String.format("Collected / refreshed metadata for table [dfs.tmp.%s]", tableName)).go();
MetastoreTableInfo metastoreTableInfo = cluster.drillbit().getContext().getMetastoreRegistry().get().tables().basicRequests().metastoreTableInfo(tableInfo);
assertTrue("table metadata wasn't found", metastoreTableInfo.isExists());
} finally {
run("analyze table dfs.tmp.`%s` drop metadata", tableName);
run("drop table if exists dfs.tmp.`%s`", tableName);
}
}
Aggregations