metabase / metabase

The simplest, fastest way to get business intelligence and analytics to everyone in your company :yum:
https://metabase.com
Other
38.33k stars 5.08k forks source link

v0.50.x - "scale: Timeseries" not working with Oracle database - "invalid time zone in DateTimeFormat(): +00:00" #44128

Closed itgkarl closed 3 months ago

itgkarl commented 3 months ago

Describe the bug

Since v0.50.x visualizations using scale: Timeseries (Bar, Line, Area, Combo) are not working with Oracle Databases any more.

grafik

To Reproduce

  1. Set up a new metabse-Instance with docker putting an oracle-jdbc-driver into the plugins folder.
  2. Connect metabase to the an Oracle Database
  3. Make a SQL-Querry against the Oracle Database to receive some testdata with a Date:
    SELECT CURRENT_DATE, 10 AS VALUE FROM DUAL
    UNION ALL
    SELECT CURRENT_DATE+1, 20 AS VALUE FROM DUAL
    UNION ALL
    SELECT CURRENT_DATE+2, 5 AS VALUE FROM DUAL
  4. Try to visualize the testdata in a Line chart using CURRENT_DATE as scale:Timeseries

I used the latest ojdbc11.jar as jdbc driver. To reproduce the error i used the latest Oracle Database XE Release 21c

In my setup to reproduce the error i started a fresh metabase with a fresh oracle-xe Database with the following docker compose file:

version: "2"

services:
  metabase:
    image: metabase/metabase:v0.50.3
    depends_on:
      - oracle-xe
    ports:
      - 3000:3000
    volumes:
      - type: bind
        source: ./plugins
        target: /plugins

  oracle-xe:
    image: container-registry.oracle.com/database/express:21.3.0-xe
    ports:
      - 1521:1521
      - 5500:5500
    environment:
      - ORACLE_PWD=test

Make sure u have a plugins folder with the ojdbc.jar in the folder you have the docker compose.yml. Start it with docker compose up. You can connect to the oracle database on:

Expected behavior

The Line Chart should be rendered using scale: Timeseries

Logs

Browser Console log:

