Getting syntax error at spark sql

i m trying to execute below while trying to find maximum / Minimum priced product but getting below error,any help

scala> for i in products.takeOrdered(1, key = lambda rec: -float(rec.split(",")[3])): print(i)
:1: error: ‘(’ expected but identifier found.
for i in products.takeOrdered(1, key = lambda rec: -float(rec.split(",")[3])): print(i)

I think you are executing it in scala. This is python statement. Try to execute it pyspark.

1 Like

that realy helps appreciated