Michael Reynolds created SPARK-27265:
----------------------------------------
Summary: 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
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: [email protected]
For additional commands, e-mail: [email protected]