[metabase.lib.normalize] "Error normalizing pMBQL:\n{:value {:lib/type :mbql/query, :stages [{:lib/type :mbql.stage/mbql}]},\n :schema #object[Object [object Object]],\n :explain\n {:schema #object[Object [object Object]],\n  :value {:lib/type :mbql/query, :stages [{:lib/type :mbql.stage/mbql}]},\n  :errors\n  ({:path [0 0 :database],\n    :in [:database],\n    :schema #object[Object [object Object]],\n    :value nil,\n    :type :malli.core/missing-key}\n   {:path [0 0 :stages 0 1 0 0 :mbql.stage/mbql],\n    :in [:stages 0], \n    :schema #object[Object [object Object]], \n    :value {:lib/type :mbql.stage/mbql}})}}\n" [core.cljs:4009:5](webpack:///target/cljs_release/cljs/core.cljs)
[metabase.lib.normalize] "Error normalizing pMBQL:\n{:value {:lib/type :mbql/query, :stages [{:lib/type :mbql.stage/mbql}], :lib/metadata #object[p [object Object]]},\n :schema #object[Object [object Object]],\n :explain\n {:schema #object[Object [object Object]],\n  :value {:lib/type :mbql/query, :stages [{:lib/type :mbql.stage/mbql}], :lib/metadata #object[p [object Object]]},\n  :errors\n  ({:path [0 0 :database],\n    :in [:database],\n    :schema #object[Object [object Object]],\n    :value nil,\n    :type :malli.core/missing-key}\n   {:path [0 0 :stages 0 1 0 0 :mbql.stage/mbql],\n    :in [:stages 0], \n    :schema #object[Object [object Object]], \n    :value {:lib/type :mbql.stage/mbql}})}}\n" [core.cljs:4009:5](webpack:///target/cljs_release/cljs/core.cljs)
RangeError: invalid time zone in DateTimeFormat(): +00:00
    tz Angular
    toEChartsAxisValue axis.ts:677
    fn dataset.ts:757
    _ dataset.ts:271
    x dataset.ts:227
    x dataset.ts:225
    x dataset.ts:224
    N dataset.ts:733
    r_ index.ts:130
    w use-models-and-option.ts:68
    React 2
    <anonymous> use-models-and-option.ts:58
    iI CartesianChart.tsx:49
    React 7
    unstable_runWithPriority scheduler.production.min.js:18
    React 4
    Redux 9
    em querying.js:211
    Redux 2
    eo querying.js:139
    promise callback*83402/eo/< querying.js:130
    Redux 2
    runQuery NativeQueryEditor.tsx:388
    React 11
    unstable_runWithPriority scheduler.production.min.js:18
    React 11
    m4 app.js:68
    m6 app.js:99
    71017 app-main.js:24
    Webpack 6
[console.js:13:4](webpack:///lib/errors/console.js)
invalid time zone in DateTimeFormat(): +00:00 [console.js:13:4](webpack:///lib/errors/console.js)
    error console.js:13
    onRenderError Visualization.jsx:325
    componentDidCatch ChartRenderingErrorBoundary.tsx:14
    React 4
    unstable_runWithPriority scheduler.production.min.js:18
    React 4
    unstable_runWithPriority scheduler.production.min.js:18
    React 4
    Redux 9
    em querying.js:211
    Redux 2
    eo querying.js:139
    (Async: promise callback)
    eo querying.js:130
    Redux 2
    runQuery NativeQueryEditor.tsx:388
    React 11
    unstable_runWithPriority scheduler.production.min.js:18
    React 11
    m4 app.js:68
    m6 app.js:99
    71017 app-main.js:24
    Webpack 6

Metabase Log:

[5ae29451-85d7-4b59-98f5-365ec77fc147] 2024-06-13T14:17:48+02:00 INFO metabase.core 
Metabase v0.50.3 (855535b) 

Copyright © 2024 Metabase, Inc. 

Metabase Enterprise Edition extensions are NOT PRESENT.
[5ae29451-85d7-4b59-98f5-365ec77fc147] 2024-06-13T14:17:48+02:00 INFO metabase.core Starting Metabase in STANDALONE mode
[5ae29451-85d7-4b59-98f5-365ec77fc147] 2024-06-13T14:17:48+02:00 INFO metabase.server Launching Embedded Jetty Webserver with config:
 {:port 3000, :host "0.0.0.0"}

[5ae29451-85d7-4b59-98f5-365ec77fc147] 2024-06-13T14:17:48+02:00 INFO metabase.core Starting Metabase version v0.50.3 (855535b) ...
[5ae29451-85d7-4b59-98f5-365ec77fc147] 2024-06-13T14:17:48+02:00 INFO metabase.core System info:
 {"file.encoding" "UTF-8",
 "java.runtime.name" "OpenJDK Runtime Environment",
 "java.runtime.version" "11.0.23+9",
 "java.vendor" "Eclipse Adoptium",
 "java.vendor.url" "https://adoptium.net/",
 "java.version" "11.0.23",
 "java.vm.name" "OpenJDK 64-Bit Server VM",
 "java.vm.version" "11.0.23+9",
 "os.name" "Linux",
 "os.version" "4.19.128-microsoft-standard",
 "user.language" "en",
 "user.timezone" "GMT"}
...

No Errors here Error is in Frontend.

Information about your Metabase installation

{
  "browser-info": {
    "language": "de",
    "platform": "Win32",
    "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0",
    "vendor": ""
  },
  "system-info": {
    "file.encoding": "UTF-8",
    "java.runtime.name": "OpenJDK Runtime Environment",
    "java.runtime.version": "11.0.23+9",
    "java.vendor": "Eclipse Adoptium",
    "java.vendor.url": "https://adoptium.net/",
    "java.version": "11.0.23",
    "java.vm.name": "OpenJDK 64-Bit Server VM",
    "java.vm.version": "11.0.23+9",
    "os.name": "Linux",
    "os.version": "4.19.128-microsoft-standard",
    "user.language": "en",
    "user.timezone": "GMT"
  },
  "metabase-info": {
    "databases": [
      "h2",
      "oracle"
    ],
    "hosting-env": "unknown",
    "application-database": "h2",
    "application-database-details": {
      "database": {
        "name": "H2",
        "version": "2.1.214 (2022-06-13)"
      },
      "jdbc-driver": {
        "name": "H2 JDBC Driver",
        "version": "2.1.214 (2022-06-13)"
      }
    },
    "run-mode": "prod",
    "version": {
      "date": "2024-06-13",
      "tag": "v0.50.3",
      "hash": "855535b"
    },
    "settings": {
      "report-timezone": null
    }
  }
}

Severity

Workaround exits using scale:Ordinal

Additional context

Error only seen using an Oracle Database. Using H2-DB works fine

Using scale: Ordinal works as expected. grafik

Request to database works fine and result set is shown.: grafik

Error is thrown in frontend while rendering the chart: grafik

paoliniluis commented 3 months ago

thanks, this worked in v49 right?

itgkarl commented 3 months ago

@paoliniluis Last version we used scale:Timestamp wit Oracle successfully was v0.49.13. So yes. v49 seems to work.

itgkarl commented 3 months ago

@paoliniluis I just retested it with the same local setup i showed the error in v0.50.3. I can confirm, that it worked in v0.49.16 with the same setup. No error in v0.49.16

alxnddr commented 3 months ago

upd: please ignore the ask below, I managed to reproduce it but only in Safari on non-IANA timezones

@itgkarl could you please provide the backend response for the sql query you provided? In order to do that, you need to

{
    "data": {
        "rows": [
            [
                "2024-06-13T17:38:41Z",
                10
            ],
            [
                "2024-06-14T17:38:41Z",
                20
            ],
            [
                "2024-06-15T17:38:41Z",
                5
            ]
        ],
        "cols": [....],
        "native_form": {...},
        "format-rows?": true,
        "results_timezone": "+00:00",
    }
}
itgkarl commented 3 months ago

@alxnddr Happy you could reproduce it. I looked into the response anyways. Maybe it still helps to validate the fix. I get the error on Firefox 115-12-0esr with following response:

{
   "data":{
      "rows":[
         [
            "2024-06-14T06:36:36Z",
            10
         ],
         [
            "2024-06-15T06:36:36Z",
            20
         ],
         [
            "2024-06-16T06:36:36Z",
            5
         ]
      ],
      "cols":[
         {
            "display_name":"CURRENT_DATE",
            "source":"native",
            "field_ref":[
               "field",
               "CURRENT_DATE",
               {
                  "base-type":"type/Date"
               }
            ],
            "name":"CURRENT_DATE",
            "base_type":"type/Date",
            "effective_type":"type/Date"
         },
         {
            "display_name":"VALUE",
            "source":"native",
            "field_ref":[
               "field",
               "VALUE",
               {
                  "base-type":"type/Decimal"
               }
            ],
            "name":"VALUE",
            "base_type":"type/Decimal",
            "effective_type":"type/Decimal"
         }
      ],
      "native_form":{
         "params":null,
         "query":"SELECT CURRENT_DATE, 10 AS VALUE FROM DUAL\nUNION ALL\nSELECT CURRENT_DATE+1, 20 AS VALUE FROM DUAL\nUNION ALL\nSELECT CURRENT_DATE+2, 5 AS VALUE FROM DUAL"
      },
      "format-rows?":true,
      "results_timezone":"+00:00",
      "results_metadata":{
         "columns":[
            {
               "display_name":"CURRENT_DATE",
               "field_ref":[
                  "field",
                  "CURRENT_DATE",
                  {
                     "base-type":"type/Date"
                  }
               ],
               "name":"CURRENT_DATE",
               "base_type":"type/Date",
               "effective_type":"type/Date",
               "semantic_type":null,
               "fingerprint":{
                  "global":{
                     "distinct-count":3,
                     "nil%":0.0
                  },
                  "type":{
                     "type/DateTime":{
                        "earliest":"2024-06-14T06:36:36Z",
                        "latest":"2024-06-16T06:36:36Z"
                     }
                  }
               }
            },
            {
               "display_name":"VALUE",
               "field_ref":[
                  "field",
                  "VALUE",
                  {
                     "base-type":"type/Decimal"
                  }
               ],
               "name":"VALUE",
               "base_type":"type/Decimal",
               "effective_type":"type/Decimal",
               "semantic_type":null,
               "fingerprint":{
                  "global":{
                     "distinct-count":3,
                     "nil%":0.0
                  },
                  "type":{
                     "type/Number":{
                        "min":5.0,
                        "q1":6.25,
                        "q3":17.5,
                        "max":20.0,
                        "sd":7.637626158259733,
                        "avg":11.666666666666666
                     }
                  }
               }
            }
         ]
      },
      "insights":[
         {
            "previous-value":20,
            "unit":"day",
            "offset":49734.85520833334,
            "last-change":-0.75,
            "col":"VALUE",
            "slope":-2.5,
            "last-value":5,
            "best-fit":[
               "+",
               49734.85520833334,
               [
                  "*",
                  -2.5,
                  "x"
               ]
            ]
         }
      ]
   },
   "cached":false,
   "database_id":2,
   "started_at":"2024-06-14T06:36:36.578501Z",
   "json_query":{
      "type":"native",
      "native":{
         "query":"SELECT CURRENT_DATE, 10 AS VALUE FROM DUAL\nUNION ALL\nSELECT CURRENT_DATE+1, 20 AS VALUE FROM DUAL\nUNION ALL\nSELECT CURRENT_DATE+2, 5 AS VALUE FROM DUAL",
         "template-tags":{

         }
      },
      "database":2,
      "middleware":{
         "js-int-to-string?":true,
         "userland-query?":true,
         "add-default-userland-constraints?":true
      }
   },
   "average_execution_time":null,
   "status":"completed",
   "context":"ad-hoc",
   "row_count":3,
   "running_time":16
}
alxnddr commented 3 months ago

@itgkarl thank you for additional information! We will include the fix in the next maintenance version

alxnddr commented 3 months ago

Reopen until the backport PR gets merged