use of io.trino.plugin.jdbc.JdbcTableHandle in project trino by trinodb.
the class PhoenixMetadata method beginInsert.
@Override
public ConnectorInsertTableHandle beginInsert(ConnectorSession session, ConnectorTableHandle tableHandle, List<ColumnHandle> columns) {
JdbcTableHandle handle = (JdbcTableHandle) tableHandle;
Optional<String> rowkeyColumn = phoenixClient.getColumns(session, handle).stream().map(JdbcColumnHandle::getColumnName).filter(ROWKEY::equalsIgnoreCase).findFirst();
List<JdbcColumnHandle> columnHandles = columns.stream().map(JdbcColumnHandle.class::cast).collect(toImmutableList());
return new PhoenixOutputTableHandle(handle.getSchemaName(), handle.getTableName(), columnHandles.stream().map(JdbcColumnHandle::getColumnName).collect(toImmutableList()), columnHandles.stream().map(JdbcColumnHandle::getColumnType).collect(toImmutableList()), Optional.of(columnHandles.stream().map(JdbcColumnHandle::getJdbcTypeHandle).collect(toImmutableList())), rowkeyColumn);
}
use of io.trino.plugin.jdbc.JdbcTableHandle in project trino by trinodb.
the class PhoenixMetadata method dropColumn.
@Override
public void dropColumn(ConnectorSession session, ConnectorTableHandle tableHandle, ColumnHandle column) {
JdbcTableHandle handle = (JdbcTableHandle) tableHandle;
JdbcColumnHandle columnHandle = (JdbcColumnHandle) column;
phoenixClient.execute(session, format("ALTER TABLE %s DROP COLUMN %s", getEscapedTableName(handle.getSchemaName(), handle.getTableName()), columnHandle.getColumnName()));
}
use of io.trino.plugin.jdbc.JdbcTableHandle in project trino by trinodb.
the class TestPostgreSqlConnectorTest method testStringPushdownWithCollate.
@Test
public void testStringPushdownWithCollate() {
Session session = Session.builder(getSession()).setCatalogSessionProperty("postgresql", "enable_string_pushdown_with_collate", "true").build();
// varchar range
assertThat(query(session, "SELECT regionkey, nationkey, name FROM nation WHERE name BETWEEN 'POLAND' AND 'RPA'")).matches("VALUES (BIGINT '3', BIGINT '19', CAST('ROMANIA' AS varchar(25)))").isFullyPushedDown();
// varchar IN with small compaction threshold
assertThat(query(Session.builder(session).setCatalogSessionProperty("postgresql", "domain_compaction_threshold", "1").build(), "SELECT regionkey, nationkey, name FROM nation WHERE name IN ('POLAND', 'ROMANIA', 'VIETNAM')")).matches("VALUES " + "(BIGINT '3', BIGINT '19', CAST('ROMANIA' AS varchar(25))), " + "(BIGINT '2', BIGINT '21', CAST('VIETNAM' AS varchar(25)))").isNotFullyPushedDown(node(FilterNode.class, tableScan(tableHandle -> {
TupleDomain<ColumnHandle> constraint = ((JdbcTableHandle) tableHandle).getConstraint();
ColumnHandle nameColumn = constraint.getDomains().orElseThrow().keySet().stream().map(JdbcColumnHandle.class::cast).filter(column -> column.getColumnName().equals("name")).collect(onlyElement());
return constraint.getDomains().get().get(nameColumn).getValues().getRanges().getOrderedRanges().equals(ImmutableList.of(Range.range(createVarcharType(25), utf8Slice("POLAND"), true, utf8Slice("VIETNAM"), true)));
}, TupleDomain.all(), ImmutableMap.of())));
// varchar predicate over join
Session joinPushdownEnabled = joinPushdownEnabled(session);
assertThat(query(joinPushdownEnabled, "SELECT c.name, n.name FROM customer c JOIN nation n ON c.custkey = n.nationkey WHERE address < 'TcGe5gaZNgVePxU5kRrvXBfkasDTea'")).isFullyPushedDown();
// join on varchar columns is not pushed down
assertThat(query(joinPushdownEnabled, "SELECT c.name, n.name FROM customer c JOIN nation n ON c.address = n.name")).isNotFullyPushedDown(node(JoinNode.class, anyTree(node(TableScanNode.class)), anyTree(node(TableScanNode.class))));
}
Aggregations