I am trying to run substring function on a column(CompleteLine) using a variable(StringStartPoint) for the start position.
I tried few option as given below , but both are failing with different reason. How could I use variable inside select function easily.
StringStartPoint=10
df2 = df1.select(f.substring(f.col("CompleteLine"),StringStartPoint,f.col("StringLength"))).alias('MySubString')
TypeError: Column is not iterable . This is not recognizing the 3rd parameter as a value.
df2 = df1.select(f.expr("substring(col(CompleteLine),StringStartPoint,col(StringLength))").alias('MySubString')
AnalysisException: Cannot resolve StringStartPoint given input column . This is recognizing the 2nd parameter as a dataframe field.