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

Update for metabase 53/master #287

Merged
merged 4 commits into from
Feb 7, 2025

Conversation

dpsutton
Copy link
Contributor

@dpsutton dpsutton commented Feb 5, 2025

A few changes to get this building against latest metabase master

metabase.sync -> metabase.sync.core. we are trying to add apis around our systems. Annoying that you don't know what you can and cannot use. unfortunately adding these apis is painful, but we hope you can rely on the sync api going forward, and not being bitten by everything changing.

defn- inline to leftn. defn and its ilk is a top level definition. For inline helpers like this we can use letfn or let.

with-dynamic-redefs -> with-dynamic-fn-redefs. We don't consider 3rd party drivers when we refactor our test helpers. We should.

using io/resource: helper function. I don't move the directory to <metabase>/modules. I just want stuff found by the classpath. This lets the sql file be found by the classpath and not absolute file location. I added "clickhouse" to it's name for disambiguation purposes in case anyone else has a datasts.sql file in their spot. they probably don't.

If you are interested in how i ran this from the cli: I have the following alias in my ~/.clojure/deps.edn:

:aliases {
,,,
    :clickhouse {:jvm-opts ["-Dmb.dev.additional.driver.manifest.paths=/Users/dan/projects/work/metabase-clickhouse-driver/resources/metabase-plugin.yaml"]
                 :extra-paths ["/Users/dan/projects/work/metabase-clickhouse-driver/test/"]
                 :extra-deps
                 {clickhouse/clickhouse
                  {:local/root "/Users/dan/projects/work/metabase-clickhouse-driver"}}}
}

I use a jvm option for driver developers to get the plugin manifest and then add my classpaths as normal.

This lets me run tests from the regular metabase director as such:

clj -X:ee:ee-dev:dev:test:clickhouse :only '"/Users/dan/projects/work/metabase-clickhouse-driver/test"'
... output
Ran 61 tests in 0.701 seconds
4 assertions, 0 failures, 0 errors.
{:test 61, :pass 4, :fail 0, :error 0, :type :summary, :duration 700.768, :parallel 55, :single-threaded 6}
Ran 55 tests in parallel, 6 single-threaded.
Finding and running tests took 12.7 s.
All tests passed.
Running after-run hooks...

Summary

Checklist

Delete items not relevant to your PR:

  • Unit and integration tests covering the common scenarios were added
  • A human-readable description of the changes was provided to include in CHANGELOG
  • For significant changes, documentation in https://github.com/ClickHouse/clickhouse-docs was updated with further explanations or tutorials

`metabase.sync` -> `metabase.sync.core`. we are trying to add apis
around our systems. Annoying that you don't know what you can and
cannot use. unfortunately adding these apis is painful, but we hope
you can rely on the sync api going forward, and not being bitten by
everything changing.

`defn-` inline to `leftn`. defn and its ilk is a top level
definition. For inline helpers like this we can use letfn or let.

`with-dynamic-redefs` -> `with-dynamic-fn-redefs`. We don't consider
3rd party drivers when we refactor our test helpers. We should.

using io/resource: helper function. I don't move the directory to
`<metabase>/modules`. I just want stuff found by the classpath. This
lets the sql file be found by the classpath and not absolute file
location. I added "clickhouse" to it's name for disambiguation
purposes in case anyone else has a datasts.sql file in their
spot. they probably don't.

If you are interested in how i ran this from the cli:
I have the following alias in my ~/.clojure/deps.edn:
```clojure
:aliases {
,,,
    :clickhouse {:jvm-opts ["-Dmb.dev.additional.driver.manifest.paths=/Users/dan/projects/work/metabase-clickhouse-driver/resources/metabase-plugin.yaml"]
                 :extra-paths ["/Users/dan/projects/work/metabase-clickhouse-driver/test/"]
                 :extra-deps
                 {clickhouse/clickhouse
                  {:local/root "/Users/dan/projects/work/metabase-clickhouse-driver"}}}
}
```
I use a jvm option for driver developers to get the plugin manifest
and then add my classpaths as normal.

This lets me run tests from the regular metabase director as such:

