-
Notifications
You must be signed in to change notification settings - Fork 391
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
[#4731] feat(paimon-spark-conenctor): Support delete, update and mergeInto paimon table in paimon spark connector #5864
Open
caican00
wants to merge
55
commits into
apache:main
Choose a base branch
from
caican00:support-paimon-connector-extensions
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.
+1,818
−103
Open
Changes from all commits
Commits
Show all changes
55 commits
Select commit
Hold shift + click to select a range
ed8e5b7
basic ddl
e4a11d1
basic ddl
a16e949
basic dml
e28d323
support partition
6de61c2
basic dml
17690df
basic schema ddl
dae7ccf
Merge branch 'support-paimon-connector-ddl' of github.com:caican00/gr…
7c6013c
fix
0915488
fix
4190fd9
Merge branch 'support-paimon-connector-ddl' into support-paimon-conne…
01bf325
Merge branch 'main' of github.com:apache/gravitino into support-paimo…
a83a406
fix
8846dc9
support partition management
c114d1c
support partition management
af0b32a
fix
79403e2
fix
1aa58cd
fix
33c6956
Merge branch 'support-paimon-connector-dml' of github.com:caican00/gr…
3512934
support hive backend
4499371
support hive backend
84f48f0
support hive backend
0960a27
support jdbc backend
c665d8b
support metadata columns
d0d0e6d
support metadata columns
7f7bbb7
support functions
a4ba49b
support functions
3e2d893
support time travel
10f6a38
support row level operations
8e540c2
support row level operations
b8235c9
support functions
70b8900
support functions
15732fa
support time travel
2a1833f
support extensions
659338f
fix
069b748
fix
d354e2c
Merge branch 'support-paimon-connector-ddl' of github.com:caican00/gr…
658f687
support paimon connector dml together
03f1a2d
Merge branch 'main' into support-paimon-connector-ddl
caican00 f0bfd60
fix
22de28e
fix
3195e8c
Merge branch 'support-paimon-connector-ddl' of github.com:caican00/gr…
e337024
fix
ce0d591
fix
c77b2f4
Merge branch 'support-paimon-connector-ddl' of github.com:caican00/gr…
1ce5e4e
fix
a5413d1
Merge branch 'support-paimon-connector-partition-management' of githu…
4f92ddd
Merge branch 'support-paimon-connector-partition-management' of githu…
eb9eab7
Merge branch 'support-paimon-connector-hive-backend' of github.com:ca…
8fa01ad
Merge branch 'support-paimon-connector-jdbc-backend' of github.com:ca…
54b41fc
Merge branch 'support-paimon-connector-function' of github.com:caican…
de7f9ae
Merge branch 'support-paimon-connector-time-travel' of github.com:cai…
977a6b9
fix
f8220e5
fix
b723ad1
Merge branch 'support-paimon-connector-ddl' of github.com:caican00/gr…
735aa2b
fix
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
57 changes: 57 additions & 0 deletions
57
...g-common/src/main/java/org/apache/gravitino/catalog/lakehouse/paimon/PaimonConstants.java
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,57 @@ | ||
/* | ||
* 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. | ||
*/ | ||
package org.apache.gravitino.catalog.lakehouse.paimon; | ||
|
||
public class PaimonConstants { | ||
|
||
// Paimon catalog properties constants | ||
public static final String CATALOG_BACKEND = "catalog-backend"; | ||
public static final String METASTORE = "metastore"; | ||
public static final String URI = "uri"; | ||
public static final String WAREHOUSE = "warehouse"; | ||
public static final String CATALOG_BACKEND_NAME = "catalog-backend-name"; | ||
|
||
public static final String GRAVITINO_JDBC_USER = "jdbc-user"; | ||
public static final String PAIMON_JDBC_USER = "jdbc.user"; | ||
|
||
public static final String GRAVITINO_JDBC_PASSWORD = "jdbc-password"; | ||
public static final String PAIMON_JDBC_PASSWORD = "jdbc.password"; | ||
|
||
public static final String GRAVITINO_JDBC_DRIVER = "jdbc-driver"; | ||
|
||
// S3 properties needed by Paimon | ||
public static final String S3_ENDPOINT = "s3.endpoint"; | ||
public static final String S3_ACCESS_KEY = "s3.access-key"; | ||
public static final String S3_SECRET_KEY = "s3.secret-key"; | ||
|
||
// OSS related properties | ||
public static final String OSS_ENDPOINT = "fs.oss.endpoint"; | ||
public static final String OSS_ACCESS_KEY = "fs.oss.accessKeyId"; | ||
public static final String OSS_SECRET_KEY = "fs.oss.accessKeySecret"; | ||
|
||
// Iceberg Table properties constants | ||
public static final String COMMENT = "comment"; | ||
public static final String OWNER = "owner"; | ||
public static final String BUCKET_KEY = "bucket-key"; | ||
public static final String MERGE_ENGINE = "merge-engine"; | ||
public static final String SEQUENCE_FIELD = "sequence.field"; | ||
public static final String ROWKIND_FIELD = "rowkind.field"; | ||
public static final String PRIMARY_KEY = "primary-key"; | ||
public static final String PARTITION = "partition"; | ||
} |
95 changes: 95 additions & 0 deletions
95
...on/src/main/java/org/apache/gravitino/catalog/lakehouse/paimon/PaimonPropertiesUtils.java
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,95 @@ | ||
/* | ||
* 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. | ||
*/ | ||
package org.apache.gravitino.catalog.lakehouse.paimon; | ||
|
||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.Locale; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
import org.apache.gravitino.storage.OSSProperties; | ||
import org.apache.gravitino.storage.S3Properties; | ||
|
||
public class PaimonPropertiesUtils { | ||
|
||
// Map that maintains the mapping of keys in Gravitino to that in Paimon, for example, users | ||
// will only need to set the configuration 'catalog-backend' in Gravitino and Gravitino will | ||
// change it to `catalogType` automatically and pass it to Paimon. | ||
public static final Map<String, String> GRAVITINO_CONFIG_TO_PAIMON; | ||
|
||
static { | ||
Map<String, String> map = new HashMap(); | ||
map.put(PaimonConstants.CATALOG_BACKEND, PaimonConstants.CATALOG_BACKEND); | ||
map.put(PaimonConstants.GRAVITINO_JDBC_DRIVER, PaimonConstants.GRAVITINO_JDBC_DRIVER); | ||
map.put(PaimonConstants.GRAVITINO_JDBC_USER, PaimonConstants.PAIMON_JDBC_USER); | ||
map.put(PaimonConstants.GRAVITINO_JDBC_PASSWORD, PaimonConstants.PAIMON_JDBC_PASSWORD); | ||
map.put(PaimonConstants.URI, PaimonConstants.URI); | ||
map.put(PaimonConstants.WAREHOUSE, PaimonConstants.WAREHOUSE); | ||
map.put(PaimonConstants.CATALOG_BACKEND_NAME, PaimonConstants.CATALOG_BACKEND_NAME); | ||
// S3 | ||
map.put(S3Properties.GRAVITINO_S3_ENDPOINT, PaimonConstants.S3_ENDPOINT); | ||
map.put(S3Properties.GRAVITINO_S3_ACCESS_KEY_ID, PaimonConstants.S3_ACCESS_KEY); | ||
map.put(S3Properties.GRAVITINO_S3_SECRET_ACCESS_KEY, PaimonConstants.S3_SECRET_KEY); | ||
// OSS | ||
map.put(OSSProperties.GRAVITINO_OSS_ENDPOINT, PaimonConstants.OSS_ENDPOINT); | ||
map.put(OSSProperties.GRAVITINO_OSS_ACCESS_KEY_ID, PaimonConstants.OSS_ACCESS_KEY); | ||
map.put(OSSProperties.GRAVITINO_OSS_ACCESS_KEY_SECRET, PaimonConstants.OSS_SECRET_KEY); | ||
GRAVITINO_CONFIG_TO_PAIMON = Collections.unmodifiableMap(map); | ||
} | ||
|
||
/** | ||
* Converts Gravitino properties to Paimon catalog properties, the common transform logic shared | ||
* by Spark connector, Gravitino Paimon catalog. | ||
* | ||
* @param gravitinoProperties a map of Gravitino configuration properties. | ||
* @return a map containing Paimon catalog properties. | ||
*/ | ||
public static Map<String, String> toPaimonCatalogProperties( | ||
Map<String, String> gravitinoProperties) { | ||
Map<String, String> paimonProperties = new HashMap<>(); | ||
gravitinoProperties.forEach( | ||
(key, value) -> { | ||
if (GRAVITINO_CONFIG_TO_PAIMON.containsKey(key)) { | ||
paimonProperties.put(GRAVITINO_CONFIG_TO_PAIMON.get(key), value); | ||
} | ||
}); | ||
return paimonProperties; | ||
} | ||
|
||
/** | ||
* Get catalog backend name from Gravitino catalog properties. | ||
* | ||
* @param catalogProperties a map of Gravitino catalog properties. | ||
* @return catalog backend name. | ||
*/ | ||
public static String getCatalogBackendName(Map<String, String> catalogProperties) { | ||
String backendName = catalogProperties.get(PaimonConstants.CATALOG_BACKEND_NAME); | ||
if (backendName != null) { | ||
return backendName; | ||
} | ||
|
||
String catalogBackend = catalogProperties.get(PaimonConstants.CATALOG_BACKEND); | ||
return Optional.ofNullable(catalogBackend) | ||
.map(s -> s.toLowerCase(Locale.ROOT)) | ||
.orElseThrow( | ||
() -> | ||
new UnsupportedOperationException( | ||
String.format("Unsupported catalog backend: %s", catalogBackend))); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,14 +35,14 @@ | |
*/ | ||
public class PaimonTablePropertiesMetadata extends BasePropertiesMetadata { | ||
|
||
public static final String COMMENT = "comment"; | ||
public static final String OWNER = "owner"; | ||
public static final String BUCKET_KEY = "bucket-key"; | ||
public static final String MERGE_ENGINE = "merge-engine"; | ||
public static final String SEQUENCE_FIELD = "sequence.field"; | ||
public static final String ROWKIND_FIELD = "rowkind.field"; | ||
public static final String PRIMARY_KEY = "primary-key"; | ||
public static final String PARTITION = "partition"; | ||
public static final String COMMENT = PaimonConstants.COMMENT; | ||
public static final String OWNER = PaimonConstants.OWNER; | ||
public static final String BUCKET_KEY = PaimonConstants.BUCKET_KEY; | ||
public static final String MERGE_ENGINE = PaimonConstants.MERGE_ENGINE; | ||
public static final String SEQUENCE_FIELD = PaimonConstants.SEQUENCE_FIELD; | ||
public static final String ROWKIND_FIELD = PaimonConstants.ROWKIND_FIELD; | ||
public static final String PRIMARY_KEY = PaimonConstants.PRIMARY_KEY; | ||
public static final String PARTITION = PaimonConstants.PARTITION; | ||
Comment on lines
+38
to
+45
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above. Why do we replicate these constants? |
||
|
||
private static final Map<String, PropertyEntry<?>> PROPERTIES_METADATA; | ||
|
||
|
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
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 do we have this constant copied into
PaimonSchemaPropertiesMetadata
?