You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "cloud-fan (via GitHub)" <gi...@apache.org> on 2026/06/20 01:12:12 UTC

Re: [PR] [SPARK-52729][SQL][FOLLOWUP] Model table and view as a common Relation [spark]

cloud-fan commented on code in PR #56606:
URL: https://github.com/apache/spark/pull/56606#discussion_r3445136952


##########
sql/catalyst/src/main/java/org/apache/spark/sql/connector/catalog/MetadataTable.java:
##########
@@ -81,12 +82,14 @@ public Map<String, String> properties() {
 
   @Override
   public Transform[] partitioning() {
-    return info.partitions();
+    // Partitioning is a table-only concept; a view wrapped as a MetadataTable has none.
+    return info instanceof TableInfo tableInfo ? tableInfo.partitions() : new Transform[0];
   }
 
   @Override
   public Constraint[] constraints() {
-    return info.constraints();
+    // Constraints are a table-only concept; a view wrapped as a MetadataTable has none.
+    return info instanceof TableInfo tableInfo ? tableInfo.constraints() : new Constraint[0];

Review Comment:
   Two follow-ups applied:
   
   1. Renamed `TableViewCatalog` -> `RelationCatalog` (and `listTableAndViewSummaries` ->
      `listRelationSummaries`) so the catalog interface matches the `Relation` / `loadRelation`
      vocabulary -- this is the name from your Option 1 sketch.
   2. Correction to my note above: `Relation` is left **un-sealed**, not sealed. A sealed Java
      interface trips Scala's pattern-match analysis (false-positive "unreachable code" on clean
      builds), and since `Table` is already an open interface a closed hierarchy buys little.
      @uros-b's `MatchError` concern is moot regardless -- `V1Table.toCatalogTable` now uses typed
      overloads (`DelegatingTable` / `View` / `TableInfo`) instead of matching on relation subtypes.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org