Abdelrahman Gamal created SPARK-57855:
-----------------------------------------

             Summary: Refactor JDBC value getters into a sealed type for 
readability
                 Key: SPARK-57855
                 URL: https://issues.apache.org/jira/browse/SPARK-57855
             Project: Spark
          Issue Type: Improvement
          Components: SQL
    Affects Versions: 5.0.0
            Reporter: Abdelrahman Gamal


JdbcUtils.makeGetter maps each column type to a per-column reader. The reader 
type
JDBCValueGetter is just a type alias for (ResultSet, InternalRow, Int) => Unit, 
so
each case in makeGetter returns an anonymous function. Because of this, a getter
cannot be named or referred to, and makeGetter mixes the choice of getter with 
the
logic of each getter in one long block.

This change makes JDBCValueGetter a sealed trait with one named case per getter.
makeGetter then just selects the right getter for the column type. This makes 
the
code easier to read and maintain: each getter is a named, separate piece, and
makeGetter clearly shows only which getter is used for each type. The getter 
logic
is unchanged and all the types are private, so there is no behavior or API 
change.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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

Reply via email to