Skip to content
Snippets Groups Projects
Unverified Commit d74271b0 authored by github-automation-metabase's avatar github-automation-metabase Committed by GitHub
Browse files

Map Oracle DATE to type/DateTime (#49592) (#49840)


* Map Oracle DATE to type/DateTime

* Modify test

* Add test

Co-authored-by: default avatarlbrdnk <lbrdnk@users.noreply.github.com>
parent d757d0b1
No related branches found
No related tags found
No related merge requests found
......@@ -58,7 +58,9 @@
[#"RAW" :type/*]
[#"CHAR" :type/Text]
[#"CLOB" :type/OracleCLOB]
[#"DATE" :type/Date]
;; Yes, the DATE is mapped to `:type/DateTime`. Oracle's DATE can store also a time part.
;; See the docs - https://docs.oracle.com/en/database/oracle/oracle-database/19/nlspg/datetime-data-types-and-time-zone-support.html#GUID-3A1B7AC6-2EDB-4DDC-9C9D-223D4C72AC74
[#"DATE" :type/DateTime]
[#"DOUBLE" :type/Float]
;; Expression filter type
[#"^EXPRESSION" :type/*]
......
......@@ -511,3 +511,36 @@
(mt/with-native-query-testing-context query
(is (= (t/zoned-date-time (u.date/parse test-date) report-tz)
(ffirst (mt/rows (qp/process-query query))))))))))))))
(mt/defdataset date-cols-with-datetime-values
[["dates_with_time" [{:field-name "date_with_time"
:base-type {:native "DATE"}}]
[[(t/offset-date-time 2024 11 5 12 12 12)]
[(t/offset-date-time 2024 11 6 13 13 13)]]]])
(deftest date-column-filtering-test
(mt/test-driver
:oracle
(mt/dataset
date-cols-with-datetime-values
(testing "Oracle's DATE columns are mapped to type/DateTime (#49440)"
(testing "Synced field is correctly mapped"
(let [date-field (t2/select-one :model/Field
{:where [:and
[:= :table_id (t2/select-one-fn :id :model/Table :db_id (mt/id))]
[:= :name "date_with_time"]]})]
(are [key* expected-type] (= expected-type (key* date-field))
:base_type :type/DateTime
:database_type "DATE")))
(testing "Filtering with day temporal unit returns expected resutls"
(is (= [[2M "2024-11-06T13:13:13Z"]]
(mt/rows
(mt/run-mbql-query
dates_with_time
{:filter [:= [:field %date_with_time {:base-type :type/Date :temporal-unit :day}] "2024-11-06"]})))))
(testing "Filtering by datetime retuns expected results"
(is (= [[1M "2024-11-05T12:12:12Z"]]
(mt/rows
(mt/run-mbql-query
dates_with_time
{:filter [:= [:field %date_with_time {:base-type :type/Date}] "2024-11-05T12:12:12"]})))))))))
......@@ -39,6 +39,11 @@
[_driver _feature _database]
false)
;; Oracle's DATE has a time part. It is mapped to `:type/DateTime`.
(defmethod driver/database-supports? [:oracle ::date-columns-should-be-emitted-without-time]
[_driver _feature _database]
false)
(deftest ^:parallel date-columns-should-be-emitted-without-time
(mt/test-drivers (mt/normal-drivers-with-feature ::date-columns-should-be-emitted-without-time)
(is (= [["1" "April 7, 2014" "5" "12"]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment