Hello Clojurians,
I'm a beginner with clojure, but feel I have a situation that macros
might be well-suited.
The problem description is that I have a few sql files with a couple
hundred lines of ANSI SQL. These files contain many SQL statements
like the following:
case when a in ('Q1', 'Q3', 'Q8', 'Q9') then textvar end as qv100,
The task here, is that I need to convert these ANSI SQL files to
something that can be run in Hive SQL. My current belief is that Hive
SQL does not support "in" clauses (http://wiki.apache.org/hadoop/Hive/
LanguageManual/UDF), so I need to convert the above snippet to
explicit assignments like this:
case when a='Q1' then textvar when a='Q3' then textvar when a='Q8'
then textvar when a='Q9' then textvar end as qv100,
Thus, for each value in the "in" clause there will be a "when a=value"
item.
So, I think I need a function or macro to read an sql file, identify
all "case when" statements in the file where there is also an "in"
clause, and translate the "in" clause to the explicit assignments, and
output a corrected Hive-ready sql file. A complicating factor is that
since there are single-quotes embedded in each line of the "in" clause
statements, they likely need to be escaped a priori somehow.
Any thoughts, comments, solutions, or advice on how to tackle this
with clojure much appreciated.
Thanks in advance!
Regards,
~Avram
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en