You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[FEATURE] Add option to call parent of expression #1966
I'm using JsqlParser to parse SQL script, which is always select statement and is written in Spark SQL syntax.
My goal is to travel through all functions and replace them with correct analog to target database (for example postgres).
Using visitor is great feature. but I can only change existing Function object, change function name, change parameters and so on.
But in some cases I need to replace this Function with other Expression, for example with Subtraction.
Look at this example:
SELECT to_unix_timestamp("col1") from mytable; -> this is valid spark sql
SELECT ("col1" - to_date('1970-01-01', 'yyyy-mm-dd')) * 86400 -> this is valid oracle sql
Here i need to change to_unix_timestamp function with Multiplication.
I wish there was an option to get parentExpression on my Function in a visitor and call something like replaceWith(multiplication)
Activity
manticore-projects commentedon Feb 16, 2024
Greetings.
All of that is very possible. What challenges exactly are you facing please?
Maybe this explanations will help: https://manticore-projects.com/JSQLParser/usage.html#build-a-sql-statement