Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for :window-functions/offset feature #245

Open
slvrtrn opened this issue Jun 11, 2024 · 0 comments
Open

Add support for :window-functions/offset feature #245

slvrtrn opened this issue Jun 11, 2024 · 0 comments
Labels

Comments

@slvrtrn
Copy link
Collaborator

slvrtrn commented Jun 11, 2024

See the driver changelog for 0.50.0.

The :window-functions/offset (offset window functions) Metabase feature is currently disabled, as the default Metabase implementation is incompatible with ClickHouse; the tests showed that the generated queries are not valid:

clojure.lang.ExceptionInfo: Error executing query: Code: 63. DB::Exception: Aggregate function with name 'LAG' does not exists. In scope SELECT source.created_at AS created_at, SUM(source.total) AS sum, LAG(SUM(source.total), 1) OVER (ORDER BY source.created_at ASC) AS offset FROM (SELECT toStartOfYear(test_data.orders.created_at) AS created_at, test_data.orders.total AS total FROM test_data.orders) AS source GROUP BY source.created_at ORDER BY source.created_at ASC LIMIT 3. (UNKNOWN_AGGREGATE_FUNCTION) (version 24.3.1.2672 (official build))
                            , server ClickHouseNode [uri=http://localhost:8123/default, options={use_server_time_zone_for_dates=true,use_no_proxy=false,product_name=metabase/1.4.1}]@-2141897951
    driver: :clickhouse
    params: nil
       sql: ["-- Metabase"
             "SELECT"
             "  `source`.`created_at` AS `created_at`,"
             "  SUM(`source`.`total`) AS `sum`,"
             "  LAG(SUM(`source`.`total`), 1) OVER ("
             "    ORDER BY"
             "      `source`.`created_at` ASC"
             "  ) AS `offset`"
             "FROM"
             "  ("
             ...]
      type: :invalid-query
     java.sql.SQLException: Code: 63. DB::Exception: Aggregate function with name 'LAG' does not exists. In scope SELECT source.created_at AS created_at, SUM(source.total) AS sum, LAG(SUM(source.total), 1) OVER (ORDER BY source.created_at ASC) AS offset FROM (SELECT toStartOfYear(test_data.orders.created_at) AS created_at, test_data.orders.total AS total FROM test_data.orders) AS source GROUP BY source.created_at ORDER BY source.created_at ASC LIMIT 3. (UNKNOWN_AGGREGATE_FUNCTION) (version 24.3.1.2672 (official build))

See also: https://clickhouse.com/docs/en/sql-reference/window-functions#standard-window-functions (the lag/lead part)

@slvrtrn slvrtrn added the enhancement New feature or request label Jun 11, 2024
@slvrtrn slvrtrn changed the title Add support for :window-functions/offset (offset window functions) feature Add support for :window-functions/offset feature Jun 11, 2024
@slvrtrn slvrtrn mentioned this issue Jun 11, 2024
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant