-
Notifications
You must be signed in to change notification settings - Fork 315
Add support for MySQL Metastore #2704
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
Open
Jayden-Chiu
wants to merge
4
commits into
apache:main
Choose a base branch
from
Jayden-Chiu:jchiu/mysql-metastore-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
090f0ed
feat(persistence): add MySQL support to relational-jdbc module
d000e76
Merge branch 'apache:main' into jchiu/mysql-metastore-support
Jayden-Chiu 86e88c5
test(persistence): tests for MySQL support
091a965
test(persistence): tests for MySQL support
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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
104 changes: 104 additions & 0 deletions
104
persistence/relational-jdbc/src/main/resources/mysql/schema-v1.sql
This file contains hidden or 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,104 @@ | ||
-- | ||
-- Licensed to the Apache Software Foundation (ASF) under one | ||
-- or more contributor license agreements. See the NOTICE file-- | ||
-- distributed with this work for additional information | ||
-- regarding copyright ownership. The ASF licenses this file | ||
-- to you under the Apache License, Version 2.0 (the | ||
-- "License"). You may not use this file except in compliance | ||
-- with the License. You may obtain a copy of the License at | ||
-- | ||
-- http://www.apache.org/licenses/LICENSE-2.0 | ||
-- | ||
-- Unless required by applicable law or agreed to in writing, | ||
-- software distributed under the License is distributed on an | ||
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
-- KIND, either express or implied. See the License for the | ||
-- specific language governing permissions and limitations | ||
-- under the License. | ||
|
||
-- Changes from v2: | ||
-- * Added `events` table | ||
|
||
CREATE DATABASE IF NOT EXISTS POLARIS_SCHEMA; | ||
USE POLARIS_SCHEMA; | ||
|
||
CREATE TABLE IF NOT EXISTS version ( | ||
version_key VARCHAR(255) PRIMARY KEY, | ||
version_value INTEGER NOT NULL | ||
); | ||
INSERT INTO version (version_key, version_value) | ||
VALUES ('version', 3) | ||
ON DUPLICATE KEY UPDATE version_value = VALUES(version_value); | ||
|
||
CREATE TABLE IF NOT EXISTS entities ( | ||
realm_id VARCHAR(255) NOT NULL, | ||
catalog_id BIGINT NOT NULL, | ||
id BIGINT NOT NULL, | ||
parent_id BIGINT NOT NULL, | ||
name VARCHAR(255) NOT NULL, | ||
entity_version INT NOT NULL, | ||
type_code INT NOT NULL, | ||
sub_type_code INT NOT NULL, | ||
create_timestamp BIGINT NOT NULL, | ||
drop_timestamp BIGINT NOT NULL, | ||
purge_timestamp BIGINT NOT NULL, | ||
to_purge_timestamp BIGINT NOT NULL, | ||
last_update_timestamp BIGINT NOT NULL, | ||
properties JSON NOT NULL DEFAULT ('{}'), | ||
internal_properties JSON NOT NULL DEFAULT ('{}'), | ||
grant_records_version INT NOT NULL, | ||
location_without_scheme TEXT, | ||
PRIMARY KEY (realm_id, id), | ||
UNIQUE KEY constraint_name (realm_id, catalog_id, parent_id, type_code, name) | ||
); | ||
|
||
-- TODO: create indexes based on all query pattern. | ||
CREATE INDEX idx_entities ON entities (realm_id, catalog_id, id); | ||
CREATE INDEX idx_locations ON entities (realm_id, parent_id, location_without_scheme(255)); | ||
|
||
CREATE TABLE IF NOT EXISTS grant_records ( | ||
realm_id VARCHAR(255) NOT NULL, | ||
securable_catalog_id BIGINT NOT NULL, | ||
securable_id BIGINT NOT NULL, | ||
grantee_catalog_id BIGINT NOT NULL, | ||
grantee_id BIGINT NOT NULL, | ||
privilege_code INTEGER, | ||
PRIMARY KEY (realm_id, securable_catalog_id, securable_id, grantee_catalog_id, grantee_id, privilege_code) | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS principal_authentication_data ( | ||
realm_id VARCHAR(255) NOT NULL, | ||
principal_id BIGINT NOT NULL, | ||
principal_client_id VARCHAR(255) NOT NULL, | ||
main_secret_hash VARCHAR(255) NOT NULL, | ||
secondary_secret_hash VARCHAR(255) NOT NULL, | ||
secret_salt VARCHAR(255) NOT NULL, | ||
PRIMARY KEY (realm_id, principal_client_id) | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS policy_mapping_record ( | ||
realm_id VARCHAR(255) NOT NULL, | ||
target_catalog_id BIGINT NOT NULL, | ||
target_id BIGINT NOT NULL, | ||
policy_type_code INTEGER NOT NULL, | ||
policy_catalog_id BIGINT NOT NULL, | ||
policy_id BIGINT NOT NULL, | ||
parameters JSON NOT NULL DEFAULT ('{}'), | ||
PRIMARY KEY (realm_id, target_catalog_id, target_id, policy_type_code, policy_catalog_id, policy_id) | ||
); | ||
|
||
CREATE INDEX idx_policy_mapping_record ON policy_mapping_record (realm_id, policy_type_code, policy_catalog_id, policy_id, target_catalog_id, target_id); | ||
|
||
CREATE TABLE IF NOT EXISTS events ( | ||
realm_id VARCHAR(255) NOT NULL, | ||
catalog_id VARCHAR(255) NOT NULL, | ||
event_id VARCHAR(255) NOT NULL, | ||
request_id VARCHAR(255), | ||
event_type VARCHAR(255) NOT NULL, | ||
timestamp_ms BIGINT NOT NULL, | ||
principal_name VARCHAR(255), | ||
resource_type VARCHAR(255) NOT NULL, | ||
resource_identifier VARCHAR(255) NOT NULL, | ||
additional_properties JSON NOT NULL DEFAULT ('{}'), | ||
PRIMARY KEY (event_id) | ||
); |
104 changes: 104 additions & 0 deletions
104
persistence/relational-jdbc/src/main/resources/mysql/schema-v2.sql
This file contains hidden or 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,104 @@ | ||
-- | ||
-- Licensed to the Apache Software Foundation (ASF) under one | ||
-- or more contributor license agreements. See the NOTICE file-- | ||
-- distributed with this work for additional information | ||
-- regarding copyright ownership. The ASF licenses this file | ||
-- to you under the Apache License, Version 2.0 (the | ||
-- "License"). You may not use this file except in compliance | ||
-- with the License. You may obtain a copy of the License at | ||
-- | ||
-- http://www.apache.org/licenses/LICENSE-2.0 | ||
-- | ||
-- Unless required by applicable law or agreed to in writing, | ||
-- software distributed under the License is distributed on an | ||
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
-- KIND, either express or implied. See the License for the | ||
-- specific language governing permissions and limitations | ||
-- under the License. | ||
|
||
-- Changes from v2: | ||
-- * Added `events` table | ||
|
||
CREATE DATABASE IF NOT EXISTS POLARIS_SCHEMA; | ||
USE POLARIS_SCHEMA; | ||
|
||
CREATE TABLE IF NOT EXISTS version ( | ||
version_key VARCHAR(255) PRIMARY KEY, | ||
version_value INTEGER NOT NULL | ||
); | ||
INSERT INTO version (version_key, version_value) | ||
VALUES ('version', 3) | ||
ON DUPLICATE KEY UPDATE version_value = VALUES(version_value); | ||
|
||
CREATE TABLE IF NOT EXISTS entities ( | ||
realm_id VARCHAR(255) NOT NULL, | ||
catalog_id BIGINT NOT NULL, | ||
id BIGINT NOT NULL, | ||
parent_id BIGINT NOT NULL, | ||
name VARCHAR(255) NOT NULL, | ||
entity_version INT NOT NULL, | ||
type_code INT NOT NULL, | ||
sub_type_code INT NOT NULL, | ||
create_timestamp BIGINT NOT NULL, | ||
drop_timestamp BIGINT NOT NULL, | ||
purge_timestamp BIGINT NOT NULL, | ||
to_purge_timestamp BIGINT NOT NULL, | ||
last_update_timestamp BIGINT NOT NULL, | ||
properties JSON NOT NULL DEFAULT ('{}'), | ||
internal_properties JSON NOT NULL DEFAULT ('{}'), | ||
grant_records_version INT NOT NULL, | ||
location_without_scheme TEXT, | ||
PRIMARY KEY (realm_id, id), | ||
UNIQUE KEY constraint_name (realm_id, catalog_id, parent_id, type_code, name) | ||
); | ||
|
||
-- TODO: create indexes based on all query pattern. | ||
CREATE INDEX idx_entities ON entities (realm_id, catalog_id, id); | ||
CREATE INDEX idx_locations ON entities (realm_id, parent_id, location_without_scheme(255)); | ||
|
||
CREATE TABLE IF NOT EXISTS grant_records ( | ||
realm_id VARCHAR(255) NOT NULL, | ||
securable_catalog_id BIGINT NOT NULL, | ||
securable_id BIGINT NOT NULL, | ||
grantee_catalog_id BIGINT NOT NULL, | ||
grantee_id BIGINT NOT NULL, | ||
privilege_code INTEGER, | ||
PRIMARY KEY (realm_id, securable_catalog_id, securable_id, grantee_catalog_id, grantee_id, privilege_code) | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS principal_authentication_data ( | ||
realm_id VARCHAR(255) NOT NULL, | ||
principal_id BIGINT NOT NULL, | ||
principal_client_id VARCHAR(255) NOT NULL, | ||
main_secret_hash VARCHAR(255) NOT NULL, | ||
secondary_secret_hash VARCHAR(255) NOT NULL, | ||
secret_salt VARCHAR(255) NOT NULL, | ||
PRIMARY KEY (realm_id, principal_client_id) | ||
); | ||
|
||
CREATE TABLE IF NOT EXISTS policy_mapping_record ( | ||
realm_id VARCHAR(255) NOT NULL, | ||
target_catalog_id BIGINT NOT NULL, | ||
target_id BIGINT NOT NULL, | ||
policy_type_code INTEGER NOT NULL, | ||
policy_catalog_id BIGINT NOT NULL, | ||
policy_id BIGINT NOT NULL, | ||
parameters JSON NOT NULL DEFAULT ('{}'), | ||
PRIMARY KEY (realm_id, target_catalog_id, target_id, policy_type_code, policy_catalog_id, policy_id) | ||
); | ||
|
||
CREATE INDEX idx_policy_mapping_record ON policy_mapping_record (realm_id, policy_type_code, policy_catalog_id, policy_id, target_catalog_id, target_id); | ||
|
||
CREATE TABLE IF NOT EXISTS events ( | ||
realm_id VARCHAR(255) NOT NULL, | ||
catalog_id VARCHAR(255) NOT NULL, | ||
event_id VARCHAR(255) NOT NULL, | ||
request_id VARCHAR(255), | ||
event_type VARCHAR(255) NOT NULL, | ||
timestamp_ms BIGINT NOT NULL, | ||
principal_name VARCHAR(255), | ||
resource_type VARCHAR(255) NOT NULL, | ||
resource_identifier VARCHAR(255) NOT NULL, | ||
additional_properties JSON NOT NULL DEFAULT ('{}'), | ||
PRIMARY KEY (event_id) | ||
); |
Oops, something went wrong.
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.
Why add earlier schemas? MySQL was not supported when v1 was current 🤔
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.
Since this is currently only checked within a persistence impl, these version numbers are also per persistence impl. There's no requirement that MySQL vN align with postgres vN.
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.
So rather than just starting with mysql v3, you could just start with mysql v1 with all the tables that postgres v3 has.