ClickHouse/clickhouse-jdbc-bridge

The Datetime and Date of oracle will be effected by timezone.

Gowa2017 opened this issue · 1 comments

My clickhouse timezone is:

┌───────────────now()─┬─timezone()────┐
│ 2022-03-18 16:45:03 │ Asia/Shanghai │
└─────────────────────┴───────────────┘

My System timedatectl is:

timedatectl
      Local time: Fri 2022-03-18 16:45:37 CST
  Universal time: Fri 2022-03-18 08:45:37 UTC
        RTC time: Fri 2022-03-18 08:45:37
       Time zone: Asia/Shanghai (CST, +0800)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: n/a

My Oracle Field type

 STARTTIME				   NOT NULL DATE
 STOPTIME				   NOT NULL DATE

I run select in clickhouse:

select toDateTime(D, 'Asia/Shanghai') from  jdbc('jdbc:oracle:thin:xxx/yyy@//192.168.10.170:1521/ggg','select sysdate as d from dual')
┌─toDateTime(D, 'Asia/Shanghai')─┐
│            2022-03-19 00:48:54 │
└────────────────────────────────┘

Oracle timezone:

SELECT *
FROM jdbc('jdbc:oracle:thin:xxx/yyy@//192.168.10.170:1521/ggg, 'select  sessiontimezone,dbtimezone from dual');
┌─SESSIONTIMEZONE─┬─DBTIMEZONE─┐
│ Asia/Shanghai   │ +00:00     │
└─────────────────┴────────────┘

So, how can I get the same output of the datetime.

I kown why, oracle date and datetime had no concept of timezone, so the date data is correct, and I must use to_char in oracle to convert it to string.