I want to achieve the following sql query conversion using sqlglot
select * from table where date > abc.def(2 * days)
to
select * from table where date > {@abc.def(2 * days).xyz(yyyy)}
For the first conversion i.e abc
to {@abc}
, I used the following replacement and it worked:
tree = sqlglot.parse_one(query)
tree.find(sqlglot.exp.Var).replace(sqlglot.exp.Var(this="{@abc"))
Can somebody help with the next conversion i.e def(2 * days)
to def(2 * days).xyz(yyy)}
Results in: