Ok, so I am trying to run this piece of code:
%%spark
spark.sql(f'''select t2.ANOT_PDA_PRD
,t2.VLR_PDA_PRD AS MAX_VLR_PDA
,(CASE t1.cd_gr_mdld_prd_pd
WHEN 7 THEN t3.DEF_B4
WHEN 8 THEN t3.DEF_B4
WHEN 9 THEN t3.DEF_B4
WHEN 10 THEN t3.DEF_B5
WHEN 11 THEN t3.DEF_B4
WHEN 12 THEN t3.DEF_B5
WHEN 13 THEN t3.DEF_B4
WHEN 14 THEN t3.DEF_B4
WHEN 15 THEN t3.DEF_B5
WHEN 16 THEN t3.DEF_B4
WHEN 17 THEN t3.DEF_B4
WHEN 18 THEN t3.DEF_B4
WHEN 22 THEN t3.DEF_B5
ELSE 0 END) AS TMP_QUALI
,T3.ANOT_PDA_CLI
from temp_vars_qlt as t1
left join temp_vars_qlt as t2
on t1.dt_mvtc = t2.dt_mvtc and t1.cd_cli = t2.cd_cli and T1.cd_gr_mdld_prd_pd=t2.cd_gr_mdld_prd_pd
left join temp_vars_qlt as t3
on t1.dt_mvtc = t3.dt_mvtc and t1.cd_cli = t3.cd_cli
where t1.dt_mvtc between({data_inicial} , {data_final})
''').createOrReplaceTempView("temp_safras_qlt_aux")
But I got the following error:
SparkStatementException: "\nmismatched input 'from' expecting <EOF>(line 19, pos 14)\n\n== SQL
==\nselect t2.ANOT_PDA_PRD\n ,t2.VLR_PDA_PRD AS MAX_VLR_PDA\n ,(CASE
t1.cd_gr_mdld_prd_pd\n WHEN 7 THEN t3.DEF_B4\n WHEN 8
THEN t3.DEF_B4\n .................
whi A LOT of other lines, but altough is not readable entirely, I believe the important part is in the first line.
But I do not know what "\nmismatched input 'from' expecting <EOF> was supposed to mean anyway.
So, the question is simple: what is wrong?