@malloydata/render 0.0.248-dev250325232143 → 0.0.248-dev250326010711

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.
@@ -116767,7 +116767,12 @@ var qc = {};
116767
116767
  throw new Error(`Sampling is not supported on dialect ${this.name}.`);
116768
116768
  return l;
116769
116769
  }
116770
- sqlOrderBy(l) {
116770
+ /**
116771
+ * MySQL is NULLs first, all other dialects have a way to make NULLs last.
116772
+ * isBaseOrdering is a hack to allow the MySQL dialect to partially implement
116773
+ * NULLs last, but should go away once MySQL fully implements NULLs last.
116774
+ */
116775
+ sqlOrderBy(l, c) {
116771
116776
  return `ORDER BY ${l.join(",")}`;
116772
116777
  }
116773
116778
  sqlTzStr(l) {
@@ -117820,6 +117825,9 @@ class eJe extends VKe.Dialect {
117820
117825
  sqlAnyValue(e, r) {
117821
117826
  return `ANY_VALUE(CASE WHEN group_set=${e} THEN ${r} END)`;
117822
117827
  }
117828
+ sqlOrderBy(e, r) {
117829
+ return r === "analytical" || r === "turtle" ? `ORDER BY ${e.join(",")}` : `ORDER BY ${e.map((i) => `${i} NULLS LAST`).join(",")}`;
117830
+ }
117823
117831
  // can array agg or any_value a struct...
117824
117832
  sqlAggregateTurtle(e, r, i, s) {
117825
117833
  let o = "";
@@ -120330,7 +120338,7 @@ const u0 = Xe, PJe = It, sm = qc, DW = Qc, UJe = lT, jJe = cT, qJe = {
120330
120338
  };
120331
120339
  class HJe extends sm.Dialect {
120332
120340
  constructor() {
120333
- super(...arguments), this.name = "mysql", this.defaultNumberType = "DOUBLE PRECISION", this.defaultDecimalType = "DECIMAL", this.udfPrefix = "ms_temp.__udf", this.hasFinalStage = !1, this.stringTypeName = "VARCHAR(255)", this.divisionIsInteger = !0, this.supportsSumDistinctFunction = !0, this.unnestWithNumbers = !1, this.defaultSampling = { rows: 5e4 }, this.supportUnnestArrayAgg = !0, this.supportsAggDistinct = !0, this.supportsCTEinCoorelatedSubQueries = !0, this.supportsSafeCast = !1, this.dontUnionIndex = !1, this.supportsQualify = !1, this.supportsNesting = !0, this.experimental = !1, this.supportsFullJoin = !1, this.supportsPipelinesInViews = !1, this.readsNestedData = !1, this.supportsComplexFilteredSources = !1, this.supportsArraysInData = !1, this.compoundObjectInSchema = !1, this.booleanAsNumbers = !0;
120341
+ super(...arguments), this.name = "mysql", this.defaultNumberType = "DOUBLE PRECISION", this.defaultDecimalType = "DECIMAL", this.udfPrefix = "ms_temp.__udf", this.hasFinalStage = !1, this.stringTypeName = "VARCHAR(255)", this.divisionIsInteger = !0, this.supportsSumDistinctFunction = !0, this.unnestWithNumbers = !1, this.defaultSampling = { rows: 5e4 }, this.supportUnnestArrayAgg = !0, this.supportsAggDistinct = !0, this.supportsCTEinCoorelatedSubQueries = !0, this.supportsSafeCast = !1, this.dontUnionIndex = !1, this.supportsQualify = !1, this.supportsNesting = !0, this.experimental = !1, this.supportsFullJoin = !1, this.supportsPipelinesInViews = !1, this.readsNestedData = !1, this.supportsComplexFilteredSources = !1, this.supportsArraysInData = !1, this.compoundObjectInSchema = !1, this.booleanAsNumbers = !0, this.orderByClause = "ordinal";
120334
120342
  }
120335
120343
  malloyTypeToSQLType(e) {
120336
120344
  switch (e.type) {
@@ -120563,9 +120571,6 @@ $$ LANGUAGE SQL;
120563
120571
  }
120564
120572
  return e;
120565
120573
  }
120566
- sqlOrderBy(e) {
120567
- return `ORDER BY ${e.map((r) => `${r.trim().slice(0, r.trim().lastIndexOf(" "))} IS NULL DESC, ${r}`).join(",")}`;
120568
- }
120569
120574
  sqlLiteralString(e) {
120570
120575
  return "'" + e.replace(/\\/g, "\\\\").replace(/'/g, "\\'") + "'";
120571
120576
  }
@@ -120880,6 +120885,8 @@ xT.BooleanFilterExpression = void 0;
120880
120885
  xT.BooleanFilterExpression = {
120881
120886
  parse(t) {
120882
120887
  var e;
120888
+ if (t.match(/^\s*$/))
120889
+ return { parsed: null, log: [] };
120883
120890
  const r = { parsed: null, log: [] };
120884
120891
  let i = t.toLowerCase().trim().replace(/\s\s+/, " "), s = !1;
120885
120892
  if (i.startsWith("not ") && (s = !0, i = i.slice(4)), i === "true")
@@ -121840,6 +121847,8 @@ h2.run_parser = OXe;
121840
121847
  const o = bn, u = i(ik), a = s(sk), l = h2;
121841
121848
  t.NumberFilterExpression = {
121842
121849
  parse(c) {
121850
+ if (c.match(/^\s*$/))
121851
+ return { parsed: null, log: [] };
121843
121852
  const f = new u.Parser(u.Grammar.fromCompiled(a.default)), x = (0, l.run_parser)(c, f);
121844
121853
  return x.parsed && (0, o.isNumberFilter)(x.parsed) ? { parsed: x.parsed, log: [] } : { parsed: null, log: x.log };
121845
121854
  },
@@ -121941,6 +121950,8 @@ uk.default = IXe;
121941
121950
  const o = bn, u = i(ik), a = s(uk), l = jt, c = h2;
121942
121951
  t.StringFilterExpression = {
121943
121952
  parse(f) {
121953
+ if (f.match(/^\s*$/))
121954
+ return { parsed: null, log: [] };
121944
121955
  const x = new u.Parser(u.Grammar.fromCompiled(a.default)), h = (0, c.run_parser)(f, x);
121945
121956
  return h.parsed && (0, o.isStringFilter)(h.parsed) ? { parsed: h.parsed, log: [] } : { parsed: null, log: h.log };
121946
121957
  },
@@ -122151,6 +122162,8 @@ ak.default = MXe;
122151
122162
  const o = bn, u = s(ak), a = i(ik), l = h2;
122152
122163
  t.TemporalFilterExpression = {
122153
122164
  parse(h) {
122165
+ if (h.match(/^\s*$/))
122166
+ return { parsed: null, log: [] };
122154
122167
  const p = new a.Parser(a.Grammar.fromCompiled(u.default)), m = (0, l.run_parser)(h, p);
122155
122168
  return m.parsed && (0, o.isTemporalFilter)(m.parsed) ? { parsed: m.parsed, log: [] } : { parsed: null, log: m.log };
122156
122169
  },
@@ -122489,6 +122502,8 @@ dT.TemporalFilterCompiler = PXe;
122489
122502
  }
122490
122503
  t.FilterCompilers = {
122491
122504
  compile(u, a, l, c) {
122505
+ if (a === null)
122506
+ return "true";
122492
122507
  if (u === "string" && (0, e.isStringFilter)(a))
122493
122508
  return t.FilterCompilers.stringCompile(a, l, c);
122494
122509
  if (u === "number" && (0, e.isNumberFilter)(a))
@@ -122979,7 +122994,7 @@ let lk = class extends VXe {
122979
122994
  _.push(` ${R} ${b.dir || "ASC"}`);
122980
122995
  } else r.firstSegment.type === "project" && _.push(` ${v.fif.f.generateExpression(r)} ${b.dir || "ASC"}`);
122981
122996
  }
122982
- _.length > 0 && (m = " " + this.parent.dialect.sqlOrderBy(_));
122997
+ _.length > 0 && (m = " " + this.parent.dialect.sqlOrderBy(_, "analytical"));
122983
122998
  }
122984
122999
  let g = "";
122985
123000
  if (y.between) {
@@ -123122,7 +123137,7 @@ let lk = class extends VXe {
123122
123137
  case "compositeField":
123123
123138
  return "{COMPOSITE_FIELD}";
123124
123139
  case "filterMatch":
123125
- if ((a.dataType === "string" || a.dataType === "number" || a.dataType === "date" || a.dataType === "timestamp" || a.dataType === "boolean") && (0, zXe.isFilterExpression)(a.filter))
123140
+ if ((a.dataType === "string" || a.dataType === "number" || a.dataType === "date" || a.dataType === "timestamp" || a.dataType === "boolean") && (a.filter === null || (0, zXe.isFilterExpression)(a.filter)))
123126
123141
  return HXe.FilterCompilers.compile(a.dataType, a.filter, a.e.sql || "", this.parent.dialect);
123127
123142
  throw new Error(`Internal Error: Filter Compiler Undefined Type '${a.dataType}'`);
123128
123143
  default:
@@ -123943,17 +123958,27 @@ ${(0, Sn.indent)(p)}) AS ${r.alias}
123943
123958
  for (const u of s)
123944
123959
  if (typeof u.field == "string") {
123945
123960
  const a = r.getField(u.field);
123946
- if (a && a.fieldUsage.type === "result")
123947
- this.parent.dialect.orderByClause === "ordinal" ? o.push(`${a.fieldUsage.resultIndex} ${u.dir || "ASC"}`) : this.parent.dialect.orderByClause === "output_name" && o.push(`${this.parent.dialect.sqlMaybeQuoteIdentifier(u.field)} ${u.dir || "ASC"}`);
123948
- else
123961
+ if (a && a.fieldUsage.type === "result") {
123962
+ if (this.parent.dialect.orderByClause === "ordinal")
123963
+ o.push(`${a.fieldUsage.resultIndex} ${u.dir || "ASC"}`);
123964
+ else if (this.parent.dialect.orderByClause === "output_name")
123965
+ o.push(`${this.parent.dialect.sqlMaybeQuoteIdentifier(u.field)} ${u.dir || "ASC"}`);
123966
+ else if (this.parent.dialect.orderByClause === "expression") {
123967
+ const l = a.getSQL();
123968
+ o.push(`${l} ${u.dir || "ASC"}`);
123969
+ }
123970
+ } else
123949
123971
  throw new Error(`Unknown field in ORDER BY ${u.field}`);
123950
123972
  } else if (this.parent.dialect.orderByClause === "ordinal")
123951
123973
  o.push(`${u.field} ${u.dir || "ASC"}`);
123952
123974
  else if (this.parent.dialect.orderByClause === "output_name") {
123953
123975
  const a = r.getFieldByNumber(u.field);
123954
123976
  o.push(`${this.parent.dialect.sqlMaybeQuoteIdentifier(a.name)} ${u.dir || "ASC"}`);
123977
+ } else if (this.parent.dialect.orderByClause === "expression") {
123978
+ const l = r.getFieldByNumber(u.field).fif.getSQL();
123979
+ o.push(`${l} ${u.dir || "ASC"}`);
123955
123980
  }
123956
- return o.length > 0 && (i = this.parent.dialect.sqlOrderBy(o) + `
123981
+ return o.length > 0 && (i = this.parent.dialect.sqlOrderBy(o, "query") + `
123957
123982
  `), i;
123958
123983
  }
123959
123984
  generateSimpleSQL(e) {
@@ -124212,7 +124237,7 @@ FROM ${r}
124212
124237
  name: g.field,
124213
124238
  fif: e.getField(g.field)
124214
124239
  } : l = e.getFieldByNumber(g.field), e.firstSegment.type === "reduce" ? a.push(" " + this.parent.dialect.sqlMaybeQuoteIdentifier(`${l.name}__${e.groupSet}`) + ` ${g.dir || "ASC"}`) : e.firstSegment.type === "project" && a.push(` ${l.fif.f.generateExpression(e)} ${g.dir || "ASC"}`);
124215
- a.length > 0 && (o = " " + this.parent.dialect.sqlOrderBy(a));
124240
+ a.length > 0 && (o = " " + this.parent.dialect.sqlOrderBy(a, "turtle"));
124216
124241
  const f = this.buildDialectFieldList(e);
124217
124242
  let x, h;
124218
124243
  (x = e.getRepeatedResultType()) !== "nested" ? x === "inline_all_numbers" ? h = this.parent.dialect.sqlCoaleseMeasuresInline(e.groupSet, f) : h = this.parent.dialect.sqlAnyValueTurtle(e.groupSet, f) : h = this.parent.dialect.sqlAggregateTurtle(e.groupSet, f, o, u);
@@ -130487,8 +130512,6 @@ class $ut extends Iut.ExpressionDef {
130487
130512
  if (a.log.length > 0)
130488
130513
  for (const c of a.log)
130489
130514
  return this.loggedErrorExpr("filter-expression-error", `Filter parse error: ${c.message}`);
130490
- if (!a.parsed)
130491
- return this.loggedErrorExpr("filter-expression-type", "FJKLD:JDKSL: expression parsed to null");
130492
130515
  const l = {
130493
130516
  node: "filterMatch",
130494
130517
  dataType: u.type,