spark sql中的stack() - 运行时异常

时间:2017-07-19 10:48:40

标签: apache-spark apache-spark-sql spark-dataframe

(使用apache spark版本1.6) 我在下面提到链接尝试unpivot功能: unpivot in spark-sql/pyspark

这里的问题我在执行时遇到了一些运行时异常:

df.select($"A", expr("stack(2, 'large', large, 'small', small) as (c, d)")).where("c is not null or b is not null")

例外:

User class threw exception: java.lang.Exception: Application failed with 1 errors: Action UnPivot3: java.lang.RuntimeException: [1.10] failure: identifier expected
stack(2, 'large', large,'small', small) as (c, d)
^
at scala.sys.package$.error(package.scala:27)
at org.apache.spark.sql.catalyst.SqlParser$.parseExpression(SqlParser.scala:49)
at org.apache.spark.sql.functions$.expr(functions.scala:1076)

1)知道如何解决这个问题吗? 2)关于stack()的任何文档帮助都会很棒。

1 个答案:

答案 0 :(得分:1)

在此提交中添加了堆栈:https://github.com/apache/spark/commit/d0d28507cacfca5919dbfb4269892d58b62e8662用于Jira票证:https://issues.apache.org/jira/browse/SPARK-16286

它的修复版本是Spark 2.0,所以你必须将你的Spark版本更新到至少2.0才能使用Stack函数