如何通过动态查询流控制Spark Stream?

时间:2020-09-17 13:57:14

标签: apache-spark pyspark apache-spark-sql spark-streaming

我有来自Kafka的数据流,称为SourceStream。

我还有另一个Spark SQL查询流,其单个值为Spark SQL查询以及窗口大小。

我希望将这些查询应用于SourceStream数据,并将查询结果传递到接收器。

例如。 源流

  Id     type    timestamp     user     amount  
 ------- ------  ----------    ---------- -------- 
  uuid1   A      342342        ME           10.0  
  uuid2   B      234231        YOU        120.10  
  uuid3   A      234234        SOMEBODY    23.12  
  uuid4   A      234233        WHO         243.1  
  uuid5   C      124555        IT          35.12  
  ...
  ....

查询流

  Id     window      query   
 -------  ------     ------ 
  uuid13  1 hour     select 'uuid13' as u, max(amount) as output from df where type = 'A' group by ..
  uuid21  5 minute   select 'uuid121' as u, count(1) as output  from df where amount > 100 group by ..
  uuid321 1 day      select 'uuid321' as u, sum(amount) as output from df where amount > 100 group by ..
  ...
  ....

查询流中的每个查询将应用于与查询一起提到的窗口中源流的传入数据,并且输出将发送到接收器。

我可以通过Spark用什么方法实现它?

0 个答案:

没有答案
相关问题