我正在使用 SparkSQL
spark.sql("""
SELECT artist, count(distinct(song))
FROM user_log_table WHERE artist =
(SELECT artist
FROM user_log_table
GROUP BY artist
ORDER BY count(artist) DESC
LIMIT 1 )
""").show()
这是我的查询,我只运行了子查询,它给了我一个我正在寻找的值,然后我想在 where 子句中使用该值,但我得到了错误
调用 o22.sql 时出错。:org.apache.spark.sql.AnalysisException:分组表达式序列为空,并且'user_log_table.`artist`'不是聚合函数。在窗口函数中包装 '(count(DISTINCT user_log_table.`song`) AS `count(DISTINCT song)`)' 或在 first() (或 first_value)中包装 'user_log_table.`artist`' 如果你不这样做关心你得到的价值。;;