Your code contains many errors and I'm not sure I quite understand what you want to do.
expr
takes a string expression but you're passing a "column". It should be like this:
df123 = F.expr(f"date_sub({get_dateid_1(datetime.now())}, 1)")
print(df123)
# Column<b'date_sub(((2021 - 1) - 27), 1)'>
Or if you want to use Pyspark functions (lit
to pass the date returned by the function) :
df123 = F.date_sub(F.lit(get_dateid_1(datetime.now())), 1)
print(df123)
# Column<b'date_sub(2021-01-27, 1)'>
However, if your intent is to substract one day to the current date, you should be using the Spark builtin function current_date
:
df123 = F.date_sub(F.current_date(), 1)
print(df123)
# Column<b'date_sub(current_date(), 1)'>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…