COLDMANYU commented on code in PR #14932:
URL: https://github.com/apache/gravitino/pull/14932#discussion_r4626258296
##########
spark-connector/spark-common/src/main/spark35/org/apache/gravitino/spark/connector/paimon/PaimonPropertiesConverter.java:
##########
@@ -64,4 +66,35 @@ public Map<String, String>
toGravitinoTableProperties(Map<String, String> proper
public Map<String, String> toSparkTableProperties(Map<String, String>
properties) {
return new HashMap<>(properties);
}
+
+ /**
+ * Converts the Spark table properties of a table created in a Paimon
catalog with the Hive
+ * backend, the only Paimon backend that can create format tables. It
follows Paimon's own
+ * SparkCatalog: a file format provider (csv, json, orc, parquet, ...) from
the USING clause makes
+ * a format table of that format, "paimon" or no provider keeps a Paimon
table, and LOCATION
+ * becomes the Paimon table path. Other backends keep the properties as they
are.
+ *
+ * @param properties the Spark table properties, already converted by {@link
+ * #toGravitinoTableProperties(Map)}.
+ * @return the table properties to pass to the Hive backend.
+ */
+ Map<String, String> toHiveBackendTableProperties(Map<String, String>
properties) {
+ Map<String, String> tableProperties = new HashMap<>(properties);
+ String provider = tableProperties.remove(TableCatalog.PROP_PROVIDER);
+ if (StringUtils.isNotBlank(provider)
+ &&
!PaimonPropertiesConstants.PAIMON_PROVIDER.equalsIgnoreCase(provider)) {
Review Comment:
Thanks, good catch. Fixed in 649e1c97d: the conversion now uses the same
check as Paimon's `SparkCatalog` (`SparkSource.FORMAT_NAMES`, i.e. the formats
of `FormatTable.Format` in the Paimon version on the classpath). With Paimon
1.2, `USING text` now creates a Paimon table, as it does through Paimon's own
catalog.
Added a regression test for `text` in `TestPaimonPropertiesConverter` and
`SparkPaimonCatalogHiveBackendIT`
(`testCreateTableUsingUnsupportedFormatIsNotAFormatTable`, which also writes
and reads a row). Both fail without the fix.
--
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]