数据集在 Spark SQL 的 "MapGroupsWithState" 中的使用

Dataset usage in "MapGroupsWithState" of Spark SQL

我有 "id and Map[String, List]" 数据的事件。我按 id 对这些数据进行分组。然后我用 "mapgroupswithstate".

计算一些东西

我可以在mapgroupswithstate中使用from_json()方法吗?那么,我可以在 mapgroupswithstate 中使用 dataset/dataframe 吗?

例如;

df.groupBy().mapgroupswithstate{
   val anotherDF = events.toDF
   ... other operations...
}

我可以在 mapgroupswithstate 中使用 from_json() 方法吗?那么,我可以在 mapgroupswithstate 中使用 dataset/dataframe 吗?

答案 - 两个问题的答案都是否(松散地)。不是以标准的方式。 当您在 mapgroupswithstate 中操作时,您将进入执行程序级别的操作,您可以在其中编写自定义代码而无需数据框抽象。