Han
Han

Reputation: 23

Ast module for kdb sql queries

I want to analyze the code structure of a nested kdb+ queries just like what python ast module does to the python codes.

I know that kdb "parse" function already does this in kdb, but how I can implement such functionality in python, so that I can loop through all the syntax tree nodes in the sql query, and make my own custom analysis and change.

For example:

parse "select avg close by date from update close+100 from table"

will get

?
(!;`table;();0b;(,`close)!,(+;`close;100))
()
(,`date)!,`date
(,`close)!,(avg;`close)

I want it to be a tree object in python to be able to modify myself.

Upvotes: 0

Views: 62

Answers (0)

Related Questions