代码之家  ›  专栏  ›  技术社区  ›  Shankar

pyspark中的窗口函数-奇怪行为

  •  0
  • Shankar  · 技术社区  · 7 年前

    我在代码中大量使用Pyspark窗口函数。但它似乎不能正常工作。

    i'm getting the correct results only for the last record by order by column

    文件上说,这是实验性的,我们可以在生产系统中使用它吗 http://spark.apache.org/docs/2.3.0/api/python/pyspark.sql.html#pyspark.sql.Window

    样本代码:

    invWindow = Window.partitionBy(masterDrDF["ResId"], masterDrDF["vrsn_strt_dts"]).orderBy(masterDrDF["vrsn_strt_dts"]).rowsBetween(Window.unboundedPreceding, Window.unboundedFollowing)
    
    max(when(invDetDF["InvoiceItemType"].like('ABD%'), 1).otherwise(0)).over(invWindow).alias("ABD_PKG_IN")
    
    0 回复  |  直到 7 年前