[ 
https://issues.apache.org/jira/browse/SPARK-27265?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16800389#comment-16800389
 ] 

Michael Reynolds commented on SPARK-27265:
------------------------------------------

PR is here https://github.com/apache/spark/pull/24199

> Provide convenience accessors for values by Column Name
> -------------------------------------------------------
>
>                 Key: SPARK-27265
>                 URL: https://issues.apache.org/jira/browse/SPARK-27265
>             Project: Spark
>          Issue Type: Improvement
>          Components: SQL
>    Affects Versions: 2.4.0
>            Reporter: Michael Reynolds
>            Priority: Minor
>
> There are convenient methods for accessing SQL primitive values by column 
> index such as *getDouble*, *getBoolean*, *getTimestamp*, etc. 
>  
> However, when doing pivot operations sometimes it is easier to code it 
> against column names instead of column indexes. When doing this, there is no 
> way to conveniently access the values which leads to really annoying 
> boilerplate code such as:
> {code:scala}
> desc.flatMap(row => {
>    val metric = row.getAs[String](columns.head)
>    columns.tail.map(columnName => (metric, columnName, 
> row.getAs[String].(columnName).toDouble))
> }).toDF("metric", "field", "value")
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org
For additional commands, e-mail: issues-h...@spark.apache.org

Reply via email to