https://kedro.org/ logo
#questions
Title
# questions
d

Debanjan Banerjee

11/14/2023, 3:20 PM
can we use parameters from parameters.yml into spark sql ? Something like params.yml
x = 123
node.py
df = spark.sql(''''select * from table where x = '{x}' ''')
d

datajoely

11/14/2023, 3:21 PM
it would have to be via a node
but there is no reason why you can’t do that
aside from managing SQL injection risk
d

Debanjan Banerjee

11/14/2023, 3:23 PM
the thing is when i try the above , its passing the variable directly as a string generated sql : `select * from table where x = `{x}``
d

datajoely

11/14/2023, 3:23 PM
in a node or catalog entry?
d

Debanjan Banerjee

11/14/2023, 3:23 PM
node
d

datajoely

11/14/2023, 3:24 PM
then you need to do python string interpolation with
.format
or
f
strings
it’s just a python string
d

Debanjan Banerjee

11/14/2023, 3:26 PM
so
spark.sql('''f"my query"''')
?
oh no i got it
d

datajoely

11/14/2023, 3:26 PM
cool
d

Debanjan Banerjee

11/14/2023, 3:26 PM
spark.sql(f"my query")
worked
d

datajoely

11/14/2023, 3:28 PM
🚀