dongjoon-hyun opened a new pull request, #603:
URL: https://github.com/apache/spark-connect-swift/pull/603

   ### What changes were proposed in this pull request?
   
   This PR aims to fix `Catalog` APIs to not crash on `null` values returned by 
the server, by removing all 24 force casts (`as!`) in `Catalog.swift`.
   
   - `tableType` of `SparkTable` (`listTables`, `getTable`, `listViews`, 
`getView`, etc.) falls back to an empty string, like 
`Catalog.listFunctions`/`listDatabases` already do after SPARK-60063.
   - The other required values (`name`, `isTemporary`, `partition`, table 
property keys, and the single-value results of `currentCatalog`, 
`currentDatabase`, `getCreateTableString`, `databaseExists`, etc.) now use the 
existing `Row.getAsString`/`Row.getAsBool`, which throw 
`SparkConnectError.InvalidType` instead of crashing the process.
   
   ### Why are the changes needed?
   
   Previously, these APIs force-cast the server results with `as! String`/`as! 
Bool`, which crashes the client process when the server returns `null`.
   
   ```
   Could not cast value of type 'Swift.Optional<Any>' to 'Swift.String'.
   ```
   
   For example, Apache Spark's `Catalog.listTables` returns a `Table` with 
`tableType = null` when it fails to resolve a table or view, in order to return 
partial results (see `classic/Catalog.scala`). Third-party catalogs may also 
return `null` for other fields.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. `SparkTable.tableType` is now an empty string instead of crashing when 
the server returns `null`. Other `null` required values now throw 
`SparkConnectError.InvalidType` instead of crashing. There is no API change 
because the field types of the public structs (`SparkTable`, `Database`, 
`Function`, `CatalogMetadata`, `TablePartition`) remain the same.
   
   ### How was this patch tested?
   
   Pass the CIs.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Sonnet 5.5


-- 
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