@malloydata/render 0.0.248-dev250325232143 → 0.0.248-dev250325235002

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
  }
@@ -122979,7 +122984,7 @@ let lk = class extends VXe {
122979
122984
  _.push(` ${R} ${b.dir || "ASC"}`);
122980
122985
  } else r.firstSegment.type === "project" && _.push(` ${v.fif.f.generateExpression(r)} ${b.dir || "ASC"}`);
122981
122986
  }
122982
- _.length > 0 && (m = " " + this.parent.dialect.sqlOrderBy(_));
122987
+ _.length > 0 && (m = " " + this.parent.dialect.sqlOrderBy(_, "analytical"));
122983
122988
  }
122984
122989
  let g = "";
122985
122990
  if (y.between) {
@@ -123943,17 +123948,27 @@ ${(0, Sn.indent)(p)}) AS ${r.alias}
123943
123948
  for (const u of s)
123944
123949
  if (typeof u.field == "string") {
123945
123950
  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
123951
+ if (a && a.fieldUsage.type === "result") {
123952
+ if (this.parent.dialect.orderByClause === "ordinal")
123953
+ o.push(`${a.fieldUsage.resultIndex} ${u.dir || "ASC"}`);
123954
+ else if (this.parent.dialect.orderByClause === "output_name")
123955
+ o.push(`${this.parent.dialect.sqlMaybeQuoteIdentifier(u.field)} ${u.dir || "ASC"}`);
123956
+ else if (this.parent.dialect.orderByClause === "expression") {
123957
+ const l = a.getSQL();
123958
+ o.push(`${l} ${u.dir || "ASC"}`);
123959
+ }
123960
+ } else
123949
123961
  throw new Error(`Unknown field in ORDER BY ${u.field}`);
123950
123962
  } else if (this.parent.dialect.orderByClause === "ordinal")
123951
123963
  o.push(`${u.field} ${u.dir || "ASC"}`);
123952
123964
  else if (this.parent.dialect.orderByClause === "output_name") {
123953
123965
  const a = r.getFieldByNumber(u.field);
123954
123966
  o.push(`${this.parent.dialect.sqlMaybeQuoteIdentifier(a.name)} ${u.dir || "ASC"}`);
123967
+ } else if (this.parent.dialect.orderByClause === "expression") {
123968
+ const l = r.getFieldByNumber(u.field).fif.getSQL();
123969
+ o.push(`${l} ${u.dir || "ASC"}`);
123955
123970
  }
123956
- return o.length > 0 && (i = this.parent.dialect.sqlOrderBy(o) + `
123971
+ return o.length > 0 && (i = this.parent.dialect.sqlOrderBy(o, "query") + `
123957
123972
  `), i;
123958
123973
  }
123959
123974
  generateSimpleSQL(e) {
@@ -124212,7 +124227,7 @@ FROM ${r}
124212
124227
  name: g.field,
124213
124228
  fif: e.getField(g.field)
124214
124229
  } : 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));
124230
+ a.length > 0 && (o = " " + this.parent.dialect.sqlOrderBy(a, "turtle"));
124216
124231
  const f = this.buildDialectFieldList(e);
124217
124232
  let x, h;
124218
124233
  (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);