Starting with an apology that being a beginner in Scala, I could not find better wordings for the question.
I have a properties file where I need to define a few parameterized commands (or sql queries). Following is an example of this:
[section abc]
stage: StageA
query: Select count(*) FROM tableA WHERE account_id=${account_id} AND dt=$dt AND source=$source
[section def]
stage: StageB
query: Select count(*) FROM tableB WHERE event_date=${event_date} AND template=$template
In my code, I have a config object (consider a Map) which has the values for the variables in my query string (account_id, source, dt, event_date, template, etc.,). After reading the properties file I need to substitute all the macros in my query string. For this I want to write a single function with a signature like:
def resolve_query(query: String, config: Map[String, Any]): String
which should return the query text with the macros substituted with values from the config. I tried writing my own String Interpolator, but it didn't work. Is there anything else that I can try?