IMPALA-13018: Block push down of conjuncts with implicit casting on base columns for jdbc tables

The query of q80a consists BETWEEN with casting to timestamp in where
clause like:
  d_date between cast('2000-08-23' as timestamp)
    and (cast('2000-08-23' as timestamp) + interval 30 days)
Between predicate does cast all exprs to compatible types. Planner
generates predicates for DataSourceScanNode as:
  CAST(d_date AS TIMESTAMP) >= TIMESTAMP '2000-08-23 00:00:00',
  CAST(d_date AS TIMESTAMP) <= TIMESTAMP '2000-09-22 00:00:00'
But casting to Date/Timestamp for a column cannot be pushed down to JDBC
table now. This patch fixes the issue by blocking such conjuncts with
implicit unsafe casting or casting to date/timestamp to be added into
offered predicate list for JDBC table.
Note that explicit casting on base columns are not allowed to
pushdown.

Testing:
 - Add new planner unit-tests, including explicit casting, implicit
   casting to date/timestamp, built-in functions, arithmetic
   expressions.
   The predicates which are accepted for JDBC are shown in plan under
   "data source predicates" of DataSourceScanNode, predicates which
   are not accepted for JDBC are shown in plan under "predicates" of
   DataSourceScanNodes.
 - Passed all tpcds queries for JDBC tables, including q80a.
 - Passed core test

Change-Id: Iabd7e28b8d5f11f25a000dc4c9ab65895056b572
Reviewed-on: http://gerrit.cloudera.org:8080/21409
Reviewed-by: Riza Suminto <riza.suminto@cloudera.com>
Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
This commit is contained in:
wzhou-code
2024-05-07 00:19:28 -07:00
committed by Impala Public Jenkins
parent 68f8a6a1df
commit 3cbb3be5f7
5 changed files with 287 additions and 25 deletions

View File

@@ -1078,9 +1078,8 @@ class TestTpcdsQueryForJdbcTables(ImpalaTestSuite):
def test_tpcds_q80(self, vector):
self.run_test_case('tpcds-decimal_v2-q80', vector, use_db='tpcds_jdbc')
# TODO: IMPALA-13018 fix unmatched results for external JDBC tables.
# def test_tpcds_q80a(self, vector):
# self.run_test_case('tpcds-decimal_v2-q80a', vector, use_db='tpcds_jdbc')
def test_tpcds_q80a(self, vector):
self.run_test_case('tpcds-decimal_v2-q80a', vector, use_db='tpcds_jdbc')
def test_tpcds_q81(self, vector):
self.run_test_case('tpcds-decimal_v2-q81', vector, use_db='tpcds_jdbc')