Query IR#
nlql.ir —— Query IR:规范、可 JSON 序列化的查询 AST(Select / Binding / Expr 家族),三种入口的公共归宿。query_json_schema() 导出 JSON Schema,可直接作为 LLM function-calling 的参数 schema。
ir
#
Query IR: the canonical, JSON-serializable form of every NLQL query.
Expr
module-attribute
#
__all__
module-attribute
#
__all__ = ['Query', 'Select', 'Binding', 'OrderKey', 'Expr', 'Literal', 'Path', 'Ref', 'Call', 'Compare', 'And', 'Or', 'Not', 'expr_from_dict', 'query_json_schema']
Call
dataclass
#
Call(name: str, args: list[Expr] = list())
A function or operator call, resolved against the registry by name.
to_dict
#
Literal
dataclass
#
Path
dataclass
#
Query
dataclass
#
Query(select: Select, let: list[Binding] = list(), where: Expr | None = None, order_by: list[OrderKey] = list(), limit: int | None = None)
The canonical Query IR.
order_by
class-attribute
instance-attribute
#
order_by: list[OrderKey] = field(default_factory=list)
to_dict
#
源代码位于: src/nlql/ir/nodes.py
from_dict
classmethod
#
from_dict(d: dict[str, Any]) -> Query
源代码位于: src/nlql/ir/nodes.py
to_json
#
Select
dataclass
#
expr_from_dict
#
expr_from_dict(d: Any) -> Expr
Rebuild an expression node from its dict form.
源代码位于: src/nlql/ir/nodes.py
query_json_schema
#
Return the JSON Schema (draft 2020-12) describing a Query IR document.
源代码位于: src/nlql/ir/schema.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | |