You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Loic Descotte (JIRA)" <ji...@apache.org> on 2017/02/07 12:57:41 UTC
[jira] [Updated] (SPARK-19492) Dataset, map, filter and pattern
matching on elements
[ https://issues.apache.org/jira/browse/SPARK-19492?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Loic Descotte updated SPARK-19492:
----------------------------------
Description:
It seems it is impossible to use pattern matching to define input parameters for functions like filter, map, etc. on datasets.
Example :
This one is working :
{code}
val departments = Seq(
Department(1, "hr"),
Department(2, "it")
).toDS
departments.filter{ d=>
d.name == "hr"
}
{code}
but not this one :
{code}
departments.filter{ case Department(_, name)=>
name == "hr"
}
{code}
Error :
{code}
error: missing parameter type for expanded function
The argument types of an anonymous function must be fully known. (SLS 8.5)
Expected type was: ?
departments.filter{ case Department(_, name)=>
{code}
This kind of pattern matching should work as departements dataset type is known, like on Scala collections filter function for example.
was:
It seems it is impossible to use pattern matching to define input parameters for functions like filter, map, etc. on datasets.
Example :
This one is working :
{code}
val departments = Seq(
Department(1, "hr"),
Department(2, "it")
).toDS
departments.filter{ d=>
d.name == "hr"
}
{code}
but not this one :
{code}
departments.filter{ case Department(_, name)=>
name == "hr"
}
{code}
Error :
{code}
error: missing parameter type for expanded function
The argument types of an anonymous function must be fully known. (SLS 8.5)
Expected type was: ?
departments.filter{ case Department(_, name)=>
{code}
I don't know why it's not working, unlike Scala collections filter function for example.
> Dataset, map, filter and pattern matching on elements
> -----------------------------------------------------
>
> Key: SPARK-19492
> URL: https://issues.apache.org/jira/browse/SPARK-19492
> Project: Spark
> Issue Type: Bug
> Components: SQL
> Affects Versions: 2.0.2, 2.1.0
> Reporter: Loic Descotte
>
> It seems it is impossible to use pattern matching to define input parameters for functions like filter, map, etc. on datasets.
> Example :
> This one is working :
> {code}
> val departments = Seq(
> Department(1, "hr"),
> Department(2, "it")
> ).toDS
> departments.filter{ d=>
> d.name == "hr"
> }
> {code}
> but not this one :
> {code}
> departments.filter{ case Department(_, name)=>
> name == "hr"
> }
> {code}
> Error :
> {code}
> error: missing parameter type for expanded function
> The argument types of an anonymous function must be fully known. (SLS 8.5)
> Expected type was: ?
> departments.filter{ case Department(_, name)=>
> {code}
> This kind of pattern matching should work as departements dataset type is known, like on Scala collections filter function for example.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org