[Python] Ast module for kdb sql queries

Discussão em 'Python' iniciado por Stack, Dezembro 21, 2024.

  1. Stack

    Stack Membro Participativo

    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.

    Continue reading...

Compartilhe esta Página