Repository navigation
Conversation
pan3793
left a comment
There was a problem hiding this comment.
Review of #7718 (head 8ffa541). Verdict: request changes. The #7673 diagnosis and the Iceberg fix mechanism are verified real; the listing refactor introduces the regressions below in the same configurations the PR targets.
-
[Blocker, regression] Local temp views leak into the new v2 listing.
catalog.listTables(ns)(SparkCatalogUtils.scala:202-204) reachesV2SessionCatalog.listTables->SessionCatalog.listTables(db)withincludeLocalTempViews = true, so temp views come back asIdentifier.of(Array(), name); they are typed TABLE withTABLE_SCHEM=""(:217-232) andgetTempViews(:350-359) emits the same view a second time as VIEW. Master usedincludeLocalTempViews = falsehere. Fix: drop identifiers with an empty namespace before typing/loading. -
[Blocker, regression]
catalog.loadTable(ident)at :229 is unguarded and runs per row whenignoreTableProperties=false(the default), so the namespace-less identifier from (1) throws (requiresSinglePartNamespace/NoSuchTable) and fails the whole GetTables; any unloadable, dropped, or corrupt table does the same. It also forces per-table format I/O (Delta_delta_log, Iceberg metadata JSON) where master did one bulk HMS call. Fix: wrap inTryand degrade REMARKS to "" (or keep the session-catalog listing load-free). -
[Blocker, regression] The view probe keys
listViewsresults by the outer db (:211-215) whileSessionCatalog.listViewsalso returns local temp views, so a temp viewvmarks permanent tabledb.vas VIEW and removes it undertableTypes={TABLE}. Fix: only keepTableIdentifiers with a database. -
[Major, regression]
getSchemas("spark_catalog", ...)with a custom session catalog now returns backtick-quoted namespaces and matches the pattern against the quoted form (:126, :170-173); a DB like2024_dbis returned as`2024_db`and no longer matchable by its own pattern. Master returned raw v1 names. -
[Major, regression]
listAllNamespacesis a non-exhaustive match (:153-163) and is now reachable for the session catalog, so aTableCatalog-only session catalog throwsMatchErrorin GetSchemas where master returned v1 rows. -
[Major, new failure mode] The per-namespace
spark.sessionState.catalog.listViews(db, ...)probe callsrequireDbExists, so a custom session catalog whose namespaces are not v1-backed now fails the whole GetTables withNoSuchDatabaseException. Guard withdatabaseExistsor catch and skip the probe for that namespace. -
[Major]
hasCustomSessionCatalog(:106-109) compares case-sensitively; Spark 4.x normalizesBUILTINtobuiltin, so such a value is treated as custom. UseequalsIgnoreCase(mirrorsV2SessionCatalog.hasCustomSessionCatalog). -
[Major, behavior change]
tableTypesis now applied to ordinary v2 catalogs (:225) while view detection exists only for the session catalog, sogetTables(<v2 catalog>, ..., Array("VIEW"))goes from all-rows-typed-TABLE to empty. DSv2ViewCatalogis still immature, so covering v2 tables only is fine for this PR - please just document the limitation (non-session v2 catalogs report tables only, VIEW-only filters return empty) and drop the filter or add a test pinning the empty-result behavior. -
[Major, scope/claim] The fix guarantees only "the custom catalog can load the table". Tables delegated back to v1 (e.g.
DeltaCatalog+catalogImplementation=hive, or non-Iceberg tables under Iceberg's session catalog) still hitHiveExternalCatalog/HiveClientImpl.getStorageHandlerand the sameClassNotFoundException. Narrow the claim, or make the listing independent of per-catalog loading. -
[Major]
TABLE_CATis inconsistent within one result:catalog.name()at :231 vs the raw request string ingetTempViews(:357) andgetColumnsByCatalog, sogetTables(null, ...)mixes"spark_catalog"withnull. Align all row producers and tighten the assertions. -
[Test]
DeltaMetadataTests#get tables and viewsexercises the new path (DeltaCatalog is a custom session catalog) but passes on master, so it does not discriminate the fix. Add a case that fails without the change, or drop it. -
[Test] Nothing covers GetSchemas: reverting only the getSchemas change keeps the suites green, because the test session catalogs delegate namespaces to the v1 catalog. Add a test-only
CatalogExtensionexposing a namespace the v1 catalog cannot see. -
[Test]
IcebergMetadataTestscreatesspark_catalog.<db>namespaces and never drops them (withDatabasesonly drops unqualified names), making the exact-countget schemasassertion order-dependent. Drop them in thefinallyblocks. -
[Test]
kyuubi.operation.getTables.ignoreTablePropertieshas no coverage repo-wide; the new path has three distinct behaviors for it (:208, :225, :228). Add a test. -
[Minor] The new tests never assert
TABLE_SCHEM/TABLE_CAT; the docstring at :186-191 overstates ("returns both v1 and v2 views", "never loads the Hive storage handler") - it only covers views registered in the v1 catalog;catalog.name()andcatalog.nameare mixed in one file. -
[Minor] The new
WithSimpleHMSContainerduplicatesWithSecuredHMSContainer(drop the unusedenv, consider sharing the container def),hmsThriftUrishas no null guard, andHostPortWaitStrategyhas no startup-timeout margin. -
[Hygiene] Commit
80255d65eis tagged #7064 while the PR head/title use #7673, and the description does not describe the final diff or list the commands run. Please update the description for the final state.
8ffa541 to
5b7ec6a
Compare
|
Thanks for the thorough review. All blockers and majors are addressed, code, tests, and PR metadata are now aligned. Point-by-point:
|
5b7ec6a to
3cdd2d7
Compare
pan3793
left a comment
There was a problem hiding this comment.
Review of #7718 (head 3cdd2d7). Verdict: request changes. The previous round is addressed; 1-3 need to be addressed in this PR, and 1 and 2 are regressions in the configuration this PR targets. "Previous item N" refers to my last review; line numbers refer to SparkCatalogUtils.scala unless noted.
-
[Major, regression] With a custom session catalog, schema and table patterns are matched as case-sensitive Java regex against DSv2 names (
:176-179via:207,:187-190via:127,:259). Master listed through the v1 catalog, which matches case-insensitively, sogetTables("spark_catalog", "DEFAULT", "MY_TABLE", null)andgetSchemas("spark_catalog", "DEFAULT")return rows on master and nothing here. The view probe at:270still uses v1 matching, so the two filters disagree within one request. Session catalog identifiers are case-insensitive; compile these patterns withPattern.CASE_INSENSITIVEforspark_catalog. -
[Major, regression] Previous item 2 is fixed for failures, but the per-table format I/O noted there remains. With
ignoreTableProperties=false(default), every custom session catalog (Iceberg, Delta, Hudi, Paimon) callstc.loadTableper listed table just for REMARKS (:298), where master made onegetTablesByNameHMS call per database; e.g.DeltaCatalogwith 5k tables turns one RPC into 5k_delta_logreads on every GetTables. Per namespace:- Try the batched v1
sessionCatalog.getTablesByNamefirst. It returns both the VIEW type and the comment (Iceberg pushes table properties, includingcomment, into HMS params), so REMARKS is unchanged and thedatabaseExists+listViewsprobe (:263-277) is only needed on the fallback path. - Fall back to the current per-table path for namespaces where the batch throws (the #7673 case) and for identifiers it does not return (DSv2-only tables).
- Try the batched v1
-
[Major, perf] SPARK-52109 (4.1.0) added
TableCatalog.listTableSummaries, which returns table types without loading tables when the catalog implements it. Since this PR reworks bothTableCatalogbranches (:254,:311), use it there forignoreTableProperties=true, sotableTypesis honored without per-table loads:- Detect the method by reflection, not by Spark version, since vendors backport.
- Call it only when the catalog has its own implementation. Calling it unconditionally turns today's single
listTablesinto N loads and brings #7673 back for catalogs that don't implement it (e.g.DeltaCatalogviaDelegatingCatalogExtension). A simple check is enough as long as the code comment explains it, e.g.// SPARK-52109 (4.1.0): added TableCatalog.listTableSummaries. Detect it by reflection // instead of by Spark version, since vendors may backport it. Use it only when the // catalog provides its own implementation, because the TableCatalog default calls // loadTable for every table, which is what this path avoids. A declaring class that // directly implements TableCatalog counts as not implemented: scalac emits a forwarder // to the interface default in such Scala classes (e.g. V2SessionCatalog). Real // implementations in such classes (e.g. JDBCTableCatalog) are skipped, which only // loses the optimization. private def implementsListTableSummaries(tc: TableCatalog): Boolean = try { val owner = tc.getClass.getMethod("listTableSummaries", classOf[Array[String]]) .getDeclaringClass owner != classOf[TableCatalog] && !owner.getInterfaces.contains(classOf[TableCatalog]) } catch { case _: NoSuchMethodException => false }
- Map
VIEWandMETRIC_VIEWto VIEW and the rest to TABLE, filter bytableTypes, keep REMARKS empty, and fall back tolistTablesper namespace on failure. - Today this covers Iceberg 1.12.0
SparkCatalogand gives real VIEW types for non-session v2 catalogs, resolving the TODO at:317; new implementations are picked up with no code change. Iceberg'sSparkSessionCatalog(Spark 4.2) is detected but forwards toV2SessionCatalog's default, so it stays per-table until Spark implements it there. - Update the
kyuubi.operation.getTables.ignoreTablePropertiesdoc (it saystableTypesis ignored) and regeneratesettings.md.
-
[Minor]
TryrethrowsLinkageError(:298), so aNoClassDefFoundError(SerDe or handler class present, a dependency missing, the same upgrade pattern as #7673) still fails the whole GetTables. Catch it explicitly, also in the fallback from 2. -
[Minor, refines previous item 10]
getTempViewslabels temp views with the requested or current catalog (:379), but temp views live in the session catalog andgetColumnslabels themspark_catalog(:435,:454). Withspark.sql.defaultCatalog=hadoop_prod,getTables(null, "global_temp", "%", ["VIEW"])returnsTABLE_CAT=hadoop_prod, andhadoop_prod.global_temp.vdoes not resolve. UseSESSION_CATALOGfor these rows. -
[Test]
IcebergOperationSuite.scala:30andSparkIcebergOperationSuite.scala:35repeat the same 14-entryextraConfigs, mostly re-listingIcebergSuiteMixin's entries, andIcebergMetadataTests(:28) now needs an HMS-backedspark_catalogwithout declaring it. Move the HMS overrides into one mixin built onsuper.extraConfigs, and require it fromIcebergMetadataTestswith a self-type. -
[Minor]
STARTUP_TIMEOUT = 60s(WithSimpleHMSContainer.scala:50) equals testcontainers' default wait timeout, so the margin from previous item 16 has no effect. Use a larger value, e.g. 3 minutes. -
[Nit] Unrelated cosmetic changes: three section banners are re-padded while the Columns one (
:405) is not, and thegetCatalogs/getSchemasscaladocs are reworded. Revert, or make the banners consistent.
|
Thanks for another round of careful review — both regression catches were spot on. All items are addressed; point-by-point: 1. [Major, regression] Case-sensitive pattern matching with a custom session catalog Done. For 2. [Major, regression] Per-table loadTable just for REMARKS Done as prescribed. With ignoreTableProperties=false (default), 3. [Major, perf] Use listTableSummaries for ignoreTableProperties=true — deviation on the detection check Done for both TableCatalog branches, with one deviation I'd like your input on. If you see anything improper with the current approach, I'm happy to switch back. Why not the Java declaring-class check — it has two false negatives:
The Scala-reflection probe — scalac emits forwarders to interface defaults only as bytecode, never in the Scala symbol table, so A practical side benefit: because the probe correctly detects The rest is as prescribed:
4. [Minor] LinkageError from Try Done. The 5. [Minor] getTempViews labels temp views with the wrong catalog Done. Temp view rows are now labeled 6. [Test] Duplicated extraConfigs / undeclared HMS dependency Done. The HMS overrides moved into 7. [Minor] STARTUP_TIMEOUT equals the testcontainers default Done — bumped to 3 minutes in WithSimpleHMSContainer. 8. [Nit] Cosmetic banner/scaladoc changes Banners are now consistent across all four sections, and the two scaladoc rewordings are reverted to master's wording. |
pan3793
left a comment
There was a problem hiding this comment.
Thanks, all 8 items are addressed. On the detection deviation: keep the Scala-reflection check. I verified it on Spark 4.1.0: V2SessionCatalog (scalac forwarder only) is reported as not implemented and JDBCTableCatalog as implemented, which the declaring-class check gets wrong. Keeping the view-type TODO is fine given your reasoning.
Remaining, line numbers refer to SparkCatalogUtils.scala:
- [Major] GetColumns only half adopts case-insensitive matching for
spark_catalog: the schema pattern goes throughcompilePattern(:493), the table pattern does not (:494). With a custom session catalog,getTables("spark_catalog", "DEFAULT", "MY_TABLE", null)returns the table, whilegetColumnswith the same patterns returns no columns. UsecompilePatternfor the table pattern too, and cover it in the uppercase-pattern test. The column pattern stays case-sensitive, as on the v1 path. - [Minor]
implementsListTableSummaries(:456) catches onlyNonFatal. If a member signature in the catalog's class hierarchy references a class absent at runtime (e.g. an optional dependency), the catalog still loads and works, but resolving its members throwsNoClassDefFoundError, and GetTables fails where it used to just calllistTables.attemptexists for exactly this; use it here too. - [Test] The "false" test uses
DummySessionCatalog, which extends a Java class and so has no forwarder; nothing in the suite covers the case the Scala reflection exists for. Also assert!implementsListTableSummaries(new V2SessionCatalog(spark.sessionState.catalog)), which carries a forwarder on Spark 4.1+. - [Nit] The
ignoreTablePropertiesdoc says "returning table identities only", which contradicts honoringtableTypes, and "view probe" is internal. Suggest: "Speed up theGetTablesoperation by not loading table metadata:REMARKSis left empty, andtableTypesis honored only when the catalog implements Spark'slistTableSummaries(SPARK-52109, 4.1.0); otherwise all entries are reported asTABLE." - [Hygiene] Please update the PR description for the final state: batched v1 lookup with per-table fallback,
listTableSummaries, case-insensitive matching forspark_catalog, temp views labeledspark_catalog, and theignoreTablePropertiesdoc change. Theget tables with ignoreTablePropertiesentry still says thetableTypesfilter is skipped.
|
Thanks for another round of professional review, and especially for verifying the probe on Spark 4.1.0 yourself — that forwarder case is exactly what the suite was missing, and it is now covered (item 3). All items are addressed; point-by-point: 1. [Major] GetColumns only half adopts case-insensitive matching Done. 2. [Minor] implementsListTableSummaries catches only NonFatal Done. The probe now runs inside 3. [Test] Nothing in the suite covers the forwarder case Done — asserted as suggested: 4. [Nit] ignoreTableProperties doc Done — adopted the suggested wording verbatim and regenerated 5. [Hygiene] PR description Done. The description now reflects the final state: batched v1 lookup with per-table fallback, the |
pan3793
left a comment
There was a problem hiding this comment.
LGTM. @wangzhigang1999 do you want to have another look? I think we should include this in 1.13
|
cc @maron546, do you have a chance to verify if this patch resolves your issue? |
wangzhigang1999
left a comment
There was a problem hiding this comment.
I verified the #7673 fix on Spark 3.5.8 with Iceberg 1.11.0. With the legacy Hive storage handler missing, the baseline failed GetTables. This patch listed the Iceberg table and the other objects in the same schema.
Before merging
getTablesmisclassifies views on fallback. With a viewvand an Iceberg tablev_icethat triggers the fallback, aVIEWfilter returnsvfor"v"and zero rows for"v%".listMatchingTablesalready applies the Java regex. Could we callsessionCatalog.listViews(db, "*")and check those names only for unmatched single-level identifiers? L373–409getSchemas(null, "prefix%")dropsprefix. With the built-in catalog, the baseline returnsprefix,prefixx, andprefixxyz. The patch returns only the latter two. JDBC%can match zero characters, but this branch passes the converted regexprefix.*tolistDatabases. Please preserve that match and cover the null-catalog call. I reproduced this with both Hive and in-memory catalogs. L127–132getColumnscannot use the schema name returned bygetSchemas. For a schema named2026, passingTABLE_SCHEMstraight intogetColumnsreturnedidon the baseline and zero rows on this patch.getSchemasnow returns the raw name, whilegetColumnsstill matches against the backtick-quoted form. Please use the same naming convention forspark_catalogacross all three calls and covergetSchemas→getTables→getColumnsin the quoted-name test. L489–499
Non-blocking follow-ups
- With
JDBCTableCatalogasspark_catalog, SQL reads the Derby table, butgetTablesreports the type and comment of a same-named Hive view. I saw the same behavior on the baseline. We can skip the V1 batch lookup and view probe for standalone (non-CatalogExtension) catalogs in a follow-up. L366–397 getTables("other", "global_temp", ...)still includes a session-catalog temp view. This patch fixes itsTABLE_CATlabel. The remaining follow-up is to omit the row when the caller explicitly requests another catalog. L525–530
pan3793
left a comment
There was a problem hiding this comment.
Fresh pass over the full diff at 63153e1. I agree with items 1-3 of #7718 (review) and need them fixed before merge. I verified the root cause on Spark 4.1.0: the v1 pattern APIs prepend (?i) and expand * to .*, so the converted prefix.* becomes prefix..*; listDatabases("prefix.*") returns only prefixx, and listViews("default", "v.*") misses v. This PR already reworks most of these paths, so please also fix the pre-existing issues in items 6-8 here.
Notes on those fixes, line numbers refer to SparkCatalogUtils.scala:
- Fallback view probe (
:373-381): the helper from item 2 fixes the pattern. Also run the probe only when the batch fails, since an identifier a successful batch did not return is not in the metastore, and only for single-level identifiers: a DSv2 tablea.b.vis currently typed VIEW whenever v1 databaseahas a viewv. getSchemas(:132): add one helper that rewrites the converted regex for v1 calls,pattern.replace(".*", "*"). Spark'sStringUtils.filterPatternand HMS'sObjectStoreadd(?i)and expand*themselves, so this keeps the case-insensitive match and the filtering on the HMS side; on 4.1.0,listDatabases("PREFIX*")returnsprefixandprefixx.getGlobalTempViewManager(:145) also matches case-sensitively, soGLOBAL_TEMPmissesglobal_tempwhileDEFAULTmatchesdefault; usecompilePatternthere.getColumnsByCatalog(:491-499): besides raw names forspark_catalog, skip identifiers with an empty namespace, aslistMatchingTablesdoes.V2SessionCatalog.listTablesreturns local temp views with an empty namespace andloadTablerejects them (REQUIRES_SINGLE_PART_NAMESPACEon 4.1.0), sogetColumns("spark_catalog", "default", "%", "%")fails whenever the session has a temp view. Temp view columns already come fromgetColumnsByLocalTempViews. Cover it with a temp view in the session.
New:
- [Test] Nothing exercises the batched v1 lookup end to end.
HMSIcebergSuiteMixin.scala:34setsiceberg.engine.hive.enabled=trueand the Iceberg Spark runtime does not shipHiveIcebergStorageHandler, so every namespace holding an Iceberg table takes the fallback; the unit fallback test fails the batch through a missing v1 database. Add a table created withTBLPROPERTIES ('engine.hive.enabled'='false')in its own namespace so the batch succeeds, assert the same TABLE_TYPE and REMARKS as on the fallback, and comment at:34that the setting reproduces #7673. - [Minor] A failed batch is dropped silently (
:396,:402), and the namespace degrades to oneloadTableper table. Log the cause once per namespace at warn so a slow GetTables can be traced.
Pre-existing, please fix here:
- [Minor] The other v1 pattern calls get the same converted regex, so a trailing
%never matches zero characters there either: builtin GetTables (:222,:231), temp views (:549,:551,:582,:599), the builtin branch ofgetColumnsByCatalog(:507,:509), andGetFunctions.scala:68-69. Use the helper from item 2 at each, and cover a table, a temp view and a function whose name equals the prefix. - [Minor]
getCatalogTablesOrViews(:218): makenamespacesalazy val. The builtin branch does not use it, but the eager call still lists all databases, with onedatabaseExistseach, on every GetTables. - [Minor] The builtin branch of
getColumnsByCatalog(:505) is unreachable, sinceV2SessionCatalogmatchescase tc: TableCatalogfirst, so builtin GetColumns runs oneloadTableper table. Move it first with the!hasCustomSessionCatalogguard fromgetCatalogTablesOrViews, and passincludeLocalTempViews = false(:509), as temp view columns come fromgetColumnsByLocalTempViews.getTablesByNamereturns views with their schema, asloadTabledoes, and the branch already emits raw names, so its rows match what item 3 asks for.
pan3793
left a comment
There was a problem hiding this comment.
Thanks, all 8 items are addressed in 1d6e687, and c45aa5f fixes the temp view DDL that failed the Spark 4.0 and 4.1 jobs. Findings from a fresh pass over the full diff are inline, plus:
- [Hygiene] Please update the title and description for the final scope: the trailing
%fix in the builtin GetSchemas/GetTables/GetColumns/GetFunctions and temp view paths, the batched builtin GetColumns, the temp view GetColumns fix, and the new and renamed tests. Suggested title:[KYUUBI #7673] Fix Spark engine metadata operations with custom session catalog.
| } | ||
| } | ||
|
|
||
| test("get functions whose names equal the pattern prefix") { |
There was a problem hiding this comment.
[Test] This also runs in TrinoFrontendSuite, and the Trino JDBC driver (411) throws NotImplementedException from getFunctions, so that suite will fail. Move it to SparkOperationSuite, next to get functions (:306).
| }, | ||
| v1Candidates.filterNot(ident => byName.contains(joinKey(ident)))) | ||
| case Failure(e) => | ||
| warn( |
There was a problem hiding this comment.
[Minor] This warn also fires for namespaces the metastore does not have, e.g. DSv2-only namespaces of a custom catalog: getTablesByName checks the database first and throws, so every GetTables logs a stack trace per such namespace. In the Failure branch, check databaseExists once, skip the warn when it is absent, and reuse the result for the view probe (:413).
| } | ||
| } | ||
| identifiers.flatMap { ident => | ||
| val table = tc.loadTable(ident) |
There was a problem hiding this comment.
[Minor] loadTable is unguarded, so one table that fails to load (the v1-delegated ones described under Limitations) fails GetColumns for all matched tables, while GetTables degrades the same table to an empty REMARKS. Use attempt, warn, and skip its columns. Pre-existing, but the same inconsistency this PR resolves for GetTables.
| } | ||
| } | ||
|
|
||
| // Rewrites the Java regex produced by `toJavaRegex` back into a SQL-like pattern: the v1 |
There was a problem hiding this comment.
[Nit] This comment and the test name in SparkCatalogUtilsSuite call the result a SQL-like pattern, but the v1 APIs take Hive-style patterns (* and |, the rest is regex). Suggest: "Converts the regex from toJavaRegex to the pattern form of the v1 catalog APIs, which prepend (?i) and expand * themselves."
| override protected def extraConfigs: Map[String, String] = super.extraConfigs ++ Map( | ||
| "spark.sql.catalogImplementation" -> "hive", | ||
| "spark.hadoop.hive.metastore.uris" -> hmsThriftUris, | ||
| "spark.sql.catalog.spark_catalog.uris" -> hmsThriftUris, |
There was a problem hiding this comment.
[Nit] Iceberg's property is uri, so spark.sql.catalog.spark_catalog.uris has no effect; the metastore URI comes from the line above. Remove it.
|
@pan3793 @wangzhigang1999 Thanks for the careful reviews and for verifying the fix empirically. The latest commits address the remaining feedback, in short:
The two non-blocking follow-ups are left for follow-up PRs, as suggested. The failing jobs ( |
1. GetColumns skips a table whose schema fails to resolve, and loads the tables of the builtin catalog one by one, since getTablesByName returns raw CHAR/VARCHAR and misses columns not stored in the metastore. 2. GetTables on non-session catalogs degrades REMARKS of a table that fails to load. 3. GetTables on a custom session catalog matches the table type before loading a table, and tolerates failed metastore database checks and view listings. 4. Probe listTableSummaries once per operation. 5. GetColumns tolerates a local temp view dropped after being listed. Assisted-by: Claude Opus 5.5
1. GetTables skips the v1 batch lookup and view probe for a standalone session catalog, i.e. not a CatalogExtension, as a same-named v1 table or view must not decide the type and comment of its tables. 2. GetTables and GetColumns omit temp views when another catalog is requested. Assisted-by: Claude Opus 5.5
|
@maomaodev I just put 2 commits to fix what I'm finding directly. @wangzhigang1999 could you please take another look? |
wangzhigang1999
left a comment
There was a problem hiding this comment.
LGTM. I re-tested all five issues from my previous review on our Kubernetes cluster with Spark 3.5.8 and Iceberg 1.11.0. All five passed on c10db7b. Thanks for the fixes!
|
Thanks @pan3793 @wangzhigang1999 for the fixes and verification. The implementation is now more robust and performs better, and the PR description is updated to the final state. |
|
Merge Summary:
Posted by |
Why are the changes needed?
The thrift
GetSchemas/GetTablesoperations assumedspark_catalogis always the builtin V1 session catalog and listed databases/tables viaspark.sessionState.catalog. When a custom session catalog is configured, e.g.these operations bypass the DSv2 catalog APIs (
SupportsNamespaces/TableCatalog) and the V1 session catalog path cannot even parse the V2 table metadata the custom catalog persists in HMS - it may return wrong results, or throw and fail the whole request. #7673 is a real-world example:GetTablesfails withClassNotFoundException: org.apache.iceberg.mr.hive.HiveIcebergSerDewhen the V1HiveExternalCatalogtries to load tables registered by Iceberg withstorage_handler = org.apache.iceberg.mr.hive.HiveIcebergStorageHandler.Two more defects, which the builtin catalog has too, are fixed along the way:
toJavaRegex, while those APIs compile Hive-style patterns themselves, so a trailing%could no longer match zero characters: a table, a temp view or a function whose name equals the pattern prefix went missing. The regex is now converted back viatoV1Pattern, covering the builtinGetSchemas/GetTables,GetFunctionsand the temp view paths;GetColumnsfailed on local temp views (they surface with an empty namespace) and did not resolve the raw, unquoted namesGetTablesfeeds back, breaking thegetSchemas→getTables→getColumnsround trip for identifiers needing quotes.This patch routes
GetSchemas/GetTablesthrough the DSv2 catalog APIs whenspark_catalogis a custom session catalog, keeping parity with the v1 path where it matters:spark_catalog(GetColumnsand theglobal_tempschema included; column patterns stay case-sensitive as before);CatalogExtension(e.g. Iceberg'sSparkSessionCatalog, Delta'sDeltaCatalog), table types and REMARKS are resolved with one batched v1 lookup (getTablesByName) per namespace, falling back to per-table loading when the batch fails, so a single unloadable table degrades REMARKS instead of failing the whole request (the [Bug] Legacy Iceberg tables fail with Kyuubi 1.11.1 and Iceberg 1.10.0 #7673 case, includingLinkageError); a failed view probe degrades views toTABLElikewise;CatalogExtension, e.g. Iceberg'sSparkCatalog) does not delegate to the v1 catalog, so the v1 lookup and view probe are skipped, and a same-named v1 table or view no longer decides the type and REMARKS of its tables;tableTypesare not loaded;GetColumnsskips the columns of a table whoseloadTableor schema resolution fails instead of failing all matched tables;GetTableson non-session v2 catalogs degrades REMARKS of such a table likewise;spark_catalog, keeping the rows resolvable when another catalog is the current one, and are omitted fromGetTablesandGetColumnswhen another catalog is requested; temp view columns are read from the stored view metadata rather than the view plan - a view stored as SQL text resolves to an unanalyzed plan whose schema is unreadable - so local temp view columns surface with a nullTABLE_SCHEMthat resolves back, and global temp view columns, silently empty before, surface too;kyuubi.operation.getTables.ignoreTablePropertiesoption now honorstableTypesvia Spark'slistTableSummaries(SPARK-52109, 4.1.0+) when the catalog implements it — detected by reflection, since vendors may backport — and its doc is updated accordingly.How was this patch tested?
SparkMetadataTests,SparkOperationSuite: schemas, tables, temp views and functions whose names equal the pattern prefix;GetColumnson global temp views, VARCHAR/CHAR columns, and columns not stored in the metastore.IcebergMetadataTests(real HMS):spark_catalogandhadoop_prodlisting, view detection,tableTypes, the batched v1 lookup and its fallback, temp views, and names needing quotes.SparkCatalogUtilsSuite: DSv2-only namespaces, case-insensitive patterns, unloadable tables, and pattern conversion.SummariesCatalogUtilsSuite(Derby-backedJDBCTableCatalog):listTableSummaries, standalone session catalogs, temp view scoping, and unloadable tables in a non-session catalog.spark_catalogset toSparkSessionCatalogover HMS:beeline -u "jdbc:hive2://<kyuubi-host>:<port>/" -n <user> -e "!tables"threwClassNotFoundException: org.apache.iceberg.mr.hive.HiveIcebergStorageHandlerfor a table registered with that handler; it now returns the table asTABLEwith emptyREMARKS, and views asVIEW.Limitations
TABLE). WithignoreTableProperties=truethetableTypesfilter is applied on thelistTableSummariespath, but with full table properties it is not applied to them, so aVIEW-only request still returns those tables typedTABLE(noVIEWrows are produced by the catalog itself). DSv2ViewCatalogis still immature, so covering v2 tables only is intentional for this PR.TABLE, and whenloadTablefails for them — includingLinkageErrorfrom missing SerDe/handler dependencies, the [Bug] Legacy Iceberg tables fail with Kyuubi 1.11.1 and Iceberg 1.10.0 #7673 case —REMARKSdegrades to "" andGetColumnsskips their columns (logged at warn).spark_catalogreports tables only (all rows typedTABLE), unlessignoreTableProperties=truetakes thelistTableSummariespath, and loads each table for REMARKS, as non-session v2 catalogs do, since DSv2 has no batch API that returns comments. Setkyuubi.operation.getTables.ignoreTableProperties=trueto skip loading.!tablesand!columnsof beeline, do not see temp views when the current catalog is notspark_catalog.Was this patch assisted by generative AI tooling?
Assisted-by: GLM-5.3
Assisted-by: Claude Opus 5.5
Co-authored-by: Cheng Pan chengpan@apache.org