hogql-parser 1.2.10__tar.gz → 1.2.11__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of hogql-parser might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hogql_parser
3
- Version: 1.2.10
3
+ Version: 1.2.11
4
4
  Summary: HogQL parser for internal PostHog use
5
5
  Home-page: https://github.com/PostHog/posthog/tree/master/common/hogql_parser
6
6
  Author: PostHog Inc.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hogql_parser
3
- Version: 1.2.10
3
+ Version: 1.2.11
4
4
  Summary: HogQL parser for internal PostHog use
5
5
  Home-page: https://github.com/PostHog/posthog/tree/master/common/hogql_parser
6
6
  Author: PostHog Inc.
@@ -1152,7 +1152,7 @@ class HogQLParseTreeConverter : public HogQLParserBaseVisitor {
1152
1152
  if (!limit_expr_result) {
1153
1153
  throw ParsingError("Failed to parse limitExpr");
1154
1154
  }
1155
-
1155
+
1156
1156
  PyObject* exprs = visitAsPyObject(ctx->columnExprList());
1157
1157
  if (!exprs) {
1158
1158
  Py_DECREF(limit_expr_result);
@@ -1161,7 +1161,7 @@ class HogQLParseTreeConverter : public HogQLParserBaseVisitor {
1161
1161
 
1162
1162
  PyObject* n = NULL;
1163
1163
  PyObject* offset_value = NULL;
1164
-
1164
+
1165
1165
  // Check if it's a tuple
1166
1166
  if (PyTuple_Check(limit_expr_result)) {
1167
1167
  if (PyTuple_Size(limit_expr_result) >= 2) {
@@ -1180,7 +1180,7 @@ class HogQLParseTreeConverter : public HogQLParserBaseVisitor {
1180
1180
  n = limit_expr_result;
1181
1181
  offset_value = Py_NewRef(Py_None);
1182
1182
  }
1183
-
1183
+
1184
1184
  // Create the LimitByExpr node (transfers ownership of n, offset_value, and exprs)
1185
1185
  RETURN_NEW_AST_NODE("LimitByExpr", "{s:N,s:N,s:N}",
1186
1186
  "n", n,
@@ -1212,7 +1212,7 @@ class HogQLParseTreeConverter : public HogQLParserBaseVisitor {
1212
1212
  Py_DECREF(second);
1213
1213
  throw PyInternalError();
1214
1214
  }
1215
-
1215
+
1216
1216
  if (ctx->COMMA()) {
1217
1217
  // For "LIMIT a, b" syntax: a is offset, b is limit
1218
1218
  // PyTuple_SET_ITEM steals references, so we don't need to DECREF after
@@ -2014,7 +2014,7 @@ class HogQLParseTreeConverter : public HogQLParserBaseVisitor {
2014
2014
  }
2015
2015
 
2016
2016
  PyObject* ret = build_ast_node(
2017
- "Call",
2017
+ "Call",
2018
2018
  "{s:s,s:[O]}", // s:[O] means "args" => [the single PyObject]
2019
2019
  "name", name.c_str(),
2020
2020
  "args", constant_count
@@ -2125,13 +2125,12 @@ class HogQLParseTreeConverter : public HogQLParserBaseVisitor {
2125
2125
  }
2126
2126
 
2127
2127
  VISIT(ColumnExprBetween) {
2128
- // x [NOT] BETWEEN y AND z -> inclusive ends: (x >= y AND x <= z) or NOT: (x < y OR x > z)
2129
- PyObject* x = visitAsPyObject(ctx->columnExpr(0));
2128
+ PyObject* expr = visitAsPyObject(ctx->columnExpr(0));
2130
2129
  PyObject* low;
2131
2130
  try {
2132
2131
  low = visitAsPyObject(ctx->columnExpr(1));
2133
2132
  } catch (...) {
2134
- Py_DECREF(x);
2133
+ Py_DECREF(expr);
2135
2134
  throw;
2136
2135
  }
2137
2136
  PyObject* high;
@@ -2139,112 +2138,17 @@ class HogQLParseTreeConverter : public HogQLParserBaseVisitor {
2139
2138
  high = visitAsPyObject(ctx->columnExpr(2));
2140
2139
  } catch (...) {
2141
2140
  Py_DECREF(low);
2142
- Py_DECREF(x);
2141
+ Py_DECREF(expr);
2143
2142
  throw;
2144
2143
  }
2145
-
2146
- if (ctx->NOT()) {
2147
- // (x < low) OR (x > high)
2148
- PyObject* lt_op = get_ast_enum_member("CompareOperationOp", "Lt");
2149
- PyObject* gt_op = get_ast_enum_member("CompareOperationOp", "Gt");
2150
- if (!lt_op || !gt_op) {
2151
- Py_XDECREF(lt_op);
2152
- Py_XDECREF(gt_op);
2153
- Py_DECREF(high);
2154
- Py_DECREF(low);
2155
- Py_DECREF(x);
2156
- throw PyInternalError();
2157
- }
2158
- Py_INCREF(x);
2159
- PyObject* lt = build_ast_node("CompareOperation", "{s:N,s:N,s:N}", "left", x, "right", low, "op", lt_op);
2160
- if (!lt) {
2161
- Py_DECREF(gt_op);
2162
- Py_DECREF(high);
2163
- Py_DECREF(low);
2164
- Py_DECREF(x);
2165
- throw PyInternalError();
2166
- }
2167
- Py_INCREF(x);
2168
- PyObject* gt = build_ast_node("CompareOperation", "{s:N,s:N,s:N}", "left", x, "right", high, "op", gt_op);
2169
- if (!gt) {
2170
- Py_DECREF(lt);
2171
- Py_DECREF(high);
2172
- Py_DECREF(low);
2173
- Py_DECREF(x);
2174
- throw PyInternalError();
2175
- }
2176
- PyObject* or_list = Py_BuildValue("[NN]", lt, gt);
2177
- if (!or_list) {
2178
- Py_DECREF(gt);
2179
- Py_DECREF(lt);
2180
- Py_DECREF(high);
2181
- Py_DECREF(low);
2182
- Py_DECREF(x);
2183
- throw PyInternalError();
2184
- }
2185
- PyObject* result = build_ast_node("Or", "{s:N}", "exprs", or_list);
2186
- if (!result) {
2187
- Py_DECREF(or_list);
2188
- Py_DECREF(high);
2189
- Py_DECREF(low);
2190
- Py_DECREF(x);
2191
- throw PyInternalError();
2192
- }
2193
- Py_DECREF(x);
2194
- return result;
2195
- }
2196
-
2197
- // (x >= low) AND (x <= high)
2198
- PyObject* gte_op = get_ast_enum_member("CompareOperationOp", "GtEq");
2199
- PyObject* lte_op = get_ast_enum_member("CompareOperationOp", "LtEq");
2200
- if (!gte_op || !lte_op) {
2201
- Py_XDECREF(gte_op);
2202
- Py_XDECREF(lte_op);
2203
- Py_DECREF(high);
2204
- Py_DECREF(low);
2205
- Py_DECREF(x);
2206
- throw PyInternalError();
2207
- }
2208
-
2209
- Py_INCREF(x);
2210
- PyObject* gte = build_ast_node("CompareOperation", "{s:N,s:N,s:N}", "left", x, "right", low, "op", gte_op);
2211
- if (!gte) {
2212
- Py_DECREF(lte_op);
2213
- Py_DECREF(high);
2214
- Py_DECREF(low);
2215
- Py_DECREF(x);
2216
- throw PyInternalError();
2217
- }
2218
-
2219
- Py_INCREF(x);
2220
- PyObject* lte = build_ast_node("CompareOperation", "{s:N,s:N,s:N}", "left", x, "right", high, "op", lte_op);
2221
- if (!lte) {
2222
- Py_DECREF(gte);
2223
- Py_DECREF(high);
2224
- Py_DECREF(low);
2225
- Py_DECREF(x);
2226
- throw PyInternalError();
2227
- }
2228
- PyObject* and_list = Py_BuildValue("[NN]", gte, lte);
2229
- if (!and_list) {
2230
- Py_DECREF(lte);
2231
- Py_DECREF(gte);
2232
- Py_DECREF(high);
2233
- Py_DECREF(low);
2234
- Py_DECREF(x);
2235
- throw PyInternalError();
2236
- }
2237
- PyObject* result = build_ast_node("And", "{s:N}", "exprs", and_list);
2238
- if (!result) {
2239
- Py_DECREF(and_list);
2240
- Py_DECREF(high);
2241
- Py_DECREF(low);
2242
- Py_DECREF(x);
2243
- throw PyInternalError();
2244
- }
2245
-
2246
- Py_DECREF(x);
2247
- return result;
2144
+ RETURN_NEW_AST_NODE(
2145
+ "BetweenExpr",
2146
+ "{s:N,s:N,s:N,s:O}",
2147
+ "expr", expr,
2148
+ "low", low,
2149
+ "high", high,
2150
+ "negated", ctx->NOT() ? Py_True : Py_False
2151
+ );
2248
2152
  }
2249
2153
 
2250
2154
  VISIT(ColumnExprParens) { return visit(ctx->columnExpr()); }
@@ -33,7 +33,7 @@ module = Extension(
33
33
 
34
34
  setup(
35
35
  name="hogql_parser",
36
- version="1.2.10",
36
+ version="1.2.11",
37
37
  url="https://github.com/PostHog/posthog/tree/master/common/hogql_parser",
38
38
  description="HogQL parser for internal PostHog use",
39
39
  author="PostHog Inc.",
File without changes
File without changes
File without changes
File without changes