diff --git a/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/BaseJdbcClient.java b/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/BaseJdbcClient.java index 699c84ecaa442..93f6c2f8967ef 100644 --- a/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/BaseJdbcClient.java +++ b/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/BaseJdbcClient.java @@ -764,46 +764,6 @@ public Optional implementJoin( } } - @Deprecated - @Override - public Optional legacyImplementJoin( - ConnectorSession session, - JoinType joinType, - PreparedQuery leftSource, - PreparedQuery rightSource, - List joinConditions, - Map rightAssignments, - Map leftAssignments, - JoinStatistics statistics) - { - for (JdbcJoinCondition joinCondition : joinConditions) { - if (!isSupportedJoinCondition(session, joinCondition)) { - return Optional.empty(); - } - } - - try (Connection connection = this.connectionFactory.openConnection(session)) { - return Optional.of(queryBuilder.legacyPrepareJoinQuery( - this, - session, - connection, - joinType, - leftSource, - rightSource, - joinConditions, - leftAssignments, - rightAssignments)); - } - catch (SQLException e) { - throw new TrinoException(JDBC_ERROR, e); - } - } - - protected boolean isSupportedJoinCondition(ConnectorSession session, JdbcJoinCondition joinCondition) - { - return false; - } - protected PreparedQuery applyQueryTransformations(JdbcTableHandle tableHandle, PreparedQuery query) { PreparedQuery preparedQuery = query; diff --git a/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/CachingJdbcClient.java b/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/CachingJdbcClient.java index cc5ddf6761fcd..db511e668c3ea 100644 --- a/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/CachingJdbcClient.java +++ b/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/CachingJdbcClient.java @@ -317,20 +317,6 @@ public Optional implementJoin( return delegate.implementJoin(session, joinType, leftSource, leftProjections, rightSource, rightProjections, joinConditions, statistics); } - @Override - public Optional legacyImplementJoin( - ConnectorSession session, - JoinType joinType, - PreparedQuery leftSource, - PreparedQuery rightSource, - List joinConditions, - Map rightAssignments, - Map leftAssignments, - JoinStatistics statistics) - { - return delegate.legacyImplementJoin(session, joinType, leftSource, rightSource, joinConditions, rightAssignments, leftAssignments, statistics); - } - @Override public boolean supportsTopN(ConnectorSession session, JdbcTableHandle handle, List sortOrder) { diff --git a/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/DefaultJdbcMetadata.java b/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/DefaultJdbcMetadata.java index af206e6d016da..8986dc74d73fb 100644 --- a/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/DefaultJdbcMetadata.java +++ b/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/DefaultJdbcMetadata.java @@ -43,7 +43,6 @@ import io.trino.spi.connector.Constraint; import io.trino.spi.connector.ConstraintApplicationResult; import io.trino.spi.connector.JoinApplicationResult; -import io.trino.spi.connector.JoinCondition; import io.trino.spi.connector.JoinStatistics; import io.trino.spi.connector.JoinType; import io.trino.spi.connector.LimitApplicationResult; @@ -728,101 +727,6 @@ public Optional> applyJoin( precalculateStatisticsForPushdown)); } - @Deprecated - @Override - public Optional> applyJoin( - ConnectorSession session, - JoinType joinType, - ConnectorTableHandle left, - ConnectorTableHandle right, - List joinConditions, - Map leftAssignments, - Map rightAssignments, - JoinStatistics statistics) - { - if (isTableHandleForProcedure(left) || isTableHandleForProcedure(right)) { - return Optional.empty(); - } - - if (!isJoinPushdownEnabled(session)) { - return Optional.empty(); - } - - JdbcTableHandle leftHandle = flushAttributesAsQuery(session, (JdbcTableHandle) left); - JdbcTableHandle rightHandle = flushAttributesAsQuery(session, (JdbcTableHandle) right); - - if (!leftHandle.getAuthorization().equals(rightHandle.getAuthorization())) { - return Optional.empty(); - } - int nextSyntheticColumnId = max(leftHandle.getNextSyntheticColumnId(), rightHandle.getNextSyntheticColumnId()); - - ImmutableMap.Builder newLeftColumnsBuilder = ImmutableMap.builder(); - OptionalInt maxColumnNameLength = jdbcClient.getMaxColumnNameLength(session); - for (JdbcColumnHandle column : jdbcClient.getColumns(session, leftHandle)) { - newLeftColumnsBuilder.put(column, createSyntheticJoinProjectionColumn(column, nextSyntheticColumnId, maxColumnNameLength)); - nextSyntheticColumnId++; - } - Map newLeftColumns = newLeftColumnsBuilder.buildOrThrow(); - - ImmutableMap.Builder newRightColumnsBuilder = ImmutableMap.builder(); - for (JdbcColumnHandle column : jdbcClient.getColumns(session, rightHandle)) { - newRightColumnsBuilder.put(column, createSyntheticJoinProjectionColumn(column, nextSyntheticColumnId, maxColumnNameLength)); - nextSyntheticColumnId++; - } - Map newRightColumns = newRightColumnsBuilder.buildOrThrow(); - - ImmutableList.Builder jdbcJoinConditions = ImmutableList.builder(); - for (JoinCondition joinCondition : joinConditions) { - Optional leftColumn = getVariableColumnHandle(leftAssignments, joinCondition.getLeftExpression()); - Optional rightColumn = getVariableColumnHandle(rightAssignments, joinCondition.getRightExpression()); - if (leftColumn.isEmpty() || rightColumn.isEmpty()) { - return Optional.empty(); - } - jdbcJoinConditions.add(new JdbcJoinCondition(leftColumn.get(), joinCondition.getOperator(), rightColumn.get())); - } - - Optional joinQuery = jdbcClient.legacyImplementJoin( - session, - joinType, - asPreparedQuery(leftHandle), - asPreparedQuery(rightHandle), - jdbcJoinConditions.build(), - newRightColumns.entrySet().stream() - .collect(toImmutableMap(Entry::getKey, entry -> entry.getValue().getColumnName())), - newLeftColumns.entrySet().stream() - .collect(toImmutableMap(Entry::getKey, entry -> entry.getValue().getColumnName())), - statistics); - - if (joinQuery.isEmpty()) { - return Optional.empty(); - } - - return Optional.of(new JoinApplicationResult<>( - new JdbcTableHandle( - new JdbcQueryRelationHandle(joinQuery.get()), - TupleDomain.all(), - ImmutableList.of(), - Optional.empty(), - OptionalLong.empty(), - Optional.of( - ImmutableList.builder() - .addAll(newLeftColumns.values()) - .addAll(newRightColumns.values()) - .build()), - leftHandle.getAllReferencedTables().flatMap(leftReferencedTables -> - rightHandle.getAllReferencedTables().map(rightReferencedTables -> - ImmutableSet.builder() - .addAll(leftReferencedTables) - .addAll(rightReferencedTables) - .build())), - nextSyntheticColumnId, - leftHandle.getAuthorization(), - leftHandle.getUpdateAssignments()), - ImmutableMap.copyOf(newLeftColumns), - ImmutableMap.copyOf(newRightColumns), - precalculateStatisticsForPushdown)); - } - @VisibleForTesting static JdbcColumnHandle createSyntheticJoinProjectionColumn(JdbcColumnHandle column, int nextSyntheticColumnId, OptionalInt optionalMaxColumnNameLength) { diff --git a/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/ForwardingJdbcClient.java b/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/ForwardingJdbcClient.java index 0439c3f037e2e..0c6ad06b5f7d1 100644 --- a/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/ForwardingJdbcClient.java +++ b/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/ForwardingJdbcClient.java @@ -240,20 +240,6 @@ public Optional implementJoin( return delegate().implementJoin(session, joinType, leftSource, leftProjections, rightSource, rightProjections, joinConditions, statistics); } - @Override - public Optional legacyImplementJoin( - ConnectorSession session, - JoinType joinType, - PreparedQuery leftSource, - PreparedQuery rightSource, - List joinConditions, - Map rightAssignments, - Map leftAssignments, - JoinStatistics statistics) - { - return delegate().legacyImplementJoin(session, joinType, leftSource, rightSource, joinConditions, rightAssignments, leftAssignments, statistics); - } - @Override public JdbcOutputTableHandle beginCreateTable(ConnectorSession session, ConnectorTableMetadata tableMetadata) { diff --git a/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/JdbcClient.java b/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/JdbcClient.java index 426065b3c93a4..a604a62e8b61e 100644 --- a/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/JdbcClient.java +++ b/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/JdbcClient.java @@ -144,17 +144,6 @@ Optional implementJoin( List joinConditions, JoinStatistics statistics); - @Deprecated - Optional legacyImplementJoin( - ConnectorSession session, - JoinType joinType, - PreparedQuery leftSource, - PreparedQuery rightSource, - List joinConditions, - Map rightAssignments, - Map leftAssignments, - JoinStatistics statistics); - boolean supportsTopN(ConnectorSession session, JdbcTableHandle handle, List sortOrder); /** diff --git a/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/RetryingJdbcClient.java b/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/RetryingJdbcClient.java index ac2fab50e744e..ac41edb5f3955 100644 --- a/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/RetryingJdbcClient.java +++ b/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/RetryingJdbcClient.java @@ -237,13 +237,6 @@ public Optional implementJoin(ConnectorSession session, JoinType return delegate.implementJoin(session, joinType, leftSource, leftProjections, rightSource, rightProjections, joinConditions, statistics); } - @Override - public Optional legacyImplementJoin(ConnectorSession session, JoinType joinType, PreparedQuery leftSource, PreparedQuery rightSource, List joinConditions, Map rightAssignments, Map leftAssignments, JoinStatistics statistics) - { - // there should be no remote database interaction - return delegate.legacyImplementJoin(session, joinType, leftSource, rightSource, joinConditions, rightAssignments, leftAssignments, statistics); - } - @Override public boolean supportsTopN(ConnectorSession session, JdbcTableHandle handle, List sortOrder) { diff --git a/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/jmx/StatisticsAwareJdbcClient.java b/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/jmx/StatisticsAwareJdbcClient.java index 95f350c78f804..c24ae1be00cd1 100644 --- a/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/jmx/StatisticsAwareJdbcClient.java +++ b/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/jmx/StatisticsAwareJdbcClient.java @@ -17,7 +17,6 @@ import io.trino.plugin.jdbc.JdbcClient; import io.trino.plugin.jdbc.JdbcColumnHandle; import io.trino.plugin.jdbc.JdbcExpression; -import io.trino.plugin.jdbc.JdbcJoinCondition; import io.trino.plugin.jdbc.JdbcOutputTableHandle; import io.trino.plugin.jdbc.JdbcProcedureHandle; import io.trino.plugin.jdbc.JdbcProcedureHandle.ProcedureQuery; @@ -261,19 +260,6 @@ public Optional implementJoin(ConnectorSession session, return stats.getImplementJoin().wrap(() -> delegate().implementJoin(session, joinType, leftSource, leftProjections, rightSource, rightProjections, joinConditions, statistics)); } - @Override - public Optional legacyImplementJoin(ConnectorSession session, - JoinType joinType, - PreparedQuery leftSource, - PreparedQuery rightSource, - List joinConditions, - Map rightAssignments, - Map leftAssignments, - JoinStatistics statistics) - { - return stats.getImplementJoin().wrap(() -> delegate().legacyImplementJoin(session, joinType, leftSource, rightSource, joinConditions, rightAssignments, leftAssignments, statistics)); - } - @Override public Optional getTableComment(ResultSet resultSet) throws SQLException diff --git a/plugin/trino-exasol/src/main/java/io/trino/plugin/exasol/ExasolClient.java b/plugin/trino-exasol/src/main/java/io/trino/plugin/exasol/ExasolClient.java index 93202b4a89a92..a5c01c10ed7f9 100644 --- a/plugin/trino-exasol/src/main/java/io/trino/plugin/exasol/ExasolClient.java +++ b/plugin/trino-exasol/src/main/java/io/trino/plugin/exasol/ExasolClient.java @@ -22,7 +22,6 @@ import io.trino.plugin.jdbc.ConnectionFactory; import io.trino.plugin.jdbc.JdbcColumnHandle; import io.trino.plugin.jdbc.JdbcExpression; -import io.trino.plugin.jdbc.JdbcJoinCondition; import io.trino.plugin.jdbc.JdbcOutputTableHandle; import io.trino.plugin.jdbc.JdbcTableHandle; import io.trino.plugin.jdbc.JdbcTypeHandle; @@ -184,13 +183,6 @@ protected void renameTable(ConnectorSession session, Connection connection, Stri throw new TrinoException(NOT_SUPPORTED, "This connector does not support renaming tables"); } - @Override - protected boolean isSupportedJoinCondition(ConnectorSession session, JdbcJoinCondition joinCondition) - { - // Deactivated because test 'testJoinPushdown()' requires write access which is not implemented for Exasol - return false; - } - @Override public Optional implementAggregation(ConnectorSession session, AggregateFunction aggregate, Map assignments) { diff --git a/plugin/trino-ignite/src/main/java/io/trino/plugin/ignite/IgniteClient.java b/plugin/trino-ignite/src/main/java/io/trino/plugin/ignite/IgniteClient.java index 34c8183d78868..7154db581671c 100644 --- a/plugin/trino-ignite/src/main/java/io/trino/plugin/ignite/IgniteClient.java +++ b/plugin/trino-ignite/src/main/java/io/trino/plugin/ignite/IgniteClient.java @@ -28,7 +28,6 @@ import io.trino.plugin.jdbc.ConnectionFactory; import io.trino.plugin.jdbc.JdbcColumnHandle; import io.trino.plugin.jdbc.JdbcExpression; -import io.trino.plugin.jdbc.JdbcJoinCondition; import io.trino.plugin.jdbc.JdbcOutputTableHandle; import io.trino.plugin.jdbc.JdbcSortItem; import io.trino.plugin.jdbc.JdbcTableHandle; @@ -592,31 +591,6 @@ public Optional implementJoin( return super.implementJoin(session, joinType, leftSource, leftProjections, rightSource, rightProjections, joinConditions, statistics); } - @Override - public Optional legacyImplementJoin( - ConnectorSession session, - JoinType joinType, - PreparedQuery leftSource, - PreparedQuery rightSource, - List joinConditions, - Map rightAssignments, - Map leftAssignments, - JoinStatistics statistics) - { - // Ignite does not support FULL JOIN - if (joinType == JoinType.FULL_OUTER) { - return Optional.empty(); - } - - return super.legacyImplementJoin(session, joinType, leftSource, rightSource, joinConditions, rightAssignments, leftAssignments, statistics); - } - - @Override - protected boolean isSupportedJoinCondition(ConnectorSession session, JdbcJoinCondition joinCondition) - { - return true; - } - @Override public void createSchema(ConnectorSession session, String schemaName) { diff --git a/plugin/trino-mariadb/src/main/java/io/trino/plugin/mariadb/MariaDbClient.java b/plugin/trino-mariadb/src/main/java/io/trino/plugin/mariadb/MariaDbClient.java index 6cf1446648c62..040910149b5de 100644 --- a/plugin/trino-mariadb/src/main/java/io/trino/plugin/mariadb/MariaDbClient.java +++ b/plugin/trino-mariadb/src/main/java/io/trino/plugin/mariadb/MariaDbClient.java @@ -28,7 +28,6 @@ import io.trino.plugin.jdbc.ConnectionFactory; import io.trino.plugin.jdbc.JdbcColumnHandle; import io.trino.plugin.jdbc.JdbcExpression; -import io.trino.plugin.jdbc.JdbcJoinCondition; import io.trino.plugin.jdbc.JdbcSortItem; import io.trino.plugin.jdbc.JdbcStatisticsConfig; import io.trino.plugin.jdbc.JdbcTableHandle; @@ -56,7 +55,6 @@ import io.trino.spi.connector.ColumnHandle; import io.trino.spi.connector.ConnectorSession; import io.trino.spi.connector.ConnectorTableMetadata; -import io.trino.spi.connector.JoinCondition; import io.trino.spi.connector.JoinStatistics; import io.trino.spi.connector.JoinType; import io.trino.spi.connector.SchemaTableName; @@ -662,38 +660,6 @@ public Optional implementJoin( return super.implementJoin(session, joinType, leftSource, leftProjections, rightSource, rightProjections, joinConditions, statistics); } - @Override - public Optional legacyImplementJoin( - ConnectorSession session, - JoinType joinType, - PreparedQuery leftSource, - PreparedQuery rightSource, - List joinConditions, - Map rightAssignments, - Map leftAssignments, - JoinStatistics statistics) - { - if (joinType == JoinType.FULL_OUTER) { - // Not supported in MariaDB - return Optional.empty(); - } - return super.legacyImplementJoin(session, joinType, leftSource, rightSource, joinConditions, rightAssignments, leftAssignments, statistics); - } - - @Override - protected boolean isSupportedJoinCondition(ConnectorSession session, JdbcJoinCondition joinCondition) - { - if (joinCondition.getOperator() == JoinCondition.Operator.IDENTICAL) { - // Not supported in MariaDB - return false; - } - - // Remote database can be case insensitive. - return Stream.of(joinCondition.getLeftColumn(), joinCondition.getRightColumn()) - .map(JdbcColumnHandle::getColumnType) - .noneMatch(type -> type instanceof CharType || type instanceof VarcharType); - } - @Override public TableStatistics getTableStatistics(ConnectorSession session, JdbcTableHandle handle) { diff --git a/plugin/trino-mysql/src/main/java/io/trino/plugin/mysql/MySqlClient.java b/plugin/trino-mysql/src/main/java/io/trino/plugin/mysql/MySqlClient.java index a79c43123f7fa..3f3d5cff0ca3f 100644 --- a/plugin/trino-mysql/src/main/java/io/trino/plugin/mysql/MySqlClient.java +++ b/plugin/trino-mysql/src/main/java/io/trino/plugin/mysql/MySqlClient.java @@ -33,7 +33,6 @@ import io.trino.plugin.jdbc.ConnectionFactory; import io.trino.plugin.jdbc.JdbcColumnHandle; import io.trino.plugin.jdbc.JdbcExpression; -import io.trino.plugin.jdbc.JdbcJoinCondition; import io.trino.plugin.jdbc.JdbcSortItem; import io.trino.plugin.jdbc.JdbcStatisticsConfig; import io.trino.plugin.jdbc.JdbcTableHandle; @@ -68,7 +67,6 @@ import io.trino.spi.connector.ColumnMetadata; import io.trino.spi.connector.ConnectorSession; import io.trino.spi.connector.ConnectorTableMetadata; -import io.trino.spi.connector.JoinCondition; import io.trino.spi.connector.JoinStatistics; import io.trino.spi.connector.JoinType; import io.trino.spi.connector.SchemaTableName; @@ -1041,44 +1039,6 @@ public Optional implementJoin( () -> super.implementJoin(session, joinType, leftSource, leftProjections, rightSource, rightProjections, joinConditions, statistics)); } - @Override - public Optional legacyImplementJoin( - ConnectorSession session, - JoinType joinType, - PreparedQuery leftSource, - PreparedQuery rightSource, - List joinConditions, - Map rightAssignments, - Map leftAssignments, - JoinStatistics statistics) - { - if (joinType == JoinType.FULL_OUTER) { - // Not supported in MySQL - return Optional.empty(); - } - return implementJoinCostAware( - session, - joinType, - leftSource, - rightSource, - statistics, - () -> super.legacyImplementJoin(session, joinType, leftSource, rightSource, joinConditions, rightAssignments, leftAssignments, statistics)); - } - - @Override - protected boolean isSupportedJoinCondition(ConnectorSession session, JdbcJoinCondition joinCondition) - { - if (joinCondition.getOperator() == JoinCondition.Operator.IDENTICAL) { - // Not supported in MySQL - return false; - } - - // Remote database can be case insensitive. - return Stream.of(joinCondition.getLeftColumn(), joinCondition.getRightColumn()) - .map(JdbcColumnHandle::getColumnType) - .noneMatch(type -> type instanceof CharType || type instanceof VarcharType); - } - @Override public TableStatistics getTableStatistics(ConnectorSession session, JdbcTableHandle handle) { diff --git a/plugin/trino-oracle/src/main/java/io/trino/plugin/oracle/OracleClient.java b/plugin/trino-oracle/src/main/java/io/trino/plugin/oracle/OracleClient.java index 3691e141a0302..378b71d5554ac 100644 --- a/plugin/trino-oracle/src/main/java/io/trino/plugin/oracle/OracleClient.java +++ b/plugin/trino-oracle/src/main/java/io/trino/plugin/oracle/OracleClient.java @@ -31,7 +31,6 @@ import io.trino.plugin.jdbc.DoubleWriteFunction; import io.trino.plugin.jdbc.JdbcColumnHandle; import io.trino.plugin.jdbc.JdbcExpression; -import io.trino.plugin.jdbc.JdbcJoinCondition; import io.trino.plugin.jdbc.JdbcTableHandle; import io.trino.plugin.jdbc.JdbcTypeHandle; import io.trino.plugin.jdbc.LongReadFunction; @@ -63,7 +62,6 @@ import io.trino.spi.connector.ColumnHandle; import io.trino.spi.connector.ConnectorSession; import io.trino.spi.connector.ConnectorTableMetadata; -import io.trino.spi.connector.JoinCondition; import io.trino.spi.expression.ConnectorExpression; import io.trino.spi.type.CharType; import io.trino.spi.type.DecimalType; @@ -591,12 +589,6 @@ public boolean isLimitGuaranteed(ConnectorSession session) return true; } - @Override - protected boolean isSupportedJoinCondition(ConnectorSession session, JdbcJoinCondition joinCondition) - { - return joinCondition.getOperator() != JoinCondition.Operator.IDENTICAL; - } - public static LongWriteFunction trinoDateToOracleDateWriteFunction() { return new LongWriteFunction() diff --git a/plugin/trino-postgresql/src/main/java/io/trino/plugin/postgresql/PostgreSqlClient.java b/plugin/trino-postgresql/src/main/java/io/trino/plugin/postgresql/PostgreSqlClient.java index 5af9843c79457..4789afefb8b67 100644 --- a/plugin/trino-postgresql/src/main/java/io/trino/plugin/postgresql/PostgreSqlClient.java +++ b/plugin/trino-postgresql/src/main/java/io/trino/plugin/postgresql/PostgreSqlClient.java @@ -34,7 +34,6 @@ import io.trino.plugin.jdbc.DoubleReadFunction; import io.trino.plugin.jdbc.JdbcColumnHandle; import io.trino.plugin.jdbc.JdbcExpression; -import io.trino.plugin.jdbc.JdbcJoinCondition; import io.trino.plugin.jdbc.JdbcSortItem; import io.trino.plugin.jdbc.JdbcStatisticsConfig; import io.trino.plugin.jdbc.JdbcTableHandle; @@ -85,7 +84,6 @@ import io.trino.spi.connector.ColumnHandle; import io.trino.spi.connector.ConnectorSession; import io.trino.spi.connector.ConnectorTableMetadata; -import io.trino.spi.connector.JoinCondition; import io.trino.spi.connector.JoinStatistics; import io.trino.spi.connector.JoinType; import io.trino.spi.connector.SchemaTableName; @@ -140,7 +138,6 @@ import java.util.UUID; import java.util.function.BiFunction; import java.util.function.Predicate; -import java.util.stream.Stream; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Throwables.throwIfInstanceOf; @@ -1113,48 +1110,6 @@ public Optional implementJoin( () -> super.implementJoin(session, joinType, leftSource, leftProjections, rightSource, rightProjections, joinConditions, statistics)); } - @Override - public Optional legacyImplementJoin( - ConnectorSession session, - JoinType joinType, - PreparedQuery leftSource, - PreparedQuery rightSource, - List joinConditions, - Map rightAssignments, - Map leftAssignments, - JoinStatistics statistics) - { - if (joinType == JoinType.FULL_OUTER) { - // FULL JOIN is only supported with merge-joinable or hash-joinable join conditions - return Optional.empty(); - } - return implementJoinCostAware( - session, - joinType, - leftSource, - rightSource, - statistics, - () -> super.legacyImplementJoin(session, joinType, leftSource, rightSource, joinConditions, rightAssignments, leftAssignments, statistics)); - } - - @Override - protected boolean isSupportedJoinCondition(ConnectorSession session, JdbcJoinCondition joinCondition) - { - boolean isVarchar = Stream.of(joinCondition.getLeftColumn(), joinCondition.getRightColumn()) - .map(JdbcColumnHandle::getColumnType) - .anyMatch(type -> type instanceof CharType || type instanceof VarcharType); - if (isVarchar) { - // PostgreSQL is case sensitive by default, but orders varchars differently - JoinCondition.Operator operator = joinCondition.getOperator(); - return switch (operator) { - case LESS_THAN, LESS_THAN_OR_EQUAL, GREATER_THAN, GREATER_THAN_OR_EQUAL -> isEnableStringPushdownWithCollate(session); - case EQUAL, NOT_EQUAL, IDENTICAL -> true; - }; - } - - return true; - } - @Override protected void verifySchemaName(DatabaseMetaData databaseMetadata, String schemaName) throws SQLException diff --git a/plugin/trino-redshift/src/main/java/io/trino/plugin/redshift/RedshiftClient.java b/plugin/trino-redshift/src/main/java/io/trino/plugin/redshift/RedshiftClient.java index d8fc2991eea8c..d1d9472c7bb7c 100644 --- a/plugin/trino-redshift/src/main/java/io/trino/plugin/redshift/RedshiftClient.java +++ b/plugin/trino-redshift/src/main/java/io/trino/plugin/redshift/RedshiftClient.java @@ -32,7 +32,6 @@ import io.trino.plugin.jdbc.ConnectionFactory; import io.trino.plugin.jdbc.JdbcColumnHandle; import io.trino.plugin.jdbc.JdbcExpression; -import io.trino.plugin.jdbc.JdbcJoinCondition; import io.trino.plugin.jdbc.JdbcSortItem; import io.trino.plugin.jdbc.JdbcSplit; import io.trino.plugin.jdbc.JdbcStatisticsConfig; @@ -68,7 +67,6 @@ import io.trino.spi.connector.ColumnMetadata; import io.trino.spi.connector.ConnectorSession; import io.trino.spi.connector.ConnectorTableMetadata; -import io.trino.spi.connector.JoinCondition; import io.trino.spi.connector.JoinStatistics; import io.trino.spi.connector.JoinType; import io.trino.spi.expression.ConnectorExpression; @@ -426,12 +424,6 @@ public boolean isTopNGuaranteed(ConnectorSession session) return true; } - @Override - protected boolean isSupportedJoinCondition(ConnectorSession session, JdbcJoinCondition joinCondition) - { - return joinCondition.getOperator() != JoinCondition.Operator.IDENTICAL; - } - @Override public Optional implementJoin(ConnectorSession session, JoinType joinType, @@ -455,29 +447,6 @@ public Optional implementJoin(ConnectorSession session, () -> super.implementJoin(session, joinType, leftSource, leftProjections, rightSource, rightProjections, joinConditions, statistics)); } - @Override - public Optional legacyImplementJoin(ConnectorSession session, - JoinType joinType, - PreparedQuery leftSource, - PreparedQuery rightSource, - List joinConditions, - Map rightAssignments, - Map leftAssignments, - JoinStatistics statistics) - { - if (joinType == JoinType.FULL_OUTER) { - // FULL JOIN is only supported with merge-joinable or hash-joinable join conditions - return Optional.empty(); - } - return implementJoinCostAware( - session, - joinType, - leftSource, - rightSource, - statistics, - () -> super.legacyImplementJoin(session, joinType, leftSource, rightSource, joinConditions, rightAssignments, leftAssignments, statistics)); - } - @Override protected void renameTable(ConnectorSession session, Connection connection, String catalogName, String remoteSchemaName, String remoteTableName, String newRemoteSchemaName, String newRemoteTableName) throws SQLException diff --git a/plugin/trino-singlestore/src/main/java/io/trino/plugin/singlestore/SingleStoreClient.java b/plugin/trino-singlestore/src/main/java/io/trino/plugin/singlestore/SingleStoreClient.java index e0784159039c4..31a0c62ed3c9e 100644 --- a/plugin/trino-singlestore/src/main/java/io/trino/plugin/singlestore/SingleStoreClient.java +++ b/plugin/trino-singlestore/src/main/java/io/trino/plugin/singlestore/SingleStoreClient.java @@ -23,7 +23,6 @@ import io.trino.plugin.jdbc.ColumnMapping; import io.trino.plugin.jdbc.ConnectionFactory; import io.trino.plugin.jdbc.JdbcColumnHandle; -import io.trino.plugin.jdbc.JdbcJoinCondition; import io.trino.plugin.jdbc.JdbcSortItem; import io.trino.plugin.jdbc.JdbcTableHandle; import io.trino.plugin.jdbc.JdbcTypeHandle; @@ -41,7 +40,6 @@ import io.trino.spi.connector.AggregateFunction; import io.trino.spi.connector.ColumnHandle; import io.trino.spi.connector.ConnectorSession; -import io.trino.spi.connector.JoinCondition; import io.trino.spi.connector.JoinStatistics; import io.trino.spi.connector.JoinType; import io.trino.spi.connector.SchemaTableName; @@ -640,38 +638,6 @@ public Optional implementJoin( return super.implementJoin(session, joinType, leftSource, leftProjections, rightSource, rightProjections, joinConditions, statistics); } - @Override - public Optional legacyImplementJoin( - ConnectorSession session, - JoinType joinType, - PreparedQuery leftSource, - PreparedQuery rightSource, - List joinConditions, - Map rightAssignments, - Map leftAssignments, - JoinStatistics statistics) - { - if (joinType == JoinType.FULL_OUTER) { - // Not supported in SingleStore - return Optional.empty(); - } - return super.legacyImplementJoin(session, joinType, leftSource, rightSource, joinConditions, rightAssignments, leftAssignments, statistics); - } - - @Override - protected boolean isSupportedJoinCondition(ConnectorSession session, JdbcJoinCondition joinCondition) - { - if (joinCondition.getOperator() == JoinCondition.Operator.IDENTICAL) { - // Not supported in SingleStore - return false; - } - - // Remote database can be case insensitive. - return Stream.of(joinCondition.getLeftColumn(), joinCondition.getRightColumn()) - .map(JdbcColumnHandle::getColumnType) - .noneMatch(type -> type instanceof CharType || type instanceof VarcharType); - } - private static Optional getUnsignedMapping(JdbcTypeHandle typeHandle) { if (typeHandle.jdbcTypeName().isEmpty()) { diff --git a/plugin/trino-sqlserver/src/main/java/io/trino/plugin/sqlserver/SqlServerClient.java b/plugin/trino-sqlserver/src/main/java/io/trino/plugin/sqlserver/SqlServerClient.java index 396880e75da37..a2fd2c867b3f7 100644 --- a/plugin/trino-sqlserver/src/main/java/io/trino/plugin/sqlserver/SqlServerClient.java +++ b/plugin/trino-sqlserver/src/main/java/io/trino/plugin/sqlserver/SqlServerClient.java @@ -38,7 +38,6 @@ import io.trino.plugin.jdbc.ConnectionFactory; import io.trino.plugin.jdbc.JdbcColumnHandle; import io.trino.plugin.jdbc.JdbcExpression; -import io.trino.plugin.jdbc.JdbcJoinCondition; import io.trino.plugin.jdbc.JdbcOutputTableHandle; import io.trino.plugin.jdbc.JdbcProcedureHandle; import io.trino.plugin.jdbc.JdbcProcedureHandle.ProcedureQuery; @@ -71,7 +70,6 @@ import io.trino.spi.connector.ColumnHandle; import io.trino.spi.connector.ConnectorSession; import io.trino.spi.connector.ConnectorTableMetadata; -import io.trino.spi.connector.JoinCondition; import io.trino.spi.connector.JoinStatistics; import io.trino.spi.connector.JoinType; import io.trino.spi.connector.TableNotFoundException; @@ -913,26 +911,6 @@ public Optional implementJoin( () -> super.implementJoin(session, joinType, leftSource, leftProjections, rightSource, rightProjections, joinConditions, statistics)); } - @Override - public Optional legacyImplementJoin( - ConnectorSession session, - JoinType joinType, - PreparedQuery leftSource, - PreparedQuery rightSource, - List joinConditions, - Map rightAssignments, - Map leftAssignments, - JoinStatistics statistics) - { - return implementJoinCostAware( - session, - joinType, - leftSource, - rightSource, - statistics, - () -> super.legacyImplementJoin(session, joinType, leftSource, rightSource, joinConditions, rightAssignments, leftAssignments, statistics)); - } - private LongWriteFunction sqlServerTimeWriteFunction(int precision) { return new LongWriteFunction() @@ -1114,34 +1092,6 @@ public boolean isTopNGuaranteed(ConnectorSession session) return true; } - @Override - protected boolean isSupportedJoinCondition(ConnectorSession session, JdbcJoinCondition joinCondition) - { - if (joinCondition.getOperator() == JoinCondition.Operator.IDENTICAL) { - // Not supported in SQL Server - return false; - } - - boolean isVarcharJoinColumn = Stream.of(joinCondition.getLeftColumn(), joinCondition.getRightColumn()) - .map(JdbcColumnHandle::getColumnType) - .allMatch(type -> type instanceof CharType || type instanceof VarcharType); - if (isVarcharJoinColumn) { - JoinCondition.Operator operator = joinCondition.getOperator(); - return switch (operator) { - case LESS_THAN, LESS_THAN_OR_EQUAL, GREATER_THAN, GREATER_THAN_OR_EQUAL -> false; - case EQUAL, NOT_EQUAL -> isCaseSensitiveVarchar(joinCondition.getLeftColumn()) && isCaseSensitiveVarchar(joinCondition.getRightColumn()); - default -> false; - }; - } - - return true; - } - - private boolean isCaseSensitiveVarchar(JdbcColumnHandle columnHandle) - { - return columnHandle.getJdbcTypeHandle().caseSensitivity().orElse(CASE_INSENSITIVE) == CASE_SENSITIVE; - } - @Override protected List createTableSqls(RemoteTableName remoteTableName, List columns, ConnectorTableMetadata tableMetadata) {