```
clj -X:ee:ee-dev:dev:test:clickhouse :only '"/Users/dan/projects/work/metabase-clickhouse-driver/test"'
... output
Ran 61 tests in 0.701 seconds
4 assertions, 0 failures, 0 errors.
{:test 61, :pass 4, :fail 0, :error 0, :type :summary, :duration 700.768, :parallel 55, :single-threaded 6}
Ran 55 tests in parallel, 6 single-threaded.
Finding and running tests took 12.7 s.
All tests passed.
Running after-run hooks...
```
@CLAassistant
Copy link

CLAassistant commented Feb 5, 2025

CLA assistant check
All committers have signed the CLA.

@wotbrew wotbrew mentioned this pull request Feb 6, 2025
2 tasks
@slvrtrn
Copy link
Collaborator

slvrtrn commented Feb 6, 2025

I wonder why this test fails now:

FAIL in metabase.driver.sql-jdbc.sync.describe-table-test/describe-view-fields (describe_table_test.clj:824)

:clickhouse

This should not happen
expected: (nil? e)
  actual: (not
           (nil?
            #<java.sql.SQLException@54fcef49 java.sql.SQLException: Code: 62. DB::Exception: Syntax error: failed at position 6 ('MATERIALIZED'): MATERIALIZED VIEW IF EXISTS `test_data`.`orders_m`. Expected one of: DATABASE, ALL, VIEW, DICTIONARY, TEMPORARY, TABLE, FUNCTION, NAMED COLLECTION, INDEX, USER, ROLE, SETTINGS PROFILE, PROFILE, ROW POLICY, POLICY, QUOTA. (SYNTAX_ERROR) (version 24.7.6.8 (official build)) >))

@dpsutton
Copy link
Contributor Author

dpsutton commented Feb 6, 2025

it's running the sql
"DROP MATERIALIZED VIEW IF EXISTS test_data.orders_m" and clickhouse doesn't like that

i think this is easily accomplishable. It doesn't like the drop and
create syntax we use by default.

Currently when doing the materialized view tests it runs

```sql
DROP MATERIALIZED VIEW  IF EXISTS `test_data`.`orders_m`
```

Clickhouse doesn't need the `materialized` bit. We can influence this
with the `tx/drop-view!` multimethod.

Then when creating, clickhouse has much different syntax.

```
 :cause "Code: 42. DB::Exception: ORDER BY or PRIMARY KEY clause is missing. Consider using extended storage definition syntax with ORDER BY or PRIMARY KEY clause. With deprecated old syntax (highly not recommended) storage MergeTree requires 3 to 4 parameters: name of column with date, [sampling element of primary key], primary key expression, index granularity Syntax for the MergeTree table engine: CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster] ( name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1] [TTL expr1], name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2] [TTL expr2], ... INDEX index_name1 expr1 TYPE type1(...) [GRANULARITY value1], INDEX index_name2 expr2 TYPE type2(...) [GRANULARITY value2] ) ENGINE = MergeTree() ORDER BY expr [PARTITION BY expr] [PRIMARY KEY expr] [SAMPLE BY expr] [TTL expr [DELETE|TO DISK 'xxx'|TO VOLUME 'xxx'], ...] [SETTINGS name=value, ...] [COMMENT 'comment'] See details in documentation: https://clickhouse.com/docs/en/engines/table-engines/mergetree-family/mergetree/. Other engines of the family support different syntax, see details in the corresponding documentation topics. If you use the Replicated version of engines, see https://clickhouse.com/docs/en/engines/table-engines/mergetree-family/replication/. . (NUMBER_OF_ARGUMENTS_DOESNT_MATCH) (version 24.7.6.8 (official build)) "
```

We can again impact this with `tx/create-view-of-table!` for clickhouse.
@dpsutton
Copy link
Contributor Author

dpsutton commented Feb 7, 2025

And as of a5f668779822481b9dcd43644df9d503dc8020e4 on master i successfully run all tests

 clj -X:dev:ee:ee-dev:drivers:drivers-dev:test:clickhouse
...

Ran 7006 tests in 881.938 seconds
59653 assertions, 0 failures, 0 errors.
{:test 7006,
 :pass 59653,
 :fail 0,
 :error 0,
 :type :summary,
 :duration 881937.87625,
 :single-threaded 3656,
 :parallel 3350}
Ran 3350 tests in parallel, 3656 single-threaded.
Finding and running tests took 15.3 mins.

@slvrtrn slvrtrn merged commit 3bcd51d into ClickHouse:master Feb 7, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants