mchades commented on code in PR #13550:
URL: https://github.com/apache/gravitino/pull/13550#discussion_r4480682832
##########
catalogs/hive-metastore-common/src/main/java/org/apache/gravitino/hive/client/HiveShim.java:
##########
@@ -334,4 +369,121 @@ protected EnvironmentContext doNotUpdateStatsContext() {
return new EnvironmentContext(
Collections.singletonMap(StatsSetupConst.DO_NOT_UPDATE_STATS,
StatsSetupConst.TRUE));
}
+
+ /**
+ * Resolves storage schemas and converts a table without loading column
constraints.
+ *
+ * @param catalogName The Hive catalog name.
+ * @param table The metastore table.
+ * @return The converted table, retaining its original derived schema for
alters.
+ * @throws TException If the metastore cannot resolve the schema.
+ */
+ protected HiveTable convertTable(String catalogName, Table table) throws
TException {
+ List<Column> original = resolveDerivedColumns(catalogName, table);
+ HiveTable converted = HiveTableConverter.fromHiveTable(table);
+ converted.setOriginalStorageColumns(original);
+ return converted;
+ }
+
+ /**
+ * Resolves only tables containing the SerDe-derived type marker.
+ *
+ * @param catalogName The Hive catalog name.
+ * @param table The metastore table to update in memory.
+ * @return A copy of the original storage columns, or an empty list for an
ordinary table.
+ * @throws TException If the metastore cannot resolve the schema.
+ */
+ protected List<Column> resolveDerivedColumns(String catalogName, Table
table) throws TException {
+ if (!hasDerivedColumnTypes(table)) {
+ return Collections.emptyList();
+ }
+ List<Column> original =
+ table.getSd().getCols().stream()
+ .<Column>map(
+ field ->
+ Column.of(
+ field.getName(),
+ Types.UnparsedType.of(field.getType()),
+ field.getComment()))
+ .toList();
+ try {
+ replaceDerivedColumns(table, getFields(catalogName, table.getDbName(),
table.getTableName()));
+ } catch (MetaException e) {
+ MetaException failure = new MetaException(derivedSchemaError(table));
Review Comment:
**minor: SerDe failures can be misclassified based on the table name.**
For `db.network_events`, this message contains `network`, so
`HiveExceptionConverter.isConnectionKeyword` converts the schema-resolution
failure to `ConnectionFailedException`; REST then reports HTTP 502 despite HMS
being reachable. I reproduced this for both the wrapped `MetaException` and the
unresolved-result `IllegalArgumentException`. The same failures for `db.csv`
retain their expected types. The configuration guidance survives, but the
connection diagnosis is misleading.
Please classify these SerDe failures before the generic connection-keyword
check, and add coverage for names containing `network` or `connect` in both
failure paths.
--
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]