You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@spark.apache.org by Gary Liu <ga...@gmail.com> on 2021/12/17 15:00:36 UTC

spark jdbc

In spark sql jdbc module, it's using getColumnLabel to get column names
from the remote database, but in some databases, like SAS, it returns
column description instead. Should getColumnName be used?

This is from the SAS technical support:

In the documentation,
https://docs.oracle.com/javase/7/docs/api/java/sql/ResultSetMetaData.html
(we adhere to the JDBC spec for the driver code )



getColumnLabel() Gets the designated column's suggested title for use in
printouts and displays.

getColumnName() Get the designated column's name.



In the spark code, they use



while (i < ncols) {

  val columnName = rsmd.getColumnLabel(i + 1)



The appropriate method should be rsmd.getColumnName(i+1).

-- 
Gary Liu

Re: spark jdbc

Posted by Sean Owen <sr...@gmail.com>.
I'm not sure we want to do that. If you "SELECT foo AS bar", then the
column name is foo but the column label is bar. We probably want to return
the latter.

On Fri, Dec 17, 2021 at 9:07 AM Gary Liu <ga...@gmail.com> wrote:

> In spark sql jdbc module, it's using getColumnLabel to get column names
> from the remote database, but in some databases, like SAS, it returns
> column description instead. Should getColumnName be used?
>
> This is from the SAS technical support:
>
> In the documentation,
> https://docs.oracle.com/javase/7/docs/api/java/sql/ResultSetMetaData.html
> (we adhere to the JDBC spec for the driver code )
>
>
>
> getColumnLabel() Gets the designated column's suggested title for use in
> printouts and displays.
>
> getColumnName() Get the designated column's name.
>
>
>
> In the spark code, they use
>
>
>
> while (i < ncols) {
>
>   val columnName = rsmd.getColumnLabel(i + 1)
>
>
>
> The appropriate method should be rsmd.getColumnName(i+1).
>
> --
> Gary Liu
>