Details
-
Wish
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
4.0.0
-
None
-
None
Description
Currently, in Apache Spark's JdbcUtils (across all versions, including Spark 4), there is no support for complex types like StructType, MapType, except for ArrayType. This limitation is evident in the private methods makeGetter and makeSetter.
As Spark provides the ability to implement custom dialects, users cannot implement custom handling for these complex types because the methods are private and they encounter the following error:
org.apache.spark.SparkSQLException: Unsupported type <complex_type>.
The suggestion is to change the way these methods are called. Specifically, the getter/setter methods should be able to be provided by the `JdbcDialect`, rather than only being hardcoded in `JdbcUtils`.
I suppose it can be done in one of two ways:
1. Modify the makeGetter and makeSetter methods to delegate to the dialect
class JdbcUtils {
def makeGetter(args): Option[Getter] = {
dialect.makeGetter(args).orElse {
...
}
}
def makeSetter(args): Option[Setter] = {
dialect.makeSetter(args).orElse {
...
}
}
}
2. Move the makeGetter/makeSetter methods out of JdbcUtils into JdbcDialect, allowing custom dialects to override them.
abstract class JdbcDialect { def makeGetter(args): Option[Getter] def makeSetter(args): Option[Setter] } object JdbcUtils { def getGetter(args): Option[Getter] = { // logic to fetch getter from JdbcDialect } def getSetter(args): Option[Setter] = { // logic to fetch setter from JdbcDialect } }
Attachments
1.
|
Add support for StructType and MapType in JdbcUtils | Open | Unassigned |