-
Notifications
You must be signed in to change notification settings - Fork 51
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
Self serve replication SQL API #226
Self serve replication SQL API #226
Conversation
ad12bbd
to
a6d32ec
Compare
a6d32ec
to
1f7d13d
Compare
.../java/com/linkedin/openhouse/spark/statementtest/SetTableReplicationPolicyStatementTest.java
Show resolved
Hide resolved
...ala/com/linkedin/openhouse/spark/sql/execution/datasources/v2/SetReplicationPolicyExec.scala
Show resolved
Hide resolved
...ala/com/linkedin/openhouse/spark/sql/execution/datasources/v2/SetReplicationPolicyExec.scala
Show resolved
Hide resolved
...ain/scala/com/linkedin/openhouse/spark/sql/catalyst/plans/logical/SetReplicationPolicy.scala
Show resolved
Hide resolved
Thank you Selena for quick turnaround on PR. Can you expand on the testing section if local docker tests or test cluster setup was done? |
@rohitkum2506 updated description with local docker spark-shell testing 👍 |
.../java/com/linkedin/openhouse/spark/statementtest/SetTableReplicationPolicyStatementTest.java
Outdated
Show resolved
Hide resolved
.../antlr/com/linkedin/openhouse/spark/sql/catalyst/parser/extensions/OpenhouseSqlExtensions.g4
Outdated
Show resolved
Hide resolved
a3c2772
to
acd42eb
Compare
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.
LGTM. Lets get approval from @autumnust as well
.../java/com/linkedin/openhouse/spark/statementtest/SetTableReplicationPolicyStatementTest.java
Outdated
Show resolved
Hide resolved
.../antlr/com/linkedin/openhouse/spark/sql/catalyst/parser/extensions/OpenhouseSqlExtensions.g4
Show resolved
Hide resolved
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.
Thanks @chenselena! LGTM.
.../antlr/com/linkedin/openhouse/spark/sql/catalyst/parser/extensions/OpenhouseSqlExtensions.g4
Outdated
Show resolved
Hide resolved
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.
One minor question, Thanks for pushing this !
.../antlr/com/linkedin/openhouse/spark/sql/catalyst/parser/extensions/OpenhouseSqlExtensions.g4
Show resolved
Hide resolved
## Summary <!--- HINT: Replace #nnn with corresponding Issue number, if you are fixing an existing issue --> Branched off from #220, this PR adds the server side implementation for the self serve replication API. Separate PR for SQL level changes can be found here: #226. This PR adds validations for the interval and destination cluster parameters and stores the replication config as part of table policies in table properties. Validations on parameters: - Destination cluster cannot be the same as the source cluster of the table. - For the interval parameter, if user inputted it should be in the format <X>H or <X>D where hourly inputs can be 12H and daily inputs can be 1-3D. This PR doesn't include the changes to generate the cron schedule from the interval input, those will be made in a separate PR. ## Changes - [x] Client-facing API Changes - [ ] Internal API Changes - [ ] Bug Fixes - [ ] New Features - [ ] Performance Improvements - [ ] Code Style - [ ] Refactoring - [ ] Documentation - [ ] Tests For all the boxes checked, please include additional details of the changes made in this pull request. ## Testing Done <!--- Check any relevant boxes with "x" --> - [x] Manually Tested on local docker setup. Please include commands ran, and their output. - [x] Added new tests for the changes made. - [ ] Updated existing tests to reflect the changes made. - [ ] No tests added or updated. Please explain why. If unsure, please feel free to ask for help. - [ ] Some other form of testing like staging or soak time in production. Please explain. Added unit testing. Tested with local docker server: successful POST to `http://localhost:8000/v1/databases/u_tableowner/tables` with parameters: ``` { "tableId": "test_table", "databaseId": "u_tableowner", "baseTableVersion": "INITIAL_VERSION", "clusterId": "LocalHadoopCluster", "schema": "{\"type\": \"struct\", \"fields\": [{\"id\": 1,\"required\": true,\"name\": \"id\",\"type\": \"string\"},{\"id\": 2,\"required\": true,\"name\": \"name\",\"type\": \"string\"},{\"id\": 3,\"required\": true,\"name\": \"ts\",\"type\": \"timestamp\"}]}", "tableProperties": { "key": "value" }, "policies": { "sharingEnabled": "true", "replication": { "config": [ { "destination": "LocalHadoopClusterA", "interval": "12H" } ] } } } ``` successful POST to `http://localhost:8000/v1/databases/u_tableowner/tables` with parameters: ``` { "tableId": "test_table", "databaseId": "u_tableowner", "baseTableVersion": "INITIAL_VERSION", "clusterId": "LocalHadoopCluster", "schema": "{\"type\": \"struct\", \"fields\": [{\"id\": 1,\"required\": true,\"name\": \"id\",\"type\": \"string\"},{\"id\": 2,\"required\": true,\"name\": \"name\",\"type\": \"string\"},{\"id\": 3,\"required\": true,\"name\": \"ts\",\"type\": \"timestamp\"}]}", "tableProperties": { "key": "value" }, "policies": { "sharingEnabled": "true", "replication": { "config": [ { "destination": "LocalHadoopClusterA", "interval": "1D" } ] } } } ``` Using `interval: 24H` gives the following error: ``` { "status": "BAD_REQUEST", "error": "Bad Request", "message": " : Replication interval for the table LocalHadoopCluster.u_tableowner.test_table1 can either be 12 hours or daily for up to 3 days", "stacktrace": null, "cause": "Not Available" } ``` Trying to set the destination cluster as the source cluster gives the following error: ``` { "status": "BAD_REQUEST", "error": "Bad Request", "message": " : Replication destination cluster for the table LocalHadoopCluster.u_tableowner.test_table1 must be different from the source cluster", "stacktrace": null, "cause": "Not Available" } ``` For all the boxes checked, include a detailed description of the testing done for the changes made in this pull request. # Additional Information - [ ] Breaking Changes - [ ] Deprecations - [ ] Large PR broken into smaller PRs, and PR plan linked in the description. For all the boxes checked, include additional details of the changes made in this pull request.
Summary
Branched off from #220, this PR contains only the scope for SQL API support for self serve replication. The changes include SQL API support for adding replication configs to table policies within table properties.
SQL API that is supported:
where interval is defined as the interval at which the replication job is run and cluster is the destination cluster.
Interval is an optional parameter where users can define an interval from 12 to 72 as
12h/H
,24h/H
, etc. If interval is not given, the replication schedule will be set up as daily (24h intervals).We also allow a list input with multiple clusters to enable multi-cluster table replication.
Future Scope:
Add validations to check that the destination cluster != source cluster, and that the replication interval follows rules defined for data freshness and compliance.
Separate PR for server-side implementation: #227 which will contain validation for SQL string input and cron schedule.
Changes
For all the boxes checked, please include additional details of the changes made in this pull request.
Testing Done
For all the boxes checked, include a detailed description of the testing done for the changes made in this pull request.
Added unit tests.
Ran following commands on local docker:
Additional Information
For all the boxes checked, include additional details of the changes made in this pull request.