JingsongLi commented on code in PR #7860:
URL: https://github.com/apache/paimon/pull/7860#discussion_r3251861467
##########
paimon-spark/paimon-spark-common/src/main/java/org/apache/paimon/spark/SparkCatalog.java:
##########
@@ -389,6 +387,65 @@ public boolean dropTable(Identifier ident) {
}
}
+ @Override
+ public StagedTable stageCreate(
+ Identifier ident,
+ StructType schema,
+ Transform[] partitions,
+ Map<String, String> properties)
+ throws TableAlreadyExistsException, NoSuchNamespaceException {
+ return stageCreateDirectly(ident, schema, partitions, properties);
+ }
+
+ @Override
+ public StagedTable stageReplace(
+ Identifier ident,
+ StructType schema,
+ Transform[] partitions,
+ Map<String, String> properties)
+ throws NoSuchNamespaceException, NoSuchTableException {
+ return stageReplaceInternal(ident, schema, partitions, properties);
+ }
+
+ @Override
+ public StagedTable stageCreateOrReplace(
+ Identifier ident,
+ StructType schema,
+ Transform[] partitions,
+ Map<String, String> properties)
+ throws NoSuchNamespaceException {
+ try {
+ return stageReplaceInternal(ident, schema, partitions, properties);
+ } catch (NoSuchTableException e) {
+ try {
+ return stageCreate(ident, schema, partitions, properties);
+ } catch (TableAlreadyExistsException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+ }
+
+ private StagedTable stageReplaceInternal(
+ Identifier ident,
+ StructType schema,
+ Transform[] partitions,
+ Map<String, String> properties)
+ throws NoSuchNamespaceException, NoSuchTableException {
+ org.apache.paimon.catalog.Identifier tableIdent = toIdentifier(ident,
catalogName);
+ Schema targetSchema = toInitialSchema(schema, partitions, properties);
+
+ try {
+ catalog.replaceTable(tableIdent, targetSchema, false);
Review Comment:
We need to be more secure. If the RESTCatalog returns an unimplemented
exception, we should revert back to a working implementation.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]