[improvement](oracle jdbc)Support for automatically obtaining the precision of the oracle timestamp type (#21252)

This commit is contained in:
zy-kkk
2023-06-28 00:19:01 +08:00
committed by GitHub
parent db7eaad3cf
commit d871df64ca
4 changed files with 27 additions and 20 deletions

View File

@ -72,11 +72,12 @@ t3 interval day(3) to second(6)
create table doris_test.test_timestamp(
id int,
t1 date,
t2 timestamp(6),
t3 timestamp(9),
t4 timestamp,
t5 interval year(3) to month,
t6 interval day(3) to second(6)
t2 timestamp(3),
t3 timestamp(6),
t4 timestamp(9),
t5 timestamp,
t6 interval year(3) to month,
t7 interval day(3) to second(6)
);
create table doris_test.test_insert(

View File

@ -47,12 +47,13 @@ insert into doris_test.test_date (id, t3) values (5, interval '12 10:23:01.12345
insert into doris_test.test_timestamp (id, t1) values (1, to_date('2013-1-21 5:23:01','yyyy-mm-dd hh24:mi:ss'));
insert into doris_test.test_timestamp (id, t1) values (2, to_date('20131112203256', 'yyyymmddhh24miss'));
insert into doris_test.test_timestamp (id, t2) values (3, to_timestamp('20191112203357.999997623', 'yyyymmddhh24miss.ff'));
insert into doris_test.test_timestamp (id, t3) values (4, to_timestamp_tz('20191112203357.999996623', 'yyyymmddhh24miss.ff'));
insert into doris_test.test_timestamp (id, t2) values (3, to_timestamp('20191112203357.999', 'yyyymmddhh24miss.ff'));
insert into doris_test.test_timestamp (id, t3) values (4, to_timestamp('20191112203357.999997623', 'yyyymmddhh24miss.ff'));
insert into doris_test.test_timestamp (id, t4) values (5, to_timestamp_tz('20191112203357.999996623', 'yyyymmddhh24miss.ff'));
insert into doris_test.test_timestamp (id, t5) values (6, interval '11' year);
insert into doris_test.test_timestamp (id, t5) values (7, interval '223-9' year(3) to month);
insert into doris_test.test_timestamp (id, t6) values (8, interval '12 10:23:01.1234568' day to second);
insert into doris_test.test_timestamp (id, t5) values (6, to_timestamp_tz('20191112203357.999996623', 'yyyymmddhh24miss.ff'));
insert into doris_test.test_timestamp (id, t6) values (7, interval '11' year);
insert into doris_test.test_timestamp (id, t6) values (8, interval '223-9' year(3) to month);
insert into doris_test.test_timestamp (id, t7) values (9, interval '12 10:23:01.1234568' day to second);
insert into doris_test.test_number values (1, 123.45, 12345, 0.0012345);
insert into doris_test.test_number values (2, 123.45, 12345, 0.0099999);

View File

@ -47,11 +47,15 @@ public class JdbcOracleClient extends JdbcClient {
if (oracleType.startsWith("INTERVAL")) {
oracleType = oracleType.substring(0, 8);
} else if (oracleType.startsWith("TIMESTAMP")) {
if (oracleType.equals("TIMESTAMPTZ") || oracleType.equals("TIMESTAMPLTZ")) {
if (oracleType.contains("TIME ZONE") || oracleType.contains("LOCAL TIME ZONE")) {
return Type.UNSUPPORTED;
}
// oracle can support nanosecond, will lose precision
return ScalarType.createDatetimeV2Type(JDBC_DATETIME_SCALE);
int scale = fieldSchema.getDecimalDigits();
if (scale > 6) {
scale = 6;
}
return ScalarType.createDatetimeV2Type(scale);
}
switch (oracleType) {
/**

View File

@ -32,14 +32,15 @@
5 \N \N 12 10:23:1.123457
-- !test6 --
1 2013-01-21T05:23:01 \N \N \N \N \N
2 2013-11-12T20:32:56 \N \N \N \N \N
3 \N 2019-11-12T20:33:57.999998 \N \N \N \N
4 \N \N 2019-11-12T20:33:57.999996 \N \N \N
5 \N \N \N 2019-11-12T20:33:57.999997 \N \N
6 \N \N \N \N 11-0 \N
7 \N \N \N \N 223-9 \N
8 \N \N \N \N \N 12 10:23:1.123457
1 2013-01-21T05:23:01 \N \N \N \N \N \N
2 2013-11-12T20:32:56 \N \N \N \N \N \N
3 \N 2019-11-12T20:33:57.999 \N \N \N \N \N
4 \N \N 2019-11-12T20:33:57.999998 \N \N \N \N
5 \N \N \N 2019-11-12T20:33:57.999996 \N \N \N
6 \N \N \N \N 2019-11-12T20:33:57.999997 \N \N
7 \N \N \N \N \N 11-0 \N
8 \N \N \N \N \N 223-9 \N
9 \N \N \N \N \N \N 12 10:23:1.123457
-- !test7 --
1 123.45 12300 0.0012345