That's string interpolation. You could create your own for example :bind and then do replaceall, to replace named parameter.
On Wed, Nov 28, 2018, 18:55 Mann Du <manndu2...@gmail.com wrote: > Hello there, > > I am trying to pass parameters in spark.sql query in Java code, the same > as in this link > > https://forums.databricks.com/questions/115/how-do-i-pass-parameters-to-my-sql-statements.html > <https://urldefense.proofpoint.com/v2/url?u=https-3A__forums.databricks.com_questions_115_how-2Ddo-2Di-2Dpass-2Dparameters-2Dto-2Dmy-2Dsql-2Dstatements.html&d=DwMFaQ&c=slrrB7dE8n7gBJbeO0g-IQ&r=MXyWMjAKhWxt951g8qOF6A&m=os5wb5igP2ywNRr3jO9JagocXdj1XNYZXmlvbXUJWSA&s=NiYxoZK3cKJuI6-ND0ToXbAk4tqL_YpMYO_8LhZFHiE&e=> > > The link suggested to use 's' before 'select' as - > val param = 100 > spark.sql(s""" select * from table where parameter = $param """) > > it works for scala and python, but it doesn't work for Java. I also tried > .format() but failed as well. > > Does anyone know how to dynamically pass parameters in sql using Java? > Greatly appreciate your help. > > Best, > > Mann > >