Parser¶
The Parser converts tokens into an Abstract Syntax Tree (AST). It supports three statement types:
TRAIN WITH: Training data selection.
PREDICT VALUE: Prediction targets and task types.
VALIDATE WITH: Validation data selection.
Example¶
from tlsql.tlsql.parser import Parser
parser = Parser("PREDICT VALUE(users.Age, CLF) FROM users WHERE users.Gender = 'F'")
ast = parser.parse()
if ast.predict:
print(f"Target Column: {ast.predict.value.target.column}")
print(f"Target Table: {ast.predict.value.target.table}")
print(f"Task Type: {ast.predict.value.predict_type.type_name}")