Skip to content

Commit

Permalink
[fix](jdbc catalog) fix handle oracle date format (apache#25487)
Browse files Browse the repository at this point in the history
  • Loading branch information
zy-kkk authored Oct 17, 2023
1 parent 8c5af5a commit 652d6c5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import org.apache.doris.catalog.Column;
import org.apache.doris.catalog.Env;
import org.apache.doris.catalog.JdbcTable;
import org.apache.doris.catalog.Type;
import org.apache.doris.catalog.external.JdbcExternalTable;
import org.apache.doris.common.AnalysisException;
import org.apache.doris.common.Config;
Expand Down Expand Up @@ -364,7 +363,7 @@ public static String conjunctExprToString(TOdbcTableType tableType, Expr expr) {

private static String handleOracleDateFormat(Expr expr) {
if (expr.isConstant()
&& (expr.getType().equals(Type.DATETIME) || expr.getType().equals(Type.DATETIMEV2))) {
&& (expr.getType().isDatetime() || expr.getType().isDatetimeV2())) {
return "to_date('" + expr.getStringValue() + "', 'yyyy-mm-dd hh24:mi:ss')";
}
return expr.toMySql();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@
1 2022-01-21T05:23:01 \N \N
2 2022-11-12T20:32:56 \N \N

-- !date7 --
3 \N 2019-11-12T20:33:57.999 \N \N \N \N \N

-- !test_insert1 --
doris1 18

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ suite("test_oracle_jdbc_catalog", "p0,external,oracle,external_docker,external_d
order_qt_date4 """ select * from TEST_DATE where (T1 > '2022-01-21 00:00:00' and T1 < '2022-01-22 00:00:00') or (T1 > '2022-01-20 00:00:00' and T1 < '2022-01-23 00:00:00'); """
order_qt_date5 """ select * from TEST_DATE where T1 < '2022-01-22 00:00:00' or T1 = '2022-01-21 05:23:01'; """
order_qt_date6 """ select * from TEST_DATE where (T1 < '2022-01-22 00:00:00' or T1 > '2022-01-20 00:00:00') and (T1 < '2022-01-23 00:00:00' or T1 > '2022-01-19 00:00:00'); """
order_qt_date7 """select * from TEST_TIMESTAMP where T2 < str_to_date('2020-12-21 12:34:56', '%Y-%m-%d %H:%i:%s');"""

// The result of TEST_RAW will change
// So instead of qt, we're using sql here.
Expand Down

0 comments on commit 652d6c5

Please sign in to comment.