You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Alexandros Mavrommatis (Jira)" <ji...@apache.org> on 2021/10/07 15:04:00 UTC
[jira] [Updated] (SPARK-36947) Exception when trying to access Row
field using getAs method
[ https://issues.apache.org/jira/browse/SPARK-36947?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Alexandros Mavrommatis updated SPARK-36947:
-------------------------------------------
Description:
I have an input dataframe *df* with the following schema:
{code:java}
|-- origin: string (nullable = true)
|-- product: struct (nullable = true)
| |-- id: integer (nullable = true){code}
when I try to select the first 20 rows of the id column I execute:
{code:java}
df.select("product.id").show(20, false)
{code}
and I manage to get the result. But when I execute the following:
{code:java}
df.map(_.getAs[Int]("product.id")).show(20, false){code}
I get the following error:
{code:java}
java.lang.IllegalArgumentException: Field "product.id" does not exist.{code}
was:
I have an input dataframe *df* with the following schema:
{code:java}
|-- origin: string (nullable = true)
|-- product: struct (nullable = true)
| |-- id: integer (nullable = true){code}
when I try to select the first 20 rows of the id column I execute:
{code:java}
df.select("product.id").show(20, false)
{code}
**and I manage to get the result. But when I execute the following:
{code:java}
df.map(_.getAs[Int]("product.id")).show(20, false){code}
I get the following error:
{code:java}
java.lang.IllegalArgumentException: Field "product.id" does not exist.{code}
> Exception when trying to access Row field using getAs method
> ------------------------------------------------------------
>
> Key: SPARK-36947
> URL: https://issues.apache.org/jira/browse/SPARK-36947
> Project: Spark
> Issue Type: Bug
> Components: SQL
> Affects Versions: 3.1.2
> Environment: Spark 3.1.2 (but this also may affect other versions as well)
> Reporter: Alexandros Mavrommatis
> Priority: Blocker
> Labels: catalyst, row, sql
>
> I have an input dataframe *df* with the following schema:
> {code:java}
> |-- origin: string (nullable = true)
> |-- product: struct (nullable = true)
> | |-- id: integer (nullable = true){code}
>
> when I try to select the first 20 rows of the id column I execute:
> {code:java}
> df.select("product.id").show(20, false)
> {code}
>
> and I manage to get the result. But when I execute the following:
> {code:java}
> df.map(_.getAs[Int]("product.id")).show(20, false){code}
>
> I get the following error:
> {code:java}
> java.lang.IllegalArgumentException: Field "product.id" does not exist.{code}
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org