This is an automated email from the ASF dual-hosted git repository. morningman pushed a commit to branch branch-1.2-lts in repository https://gitbox.apache.org/repos/asf/doris.git
commit cc139837665d6f1fb3403642978f7ecd09ecca57 Author: zhangstar333 <87313068+zhangstar...@users.noreply.github.com> AuthorDate: Fri Dec 16 10:48:17 2022 +0800 [vectorized](jdbc) fix external table of oracle with condition about … (#15092) * [vectorized](jdbc) fix external table of oracle with condition about datetime report error * formatter --- be/src/vec/exec/scan/new_jdbc_scan_node.cpp | 2 +- be/src/vec/exec/scan/new_jdbc_scanner.cpp | 7 ++++++- be/src/vec/exec/scan/new_jdbc_scanner.h | 2 +- be/src/vec/exec/scan/new_odbc_scan_node.cpp | 2 +- be/src/vec/exec/scan/new_odbc_scanner.cpp | 6 +++++- be/src/vec/exec/scan/new_odbc_scanner.h | 2 +- .../src/main/java/org/apache/doris/planner/OdbcScanNode.java | 8 ++++++++ 7 files changed, 23 insertions(+), 6 deletions(-) diff --git a/be/src/vec/exec/scan/new_jdbc_scan_node.cpp b/be/src/vec/exec/scan/new_jdbc_scan_node.cpp index e86060ad41..15ddd607ba 100644 --- a/be/src/vec/exec/scan/new_jdbc_scan_node.cpp +++ b/be/src/vec/exec/scan/new_jdbc_scan_node.cpp @@ -52,7 +52,7 @@ Status NewJdbcScanNode::_init_scanners(std::list<VScanner*>* scanners) { NewJdbcScanner* scanner = new NewJdbcScanner(_state, this, _limit_per_scanner, _tuple_id, _query_string); _scanner_pool.add(scanner); - RETURN_IF_ERROR(scanner->prepare(_state)); + RETURN_IF_ERROR(scanner->prepare(_state, _vconjunct_ctx_ptr.get())); scanners->push_back(static_cast<VScanner*>(scanner)); return Status::OK(); } diff --git a/be/src/vec/exec/scan/new_jdbc_scanner.cpp b/be/src/vec/exec/scan/new_jdbc_scanner.cpp index b91300bf47..ef9004530d 100644 --- a/be/src/vec/exec/scan/new_jdbc_scanner.cpp +++ b/be/src/vec/exec/scan/new_jdbc_scanner.cpp @@ -27,8 +27,13 @@ NewJdbcScanner::NewJdbcScanner(RuntimeState* state, NewJdbcScanNode* parent, int _query_string(query_string), _tuple_desc(nullptr) {} -Status NewJdbcScanner::prepare(RuntimeState* state) { +Status NewJdbcScanner::prepare(RuntimeState* state, VExprContext** vconjunct_ctx_ptr) { VLOG_CRITICAL << "NewJdbcScanner::Prepare"; + if (vconjunct_ctx_ptr != nullptr) { + // Copy vconjunct_ctx_ptr from scan node to this scanner's _vconjunct_ctx. + RETURN_IF_ERROR((*vconjunct_ctx_ptr)->clone(state, &_vconjunct_ctx)); + } + if (_is_init) { return Status::OK(); } diff --git a/be/src/vec/exec/scan/new_jdbc_scanner.h b/be/src/vec/exec/scan/new_jdbc_scanner.h index 24c2649dfe..f5584cd5d0 100644 --- a/be/src/vec/exec/scan/new_jdbc_scanner.h +++ b/be/src/vec/exec/scan/new_jdbc_scanner.h @@ -32,7 +32,7 @@ public: Status close(RuntimeState* state) override; public: - Status prepare(RuntimeState* state); + Status prepare(RuntimeState* state, VExprContext** vconjunct_ctx_ptr); protected: Status _get_block_impl(RuntimeState* state, Block* block, bool* eos) override; diff --git a/be/src/vec/exec/scan/new_odbc_scan_node.cpp b/be/src/vec/exec/scan/new_odbc_scan_node.cpp index 571566b88a..db8f8bfc68 100644 --- a/be/src/vec/exec/scan/new_odbc_scan_node.cpp +++ b/be/src/vec/exec/scan/new_odbc_scan_node.cpp @@ -53,7 +53,7 @@ Status NewOdbcScanNode::_init_scanners(std::list<VScanner*>* scanners) { } NewOdbcScanner* scanner = new NewOdbcScanner(_state, this, _limit_per_scanner, _odbc_scan_node); _scanner_pool.add(scanner); - RETURN_IF_ERROR(scanner->prepare(_state)); + RETURN_IF_ERROR(scanner->prepare(_state, _vconjunct_ctx_ptr.get())); scanners->push_back(static_cast<VScanner*>(scanner)); return Status::OK(); } diff --git a/be/src/vec/exec/scan/new_odbc_scanner.cpp b/be/src/vec/exec/scan/new_odbc_scanner.cpp index 59c94cf887..71b1a8d525 100644 --- a/be/src/vec/exec/scan/new_odbc_scanner.cpp +++ b/be/src/vec/exec/scan/new_odbc_scanner.cpp @@ -36,8 +36,12 @@ NewOdbcScanner::NewOdbcScanner(RuntimeState* state, NewOdbcScanNode* parent, int _tuple_id(odbc_scan_node.tuple_id), _tuple_desc(nullptr) {} -Status NewOdbcScanner::prepare(RuntimeState* state) { +Status NewOdbcScanner::prepare(RuntimeState* state, VExprContext** vconjunct_ctx_ptr) { VLOG_CRITICAL << NEW_SCANNER_TYPE << "::prepare"; + if (vconjunct_ctx_ptr != nullptr) { + // Copy vconjunct_ctx_ptr from scan node to this scanner's _vconjunct_ctx. + RETURN_IF_ERROR((*vconjunct_ctx_ptr)->clone(state, &_vconjunct_ctx)); + } if (_is_init) { return Status::OK(); diff --git a/be/src/vec/exec/scan/new_odbc_scanner.h b/be/src/vec/exec/scan/new_odbc_scanner.h index 0b8d28ed99..012fc8b3c1 100644 --- a/be/src/vec/exec/scan/new_odbc_scanner.h +++ b/be/src/vec/exec/scan/new_odbc_scanner.h @@ -34,7 +34,7 @@ public: Status close(RuntimeState* state) override; public: - Status prepare(RuntimeState* state); + Status prepare(RuntimeState* state, VExprContext** vconjunct_ctx_ptr); protected: Status _get_block_impl(RuntimeState* state, Block* block, bool* eos) override; diff --git a/fe/fe-core/src/main/java/org/apache/doris/planner/OdbcScanNode.java b/fe/fe-core/src/main/java/org/apache/doris/planner/OdbcScanNode.java index e3876c803b..bfec4e871f 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/planner/OdbcScanNode.java +++ b/fe/fe-core/src/main/java/org/apache/doris/planner/OdbcScanNode.java @@ -18,6 +18,7 @@ package org.apache.doris.planner; import org.apache.doris.analysis.Analyzer; +import org.apache.doris.analysis.DateLiteral; import org.apache.doris.analysis.Expr; import org.apache.doris.analysis.ExprSubstitutionMap; import org.apache.doris.analysis.FunctionCallExpr; @@ -53,6 +54,7 @@ public class OdbcScanNode extends ScanNode { // Now some database have different function call like doris, now doris do not // push down the function call except MYSQL + // TODO: maybe add a config to decide whether to pushdown the function of MYSQL public static boolean shouldPushDownConjunct(TOdbcTableType tableType, Expr expr) { if (!tableType.equals(TOdbcTableType.MYSQL)) { List<FunctionCallExpr> fnExprList = Lists.newArrayList(); @@ -60,6 +62,12 @@ public class OdbcScanNode extends ScanNode { if (!fnExprList.isEmpty()) { return false; } + //oracle date type is not push down https://github.com/apache/doris/discussions/15069 + //TODO: Now not sure how to rewrite the needed expr and doesn't affect other normal + //if we could rewrite the expr according to the format, then can pushdown this. + if (tableType.equals(TOdbcTableType.ORACLE) && expr.contains(DateLiteral.class)) { + return false; + } } return true; } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org