use of io.prestosql.spi.connector.ConnectorTableHandle in project hetu-core by openlookeng.
the class TpchIndexMetadata method resolveIndex.
@Override
public Optional<ConnectorResolvedIndex> resolveIndex(ConnectorSession session, ConnectorTableHandle tableHandle, Set<ColumnHandle> indexableColumns, Set<ColumnHandle> outputColumns, TupleDomain<ColumnHandle> tupleDomain) {
TpchTableHandle tpchTableHandle = (TpchTableHandle) tableHandle;
// Keep the fixed values that don't overlap with the indexableColumns
// Note: technically we could more efficiently utilize the overlapped columns, but this way is simpler for now
Map<ColumnHandle, NullableValue> fixedValues = TupleDomain.extractFixedValues(tupleDomain).orElse(ImmutableMap.of()).entrySet().stream().filter(entry -> !indexableColumns.contains(entry.getKey())).filter(// strip nulls since meaningless in index join lookups
entry -> !entry.getValue().isNull()).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
// determine all columns available for index lookup
Set<String> lookupColumnNames = ImmutableSet.<String>builder().addAll(handleToNames(ImmutableList.copyOf(indexableColumns))).addAll(handleToNames(ImmutableList.copyOf(fixedValues.keySet()))).build();
// do we have an index?
if (!indexedData.getIndexedTable(tpchTableHandle.getTableName(), tpchTableHandle.getScaleFactor(), lookupColumnNames).isPresent()) {
return Optional.empty();
}
TupleDomain<ColumnHandle> filteredTupleDomain = tupleDomain;
if (!tupleDomain.isNone()) {
filteredTupleDomain = TupleDomain.withColumnDomains(Maps.filterKeys(tupleDomain.getDomains().get(), not(in(fixedValues.keySet()))));
}
TpchIndexHandle indexHandle = new TpchIndexHandle(tpchTableHandle.getTableName(), tpchTableHandle.getScaleFactor(), lookupColumnNames, TupleDomain.fromFixedValues(fixedValues));
return Optional.of(new ConnectorResolvedIndex(indexHandle, filteredTupleDomain));
}
use of io.prestosql.spi.connector.ConnectorTableHandle in project hetu-core by openlookeng.
the class CarbondataPageSourceProvider method createPageSource.
@Override
public ConnectorPageSource createPageSource(ConnectorTransactionHandle transactionHandle, ConnectorSession session, ConnectorSplit split, ConnectorTableHandle table, List<ColumnHandle> columns) {
HiveSplit carbonSplit = Types.checkType(((HiveSplitWrapper) (split)).getSplits().get(0), HiveSplit.class, "split is not class HiveSplit");
this.queryId = carbonSplit.getSchema().getProperty("queryId");
if (this.queryId == null) {
// Fall back to hive pagesource.
return super.createPageSource(transactionHandle, session, split, table, columns);
}
try {
hdfsEnvironment.getFileSystem(new HdfsEnvironment.HdfsContext(session, carbonSplit.getDatabase()), new Path(carbonSplit.getSchema().getProperty("tablePath")));
} catch (IOException e) {
throw new PrestoException(GENERIC_INTERNAL_ERROR, "Failed to get file system: " + e.getMessage());
}
return hdfsEnvironment.doAs(session.getUser(), () -> {
Configuration configuration = this.hdfsEnvironment.getConfiguration(new HdfsEnvironment.HdfsContext(session, carbonSplit.getDatabase(), carbonSplit.getTable()), new Path(carbonSplit.getSchema().getProperty("tablePath")));
CarbonTable carbonTable = getCarbonTable(carbonSplit, configuration);
/* So that CarbonTLS can access it */
ThreadLocalSessionInfo.setConfigurationToCurrentThread(configuration);
boolean isFullACID = isFullAcidTable(Maps.fromProperties(carbonSplit.getSchema()));
boolean isDirectVectorFill = (carbonTableReader.config.getPushRowFilter() == null) || carbonTableReader.config.getPushRowFilter().equalsIgnoreCase("false") || columns.stream().anyMatch(c -> c.getColumnName().equalsIgnoreCase(CarbonCommonConstants.CARBON_IMPLICIT_COLUMN_TUPLEID));
return new CarbondataPageSource(carbonTable, queryId, carbonSplit, columns, table, configuration, isDirectVectorFill, isFullACID, session.getUser(), hdfsEnvironment);
});
}
use of io.prestosql.spi.connector.ConnectorTableHandle in project hetu-core by openlookeng.
the class TestHBase method testGetNullSchemaTableMeta.
/**
* testGetNullSchemaTableMeta
*
* @throws TableNotFoundException
*/
@Test
public void testGetNullSchemaTableMeta() {
try {
ConnectorTableHandle table2 = TestUtils.createHBaseTableHandle("default", "table1");
HBaseConnectorMetadata hBcm = new HBaseConnectorMetadata(hconn);
hBcm.getTableMetadata(session, table2);
} catch (TableNotFoundException e) {
assertEquals(e.getMessage(), format(("Table '%s' not found"), "default.table1"));
}
}
use of io.prestosql.spi.connector.ConnectorTableHandle in project hetu-core by openlookeng.
the class TestHBase method testBeginInsert.
/**
* testBeginInsert
*/
@Test
public void testBeginInsert() {
ConnectorTableHandle table2 = TestUtils.createHBaseTableHandle("hbase", "test_table");
ConnectorInsertTableHandle table3 = TestUtils.createHBaseTableHandle("hbase", "test_table");
assertEquals(false, hcm.beginInsert(session, table2).toString().isEmpty());
assertEquals(false, hcm.finishInsert(session, table3, null, null).isPresent());
}
use of io.prestosql.spi.connector.ConnectorTableHandle in project hetu-core by openlookeng.
the class TestHivePageSink method createPageSource.
private static ConnectorPageSource createPageSource(HiveTransactionHandle transaction, HiveConfig config, File outputFile) {
Properties splitProperties = new Properties();
splitProperties.setProperty(FILE_INPUT_FORMAT, config.getHiveStorageFormat().getInputFormat());
splitProperties.setProperty(SERIALIZATION_LIB, config.getHiveStorageFormat().getSerDe());
splitProperties.setProperty("columns", Joiner.on(',').join(getColumnHandles().stream().map(HiveColumnHandle::getName).collect(toList())));
splitProperties.setProperty("columns.types", Joiner.on(',').join(getColumnHandles().stream().map(HiveColumnHandle::getHiveType).map(hiveType -> hiveType.getHiveTypeName().toString()).collect(toList())));
HiveSplitWrapper split = null;
try {
split = HiveSplitWrapper.wrap(new HiveSplit(SCHEMA_NAME, TABLE_NAME, "", "file:///" + outputFile.getCanonicalPath(), 0, outputFile.length(), outputFile.length(), 0, splitProperties, ImmutableList.of(), ImmutableList.of(), OptionalInt.empty(), false, ImmutableMap.of(), Optional.empty(), false, Optional.empty(), Optional.empty(), false, ImmutableMap.of()));
} catch (IOException e) {
System.out.println(e.getMessage());
}
ConnectorTableHandle table = new HiveTableHandle(SCHEMA_NAME, TABLE_NAME, ImmutableMap.of(), ImmutableList.of(), Optional.empty());
HivePageSourceProvider provider = new HivePageSourceProvider(config, HiveTestUtils.createTestHdfsEnvironment(config), HiveTestUtils.getDefaultHiveRecordCursorProvider(config), HiveTestUtils.getDefaultHiveDataStreamFactories(config), HiveTestUtils.TYPE_MANAGER, HiveTestUtils.getNoOpIndexCache(), getDefaultHiveSelectiveFactories(config));
return provider.createPageSource(transaction, getSession(config), split, table, ImmutableList.copyOf(getColumnHandles()));
}
Aggregations