【发布时间】:2021-06-05 16:44:24
【问题描述】:
我有如下数据,并在 claim_start_date 上排序。
arrayData = [
('abc','PN1','SN1','2021-02-03 10:20:11','','Fail'),
('abc','PN1','SN1','2021-02-03 10:20:15','','Fail'),
('abc','PN1','SN1','2021-02-03 10:20:19','','Fail'),
('abc','PN1','SN1','2021-02-03 10:21:11','2021-02-03 10:21:19','Success'),
('abc','PN1','SN1','2021-02-03 10:22:19','','Fail'),
('abc','PN1','SN1','2021-02-03 10:22:29','','Fail'),
('abc','PN1','SN1','2021-02-03 10:22:39','','Fail'),
('abc','PN1','SN1','2021-02-03 10:22:49','','Fail'),
('abc','PN1','SN1','2021-02-03 10:22:59','','Fail'),
('abc','PN1','SN1','2021-02-03 10:31:11','2021-02-03 10:31:19','Success'),
('abc','PN1','SN1','2021-02-03 10:31:21','2021-02-03 10:32:19','Success'),
('abc','PN1','SN1','2021-02-03 11:32:49','','Fail'),
('abc','PN1','SN1','2021-02-03 11:34:59','','Fail'),
('abc','PN1','SN2','2021-02-03 10:22:49','','Fail'),
('abc','PN1','SN2','2021-02-03 10:22:59','','Fail')
]
root
|-- event: string (nullable = true)
|-- PN: string (nullable = true)
|-- SN: string (nullable = true)
|-- Claim_Start: string (nullable = true)
|-- Claim_End: string (nullable = true)
|-- Status: string (nullable = true)
+-----+---+---+-------------------+-------------------+-------+
|event| PN| SN| Claim_Start| Claim_End| Status|
+-----+---+---+-------------------+-------------------+-------+
| abc|PN1|SN1|2021-02-03 10:20:11| | Fail|
| abc|PN1|SN1|2021-02-03 10:20:15| | Fail|
| abc|PN1|SN1|2021-02-03 10:20:19| | Fail|
| abc|PN1|SN1|2021-02-03 10:21:11|2021-02-03 10:21:19|Success|
| abc|PN1|SN1|2021-02-03 10:22:19| | Fail|
| abc|PN1|SN1|2021-02-03 10:22:29| | Fail|
| abc|PN1|SN1|2021-02-03 10:22:39| | Fail|
| abc|PN1|SN1|2021-02-03 10:22:49| | Fail|
| abc|PN1|SN1|2021-02-03 10:22:59| | Fail|
| abc|PN1|SN1|2021-02-03 10:31:11|2021-02-03 10:31:19|Success|
| abc|PN1|SN1|2021-02-03 10:31:21|2021-02-03 10:32:19|Success|
| abc|PN1|SN1|2021-02-03 11:32:49| | Fail|
| abc|PN1|SN1|2021-02-03 11:34:59| | Fail|
| abc|PN1|SN2|2021-02-03 10:22:49| | Fail|
| abc|PN1|SN2|2021-02-03 10:22:59| | Fail|
+-----+---+---+-------------------+-------------------+-------+
我只想从当前行遍历到上一个成功的行,即状态为成功的地方,以便我可以计算重试次数以使其成功。
有什么办法可以吗。
【问题讨论】:
-
这是this的重复吗?
标签: apache-spark pyspark apache-spark-sql