|
48 | 48 | import io.trino.plugin.jdbc.LongWriteFunction; |
49 | 49 | import io.trino.plugin.jdbc.ObjectReadFunction; |
50 | 50 | import io.trino.plugin.jdbc.ObjectWriteFunction; |
| 51 | +import io.trino.plugin.jdbc.PreparedQuery; |
51 | 52 | import io.trino.plugin.jdbc.QueryBuilder; |
52 | 53 | import io.trino.plugin.jdbc.RemoteTableName; |
53 | 54 | import io.trino.plugin.jdbc.SliceWriteFunction; |
|
74 | 75 | import io.trino.spi.connector.ColumnPosition; |
75 | 76 | import io.trino.spi.connector.ConnectorSession; |
76 | 77 | import io.trino.spi.connector.ConnectorTableMetadata; |
| 78 | +import io.trino.spi.connector.JoinStatistics; |
| 79 | +import io.trino.spi.connector.JoinType; |
77 | 80 | import io.trino.spi.expression.ConnectorExpression; |
78 | 81 | import io.trino.spi.expression.Variable; |
79 | 82 | import io.trino.spi.type.CharType; |
@@ -251,6 +254,13 @@ public ClickHouseClient( |
251 | 254 | .map("$not($is_null(value))").to("value IS NOT NULL") |
252 | 255 | .map("$not(value: boolean)").to("NOT value") |
253 | 256 | .map("$is_null(value)").to("value IS NULL") |
| 257 | + .map("$equal(left, right)").to("left = right") |
| 258 | + .map("$not_equal(left, right)").to("left <> right") |
| 259 | + .map("$less_than(left, right)").to("left < right") |
| 260 | + .map("$less_than_or_equal(left, right)").to("left <= right") |
| 261 | + .map("$greater_than(left, right)").to("left > right") |
| 262 | + .map("$greater_than_or_equal(left, right)").to("left >= right") |
| 263 | + .map("$operator$subscript(map, value)").to("map[value]") |
254 | 264 | .build(); |
255 | 265 | this.aggregateFunctionRewriter = new AggregateFunctionRewriter<>( |
256 | 266 | this.connectorExpressionRewriter, |
@@ -278,9 +288,36 @@ public Optional<JdbcExpression> implementAggregation(ConnectorSession session, A |
278 | 288 | @Override |
279 | 289 | public Optional<ParameterizedExpression> convertPredicate(ConnectorSession session, ConnectorExpression expression, Map<String, ColumnHandle> assignments) |
280 | 290 | { |
| 291 | + for (ColumnHandle columnHandle : assignments.values()) { |
| 292 | + JdbcColumnHandle jdbcColumnHandle = (JdbcColumnHandle) columnHandle; |
| 293 | + JdbcTypeHandle typeHandle = jdbcColumnHandle.getJdbcTypeHandle(); |
| 294 | + String jdbcTypeName = typeHandle.jdbcTypeName() |
| 295 | + .orElseThrow(() -> new TrinoException(JDBC_ERROR, "Type name is missing: " + typeHandle)); |
| 296 | + if (jdbcColumnHandle.getColumnType() instanceof VarcharType && |
| 297 | + getUnsupportedTypeHandling(session) == CONVERT_TO_VARCHAR && |
| 298 | + toColumnMapping(session, jdbcTypeName, typeHandle.jdbcType(), typeHandle.decimalDigits(), typeHandle.columnSize()).isEmpty()) { |
| 299 | + // Column is mapped to VARCHAR using unsupported type handling, predicate pushdown may not work properly |
| 300 | + return Optional.empty(); |
| 301 | + } |
| 302 | + } |
| 303 | + |
281 | 304 | return connectorExpressionRewriter.rewrite(session, expression, assignments); |
282 | 305 | } |
283 | 306 |
|
| 307 | + @Override |
| 308 | + public Optional<PreparedQuery> implementJoin( |
| 309 | + ConnectorSession session, |
| 310 | + JoinType joinType, |
| 311 | + PreparedQuery leftSource, |
| 312 | + Map<JdbcColumnHandle, String> leftProjections, |
| 313 | + PreparedQuery rightSource, |
| 314 | + Map<JdbcColumnHandle, String> rightProjections, |
| 315 | + List<ParameterizedExpression> joinConditions, |
| 316 | + JoinStatistics statistics) |
| 317 | + { |
| 318 | + return Optional.empty(); |
| 319 | + } |
| 320 | + |
284 | 321 | @Override |
285 | 322 | public boolean supportsTopN(ConnectorSession session, JdbcTableHandle handle, List<JdbcSortItem> sortOrder) |
286 | 323 | { |
|
0 commit comments