ClickHouse / metabase-clickhouse-driver

ClickHouse database driver for the Metabase business intelligence front-end
Apache License 2.0
461 stars 84 forks source link

No results on specific date for datetime column #216

Closed zero-element closed 3 months ago

zero-element commented 5 months ago

Describe the bug

No results on specific date for datetime column

Steps to reproduce

  1. Create a table with datetime column
  2. Create a date time filter
  3. Select Current -> Day or Specific dates -> On
  4. Get No results!

Expected behaviour

Get results on the specific date, similar to what the v1.2.5 driver does. In v1.2.5, CAST is used to ensure that the datetime column is comparable with the input date, but newer versions "Removed superfluous CAST calls from generated queries that use Date* columns and/or intervals".

Error log

Configuration

Environment

ClickHouse server

slvrtrn commented 5 months ago

Thanks for the report!

While it works from a simple filter, it does not from the editor with variables cause it generates smth like

SELECT
  `default`.`test`.`min_time` AS `min_time`
FROM
  `default`.`test`
 WHERE `default`.`test`.`min_time` = '2024-01-16'
LIMIT
  1048575

ClickHouse is too strict for this...

Given that the available metadata contains no useful info to decide on the transformation (toDate(x)) in this case

{:description nil,
  :lib/type :metadata/column,
  :base-type :type/DateTime,
  :semantic-type nil,
  :table-id 9,
  :name "min_time",
  :coercion-strategy nil,
  :settings nil,
  :nfc-path nil,
  :database-type "DateTime",
  :effective-type :type/DateTime,
  :fk-target-field-id nil,
  :id 72,
  :parent-id nil,
  :visibility-type :normal,
  :display-name "Min Time",
  :position 0,
  :fingerprint
  {:global {:distinct-count 1, :nil% 0.0},
   :type {:type/DateTime {:earliest "2024-01-16T16:47:38Z", :latest "2024-01-16T16:47:38Z"}}}})

could be that a small patch to MB will be required.

We will discuss a possible solution in this case. Please stay tuned.

slvrtrn commented 5 months ago

@zero-element, the ETA for the fix is 0.49.0 (needs a little patch in the MB, see the linked PRs). Until it arrives, please stay on 0.47/1.2.5 if the feature is essential for your use case.

slvrtrn commented 3 months ago

@zero-element, I forgot to write an update here: as Metabase 0.49.0-RC2 is out and contains the necessary fixes, and our CI is green with it, I merged the PR and released 1.4.0, which is supposed to resolve this issue. If it still occurs, please feel free to re-open, and I will investigate.