yobx.sql — convert module#
SQL to ONNX converter.
sql_to_onnx() converts a SQL query string into a self-contained
onnx.ModelProto.
Design#
Every referenced column becomes a separate 1-D ONNX input so that the
caller can supply column vectors independently (matching the convention used
for tabular data). The converter processes the ParsedQuery
operation list in execution order:
JoinOp— equi-join on a key column.FilterOp— boolean mask applied to all columns.GroupByOp— group key used for aggregations.SelectOp— column expressions emitted as outputs.
ONNX operations used#
Compress— row-wise filtering (WHERE clause).Gather— index-based row selection (JOIN / GROUP BY key alignment).Add,Sub,Mul,Div— arithmetic expressions.Equal,Less,Greater,LessOrEqual,GreaterOrEqual— comparison predicates.And,Or— compound predicates.ReduceSum,ReduceMean,ReduceMin,ReduceMax—SUM / AVG / MIN / MAXaggregations.
Limitations#
Only equi-joins on a single key column are supported.
GROUP BYaggregation is limited to the row-wise functions listed above; true SQL group-by semantics (unique key extraction) are not yet implemented as ONNX lacks a native GroupBy node.COUNT(*)emits the total row count as a scalarint64tensor.SELECT DISTINCTis not yet supported and raisesNotImplementedError.