Skip to content

Commit f245f20

Browse files
Merge pull request #77 from abhishekpnt/cbrelease-4.8.28
code fix for exhaust
2 parents 9b7dd42 + 9e2b75e commit f245f20

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

jobs/stage-0/dataExhaust.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,21 @@
2323
from util import schemas
2424

2525
class DataExhaustModel:
26+
27+
@staticmethod
28+
def duration_format(df, in_col, out_col=None):
29+
out_col_name = out_col if out_col is not None else in_col
30+
31+
return df.withColumn(out_col_name,
32+
when(col(in_col).isNull(), lit(""))
33+
.otherwise(
34+
format_string("%02d:%02d:%02d",
35+
expr(f"{in_col} / 3600").cast("int"),
36+
expr(f"{in_col} % 3600 / 60").cast("int"),
37+
expr(f"{in_col} % 60").cast("int")
38+
)
39+
)
40+
)
2641

2742
def __init__(self, spark: SparkSession, config: dict):
2843
self.spark = spark

0 commit comments

Comments
 (0)