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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to