I'm trying to read from SAS IOM using Spark JDBC. Problem is that the SAS JDBC driver is a bit strange, so i need to create my own dialect:
object SasDialect extends JdbcDialect {
override def canHandle(url: String): Boolean = url.startsWith("jdbc:sasiom")
override def quoteIdentifier(colName: String): String = "\"" + colName + "\"n"
}
however , this is not enough. SAS makes a distinction between column labels (= human readable names) and column names (= names you use in a SQL query), but it seems that spark uses the column labels instead of the names in schema discovery, see JdbcUtils extract below:
while (i < ncols) {
val columnName = rsmd.getColumnLabel(i + 1)
this results in SQL errors because it tries to use the human readable column name in generated SQL code.
For SAS IOM JDBC to work, this would need to be the getColumnName instead of the getColumnLabel. Is there a way to specify this in the dialect ? I could not really find a way to hook into this, apart from wrapping the whole com.sas.rio.MVADriver and the resultsetmeta
Frank