-
Notifications
You must be signed in to change notification settings - Fork 535
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 clickhouse-replicated dialect #809
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
internal/testing/integration/testdata/migrations/clickhouse-replicated/00001_a.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
-- +goose Up | ||
CREATE TABLE IF NOT EXISTS trips ON CLUSTER '{cluster}' | ||
( | ||
`trip_id` UInt32, | ||
`vendor_id` Enum8('1' = 1, '2' = 2, '3' = 3, '4' = 4, 'CMT' = 5, 'VTS' = 6, 'DDS' = 7, 'B02512' = 10, 'B02598' = 11, 'B02617' = 12, 'B02682' = 13, 'B02764' = 14, '' = 15), | ||
`pickup_date` Date, | ||
`pickup_datetime` DateTime, | ||
`dropoff_date` Date, | ||
`dropoff_datetime` DateTime, | ||
`store_and_fwd_flag` UInt8, | ||
`rate_code_id` UInt8, | ||
`pickup_longitude` Float64, | ||
`pickup_latitude` Float64, | ||
`dropoff_longitude` Float64, | ||
`dropoff_latitude` Float64, | ||
`passenger_count` UInt8, | ||
`trip_distance` Float64, | ||
`fare_amount` Float32, | ||
`extra` Float32, | ||
`mta_tax` Float32, | ||
`tip_amount` Float32, | ||
`tolls_amount` Float32, | ||
`ehail_fee` Float32, | ||
`improvement_surcharge` Float32, | ||
`total_amount` Float32, | ||
`payment_type` Enum8('UNK' = 0, 'CSH' = 1, 'CRE' = 2, 'NOC' = 3, 'DIS' = 4), | ||
`trip_type` UInt8, | ||
`pickup` FixedString(25), | ||
`dropoff` FixedString(25), | ||
`cab_type` Enum8('yellow' = 1, 'green' = 2, 'uber' = 3), | ||
`pickup_nyct2010_gid` Int8, | ||
`pickup_ctlabel` Float32, | ||
`pickup_borocode` Int8, | ||
`pickup_ct2010` String, | ||
`pickup_boroct2010` FixedString(7), | ||
`pickup_cdeligibil` String, | ||
`pickup_ntacode` FixedString(4), | ||
`pickup_ntaname` String, | ||
`pickup_puma` UInt16, | ||
`dropoff_nyct2010_gid` UInt8, | ||
`dropoff_ctlabel` Float32, | ||
`dropoff_borocode` UInt8, | ||
`dropoff_ct2010` String, | ||
`dropoff_boroct2010` FixedString(7), | ||
`dropoff_cdeligibil` String, | ||
`dropoff_ntacode` FixedString(4), | ||
`dropoff_ntaname` String, | ||
`dropoff_puma` UInt16 | ||
) | ||
ENGINE = ReplicatedMergeTree() | ||
PARTITION BY toYYYYMM(pickup_date) | ||
ORDER BY pickup_datetime; | ||
|
||
-- +goose Down | ||
DROP TABLE IF EXISTS trips ON CLUSTER '{cluster}' SYNC; |
13 changes: 13 additions & 0 deletions
13
internal/testing/integration/testdata/migrations/clickhouse-replicated/00002_b.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
-- +goose Up | ||
CREATE TABLE IF NOT EXISTS clickstream ON CLUSTER '{cluster}' ( | ||
customer_id String, | ||
time_stamp Date, | ||
click_event_type String, | ||
country_code FixedString(2), | ||
source_id UInt64 | ||
) | ||
ENGINE = ReplicatedMergeTree() | ||
ORDER BY (time_stamp); | ||
|
||
-- +goose Down | ||
DROP TABLE IF EXISTS clickstream ON CLUSTER '{cluster}' SYNC; |
8 changes: 8 additions & 0 deletions
8
internal/testing/integration/testdata/migrations/clickhouse-replicated/00003_c.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
-- +goose Up | ||
INSERT INTO clickstream VALUES ('customer1', '2021-10-02', 'add_to_cart', 'US', 568239 ); | ||
|
||
INSERT INTO clickstream (customer_id, time_stamp, click_event_type) VALUES ('customer2', '2021-10-30', 'remove_from_cart' ); | ||
|
||
INSERT INTO clickstream (* EXCEPT(country_code)) VALUES ('customer3', '2021-11-07', 'checkout', 307493 ); | ||
|
||
-- +goose Down |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be awesome to be able to pass keeper path here as well, like
ENGINE = ReplicatedMergeTree('/clickhouse/tables/common/migrations', '{replica}')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's an endless number of ways to configure clickhouse, which means goose will need to know about all these and expose knobs for them.
I think the most practical solution would be for projects to implement the
Store
interface, e.g.,#520 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe an alternative would be to expose configuration options via a .yaml file. I think what I'm getting at is it's not sustainable to maintain dozens of custom clickhouse dialects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally agree! The Store interface looks much better