You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Frank Oosterhuis (Jira)" <ji...@apache.org> on 2020/06/24 14:38:00 UTC
[jira] [Comment Edited] (SPARK-32051) Dataset.foreachPartition
returns object
[ https://issues.apache.org/jira/browse/SPARK-32051?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17143875#comment-17143875 ]
Frank Oosterhuis edited comment on SPARK-32051 at 6/24/20, 2:37 PM:
--------------------------------------------------------------------
This is fine:
{code:java}
spark.range(100)
.select(
concat(lit("d"), col("id")).as("db"),
concat(lit("t"), col("id")).as("table")
)
.foreach((r : Row) => {
val sql = "drop table %s.%s".format(r.getAs("db"), r.getAs("table"))
println(sql)
})
{code}
This breaks:
{code:java}
spark.range(100)
.select(
concat(lit("d"), col("id")).as("db"),
concat(lit("t"), col("id")).as("table")
)
.foreach((r : Row) => {
val sql = "drop table %s.%s".format(r.getAs("db"), r.getAs("table"))
spark.sql(sql)
})
{code}
My work around for now: map the strings and collect, then run the foreach on the resulting array.
was (Author: frankivo):
This is fine:
{code:java}
spark.range(100)
.select(
concat(lit("d"), col("id")).as("db"),
concat(lit("t"), col("id")).as("table")
)
.foreach((r : Row) => {
val sql = "drop table %s.%s".format(r.getAs("db"), r.getAs("table"))
println(sql)
})
{code}
This breaks:
{code:java}
spark.range(100)
.select(
concat(lit("d"), col("id")).as("db"),
concat(lit("t"), col("id")).as("table")
)
.foreach((r : Row) => {
val sql = "drop table %s.%s".format(r.getAs("db"), r.getAs("table"))
spark.sql(sql)
})
{code}
> Dataset.foreachPartition returns object
> ---------------------------------------
>
> Key: SPARK-32051
> URL: https://issues.apache.org/jira/browse/SPARK-32051
> Project: Spark
> Issue Type: Bug
> Components: SQL
> Affects Versions: 3.0.0
> Reporter: Frank Oosterhuis
> Priority: Major
>
> I'm trying to map values from the Dataset[Row], but since 3.0.0 this fails.
> In 3.0.0 I'm dealing with an error: "Error:(28, 38) value map is not a member of Object"
>
> This is the simplest code that works in 2.4.x, but fails in 3.0.0:
> {code:scala}
> spark.range(100)
> .repartition(10)
> .foreachPartition(part => println(part.toList))
> {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