rahil-c commented on code in PR #1862:
URL: https://github.com/apache/polaris/pull/1862#discussion_r2181022029
##########
plugins/spark/v3.5/spark/src/main/java/org/apache/polaris/spark/utils/PolarisCatalogUtils.java:
##########
@@ -87,6 +119,32 @@ public static Table loadSparkTable(GenericTable
genericTable) {
provider, new CaseInsensitiveStringMap(tableProperties),
scala.Option.empty());
}
+ public static Table loadHudiSparkTable(GenericTable genericTable, Identifier
identifier) {
+ SparkSession sparkSession = SparkSession.active();
+ Map<String, String> tableProperties = Maps.newHashMap();
+ tableProperties.putAll(genericTable.getProperties());
+ tableProperties.put(
+ TABLE_PATH_KEY,
genericTable.getProperties().get(TableCatalog.PROP_LOCATION));
+ String namespacePath = String.join(".", identifier.namespace());
+ TableIdentifier tableIdentifier =
+ new TableIdentifier(identifier.name(), Option.apply(namespacePath));
+ CatalogTable catalogTable = null;
+ try {
+ catalogTable =
sparkSession.sessionState().catalog().getTableMetadata(tableIdentifier);
+ } catch (NoSuchDatabaseException e) {
+ throw new RuntimeException(
+ "No database found for the given tableIdentifier:" +
tableIdentifier, e);
+ } catch (NoSuchTableException e) {
+ LOG.debug("No table currently exists, as an initial create table");
+ }
+ return new HoodieInternalV2Table(
Review Comment:
`PolarisCatalogUtils.loadSparkTable` seems to be to return something that is
a child of Spark `Table`, as it invoked by the `PolarisSparkCatalog#loadTable`
https://github.com/apache/polaris/blob/main/plugins/spark/v3.5/spark/src/main/java/org/apache/polaris/spark/PolarisSparkCatalog.java#L67
When checking the hudi code base the only class I see that extends this
`Table` is the `HoodieInternalV2Table`
https://github.com/apache/hudi/blob/master/hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/spark/sql/hudi/catalog/HoodieInternalV2Table.scala#L44
And when checking the hudi code base i did not see any util class for
providing the `HoodieInternalV2Table` hence why I had to construct it in this
manner.
--
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]