use of io.prestosql.spi.connector.ConnectorTableProperties in project hetu-core by openlookeng.
the class TpchMetadata method getTableProperties.
@Override
public ConnectorTableProperties getTableProperties(ConnectorSession session, ConnectorTableHandle table) {
TpchTableHandle tableHandle = (TpchTableHandle) table;
Optional<ConnectorTablePartitioning> tablePartitioning = Optional.empty();
Optional<Set<ColumnHandle>> partitioningColumns = Optional.empty();
List<LocalProperty<ColumnHandle>> localProperties = ImmutableList.of();
Map<String, ColumnHandle> columns = getColumnHandles(session, tableHandle);
if (partitioningEnabled && tableHandle.getTableName().equals(TpchTable.ORDERS.getTableName())) {
ColumnHandle orderKeyColumn = columns.get(columnNaming.getName(OrderColumn.ORDER_KEY));
tablePartitioning = Optional.of(new ConnectorTablePartitioning(new TpchPartitioningHandle(TpchTable.ORDERS.getTableName(), calculateTotalRows(OrderGenerator.SCALE_BASE, tableHandle.getScaleFactor())), ImmutableList.of(orderKeyColumn)));
partitioningColumns = Optional.of(ImmutableSet.of(orderKeyColumn));
localProperties = ImmutableList.of(new SortingProperty<>(orderKeyColumn, SortOrder.ASC_NULLS_FIRST));
} else if (partitioningEnabled && tableHandle.getTableName().equals(TpchTable.LINE_ITEM.getTableName())) {
ColumnHandle orderKeyColumn = columns.get(columnNaming.getName(LineItemColumn.ORDER_KEY));
tablePartitioning = Optional.of(new ConnectorTablePartitioning(new TpchPartitioningHandle(TpchTable.ORDERS.getTableName(), calculateTotalRows(OrderGenerator.SCALE_BASE, tableHandle.getScaleFactor())), ImmutableList.of(orderKeyColumn)));
partitioningColumns = Optional.of(ImmutableSet.of(orderKeyColumn));
localProperties = ImmutableList.of(new SortingProperty<>(orderKeyColumn, SortOrder.ASC_NULLS_FIRST), new SortingProperty<>(columns.get(columnNaming.getName(LineItemColumn.LINE_NUMBER)), SortOrder.ASC_NULLS_FIRST));
}
return new ConnectorTableProperties(tableHandle.getConstraint(), tablePartitioning, partitioningColumns, Optional.empty(), localProperties);
}
use of io.prestosql.spi.connector.ConnectorTableProperties in project hetu-core by openlookeng.
the class TestHBaseConnector method testGetTableProperties.
/**
* testGetTableProperties
*/
@Test
public void testGetTableProperties() {
ConnectorTableProperties properties = hcm.getTableProperties(session, TestUtils.createHBaseTableHandle());
assertEquals(0, properties.getLocalProperties().size());
}
use of io.prestosql.spi.connector.ConnectorTableProperties in project hetu-core by openlookeng.
the class MetadataManager method getTableProperties.
@Override
public TableProperties getTableProperties(Session session, TableHandle handle) {
CatalogName catalogName = handle.getCatalogName();
CatalogMetadata catalogMetadata = getCatalogMetadata(session, catalogName);
ConnectorMetadata metadata = catalogMetadata.getMetadataFor(catalogName);
ConnectorSession connectorSession = session.toConnectorSession(catalogName);
TableProperties tableProperties;
ConcurrentHashMap<ConnectorTableHandle, TableProperties> tablePropertiesMap;
String queryId = session.getQueryId().getId();
if (metadata.usesLegacyTableLayouts()) {
return handle.getLayout().map(layout -> new TableProperties(catalogName, handle.getTransaction(), new ConnectorTableProperties(metadata.getTableLayout(connectorSession, layout)))).orElseGet(() -> getLayout(session, handle, Constraint.alwaysTrue(), Optional.empty()).get().getTableProperties());
}
if (!handle.getConnectorHandle().isTablePropertiesCacheSupported()) {
return new TableProperties(catalogName, handle.getTransaction(), metadata.getTableProperties(connectorSession, handle.getConnectorHandle()));
}
if (tablePropertiesQueryCache.get(queryId) != null && tablePropertiesQueryCache.get(queryId).get(handle.getConnectorHandle()) != null) {
return tablePropertiesQueryCache.get(queryId).get(handle.getConnectorHandle());
} else {
tableProperties = new TableProperties(catalogName, handle.getTransaction(), metadata.getTableProperties(connectorSession, handle.getConnectorHandle()));
if (tablePropertiesQueryCache.containsKey(queryId)) {
tablePropertiesMap = tablePropertiesQueryCache.get(queryId);
} else {
tablePropertiesMap = new ConcurrentHashMap<>();
}
tablePropertiesMap.put(handle.getConnectorHandle(), tableProperties);
tablePropertiesQueryCache.put(queryId, tablePropertiesMap);
}
return tableProperties;
}
use of io.prestosql.spi.connector.ConnectorTableProperties in project hetu-core by openlookeng.
the class AbstractTestHive method testGetPartitionsWithBindings.
@Test
public void testGetPartitionsWithBindings() {
try (Transaction transaction = newTransaction()) {
ConnectorMetadata metadata = transaction.getMetadata();
ConnectorTableHandle tableHandle = getTableHandle(metadata, tablePartitionFormat);
Constraint constraint = new Constraint(TupleDomain.withColumnDomains(ImmutableMap.of(intColumn, Domain.singleValue(BIGINT, 5L))));
tableHandle = applyFilter(metadata, tableHandle, constraint);
ConnectorTableProperties properties = metadata.getTableProperties(newSession(), tableHandle);
assertExpectedTableProperties(properties, tablePartitionFormatProperties);
assertExpectedPartitions(tableHandle, tablePartitionFormatPartitions);
}
}
use of io.prestosql.spi.connector.ConnectorTableProperties in project hetu-core by openlookeng.
the class AbstractTestHive method testGetPartitions.
@Test
public void testGetPartitions() {
try (Transaction transaction = newTransaction()) {
ConnectorMetadata metadata = transaction.getMetadata();
ConnectorTableHandle tableHandle = getTableHandle(metadata, tablePartitionFormat);
tableHandle = applyFilter(metadata, tableHandle, Constraint.alwaysTrue());
ConnectorTableProperties properties = metadata.getTableProperties(newSession(), tableHandle);
assertExpectedTableProperties(properties, tablePartitionFormatProperties);
assertExpectedPartitions(tableHandle, tablePartitionFormatPartitions);
}
}
Aggregations