use of io.prestosql.spi.metastore.model.TableEntity in project hetu-core by openlookeng.
the class HetuHBaseMetastore method hBaseTableToTableEntity.
private TableEntity hBaseTableToTableEntity(HBaseTable hBaseTable) {
TableEntity tableEntity = new TableEntity();
tableEntity.setCatalogName(catalogName);
tableEntity.setDatabaseName(hBaseTable.getSchema());
tableEntity.setName(hBaseTable.getTable());
tableEntity.setType(TABLE_TYPE);
List<ColumnEntity> columns = new ArrayList<>();
for (HBaseColumnHandle columnHandle : hBaseTable.getColumns()) {
ColumnEntity columnEntity = new ColumnEntity();
columnEntity.setName(columnHandle.getColumnName());
columnEntity.setType(columnHandle.getType().getClass().getName());
columnEntity.setComment(columnHandle.getComment());
Map<String, String> columnParam = new HashMap<>();
columnParam.put(Constants.S_FAMILY, columnHandle.getFamily().orElse(null));
columnParam.put(Constants.S_QUALIFIER, columnHandle.getQualifier().orElse(null));
columnParam.put(Constants.S_ORDINAL, String.valueOf(columnHandle.getOrdinal()));
columnParam.put(Constants.S_INDEXED, String.valueOf(columnHandle.isIndexed()).toLowerCase(Locale.ENGLISH));
columnEntity.setParameters(columnParam);
columns.add(columnEntity);
}
tableEntity.setColumns(columns);
Map<String, String> tableParam = new HashMap<>();
tableParam.put(Constants.S_EXTERNAL, String.valueOf(hBaseTable.isExternal()).toLowerCase(Locale.ENGLISH));
tableParam.put(Constants.S_SERIALIZER_CLASS_NAME, hBaseTable.getSerializerClassName());
tableParam.put(Constants.S_ROWID, hBaseTable.getRowId());
tableParam.put(Constants.S_INDEX_COLUMNS, hBaseTable.getIndexColumns());
tableParam.put(Constants.S_HBASE_TABLE_NAME, hBaseTable.getHbaseTableName().orElse(null));
tableParam.put(Constants.S_SPLIT_BY_CHAR, hBaseTable.getSplitByChar().orElse(null));
tableEntity.setParameters(tableParam);
return tableEntity;
}
use of io.prestosql.spi.metastore.model.TableEntity in project hetu-core by openlookeng.
the class VdmMetadata method listViews.
@Override
public List<SchemaTableName> listViews(ConnectorSession session, Optional<String> schemaName) {
ImmutableList.Builder<SchemaTableName> tableNames = ImmutableList.builder();
List<String> schemaNames = schemaName.<List<String>>map(ImmutableList::of).orElseGet(() -> listSchemaNames(session));
for (String schema : schemaNames) {
List<TableEntity> views = metastore.getAllTables(vdmName, schema);
for (TableEntity view : views) {
tableNames.add(new SchemaTableName(view.getDatabaseName(), view.getName()));
}
}
return tableNames.build();
}
use of io.prestosql.spi.metastore.model.TableEntity in project hetu-core by openlookeng.
the class TestHetuMetastoreCacheLocal method testGetTable.
/**
* test get table with metastore cache
*/
@Test
public void testGetTable() throws JsonProcessingException {
String tableName = "table3";
SchemaTableName schemaTableName = new SchemaTableName(defaultDatabase.getName(), tableName);
TableEntity tableEntity = TableEntity.builder().setCatalogName(defaultDatabase.getCatalogName()).setDatabaseName(defaultDatabase.getName()).setTableName(schemaTableName.getTableName()).setTableType(TableEntityType.TABLE.toString()).build();
metastore.createTable(tableEntity);
Optional<TableEntity> tableEntity2 = metastore.getTable(defaultDatabase.getCatalogName(), defaultDatabase.getName(), tableName);
String tableKey = defaultDatabase.getCatalogName() + "." + defaultDatabase.getName() + "." + tableName;
actual = mapper.writeValueAsString(tableCache.getIfPresent(tableKey).get());
expected = mapper.writeValueAsString(tableEntity2.get());
assertEquals(actual, expected);
metastore.dropTable(defaultDatabase.getCatalogName(), defaultDatabase.getName(), tableName);
}
use of io.prestosql.spi.metastore.model.TableEntity in project hetu-core by openlookeng.
the class TestHetuMetastoreCacheLocal method testCreateTable.
/**
* testCreateView with metastore cache
*/
@Test
public void testCreateTable() {
String tableName = "table1";
SchemaTableName schemaTableName = new SchemaTableName(defaultDatabase.getName(), tableName);
TableEntity tableEntity = TableEntity.builder().setCatalogName(defaultDatabase.getCatalogName()).setDatabaseName(defaultDatabase.getName()).setTableName(schemaTableName.getTableName()).setTableType(TableEntityType.TABLE.toString()).build();
metastore.createTable(tableEntity);
String tablesKey = defaultDatabase.getCatalogName() + "." + defaultDatabase.getName();
assertEquals(tablesCache.getIfPresent(tablesKey), null);
metastore.dropTable(defaultDatabase.getCatalogName(), defaultDatabase.getName(), tableName);
}
use of io.prestosql.spi.metastore.model.TableEntity in project hetu-core by openlookeng.
the class TestHetuMetastoreCacheLocal method testGetAllTables.
/**
* test get all table with metastore cache
*/
@Test
public void testGetAllTables() throws JsonProcessingException {
String tableName = "table4";
SchemaTableName schemaTableName = new SchemaTableName(defaultDatabase.getName(), tableName);
TableEntity tableEntity = TableEntity.builder().setCatalogName(defaultDatabase.getCatalogName()).setDatabaseName(defaultDatabase.getName()).setTableName(schemaTableName.getTableName()).setTableType(TableEntityType.TABLE.toString()).build();
metastore.createTable(tableEntity);
List<TableEntity> tableEntities = metastore.getAllTables(defaultDatabase.getCatalogName(), defaultDatabase.getName());
String tablesKey = defaultDatabase.getCatalogName() + "." + defaultDatabase.getName();
actual = mapper.writeValueAsString(tablesCache.getIfPresent(tablesKey));
expected = mapper.writeValueAsString(tableEntities);
assertEquals(actual, expected);
metastore.dropTable(defaultDatabase.getCatalogName(), defaultDatabase.getName(), tableName);
}
Aggregations