-
Hi, I have a particular setup where I'm predicting ASTs of SQL queries using a neural network model. I want to be able to convert this predicted AST, that uses the same node types and node properties as sqlglot, into a sqlglot object, so that I can then further run methods such as optimize, etc. Is there any way to do this? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
The You could predict the JSON form of ASTs and use Or you could just predict SQL and |
Beta Was this translation helpful? Give feedback.
-
@barakalon Very nice, thanks! |
Beta Was this translation helpful? Give feedback.
The
Expression.dump
method returns a JSON serializable dict for the AST.The
Expression.load
class method loads these dicts back into an AST.You could predict the JSON form of ASTs and use
Expression.load
.Or you could just predict SQL and
parse
the results into an AST.