@rex0220/kintone-sql-tools 3.79.0 → 3.80.0

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.
package/dist-cli/ksql.js CHANGED
@@ -31748,7 +31748,7 @@ function hasAggregateColumns(columns) {
31748
31748
  (c) => c.type === "AGGREGATE" || c.type === "ARITH_AGG_COL" || c.type === "ARITH_COL" && containsAggregate2(c.expr) || c.type === "CASE_COL" && containsAggregate2(c.expr) || c.type === "STRFUNC_COL" && hasAggregateInStringFuncExpr2(c.expr) || c.type === "SCALAR_VALUE_COL" && scalarValueHasAggregate2(c.expr)
31749
31749
  );
31750
31750
  }
31751
- function applyGroupBy(rows, groupByKeys, columns, resolveAggSortKind, resolutionPlan, aliasEvaluationContext = {}) {
31751
+ function applyGroupBy(rows, groupByKeys, columns, resolveAggSortKind, resolutionPlan, aliasEvaluationContext = {}, having = null) {
31752
31752
  if (resolutionPlan && resolutionPlan.items.length !== groupByKeys.length) {
31753
31753
  throw new Error("InternalError: plain GROUP BY resolution plan length does not match group keys.");
31754
31754
  }
@@ -31797,11 +31797,18 @@ function applyGroupBy(rows, groupByKeys, columns, resolveAggSortKind, resolution
31797
31797
  resolveAggSortKind,
31798
31798
  aliasEvaluationContext.evaluationContext
31799
31799
  );
31800
+ materializeAggregateDependencies(
31801
+ outRow,
31802
+ groupRows,
31803
+ having,
31804
+ resolveAggSortKind,
31805
+ aliasEvaluationContext.evaluationContext
31806
+ );
31800
31807
  result.push(outRow);
31801
31808
  }
31802
31809
  return result;
31803
31810
  }
31804
- function applyGroupingSets(rows, spec, columns, resolveAggSortKind, limits = {}) {
31811
+ function applyGroupingSets(rows, spec, columns, resolveAggSortKind, limits = {}, having = null) {
31805
31812
  const result = [];
31806
31813
  let generatedRows = 0;
31807
31814
  const countBucket = () => {
@@ -31861,6 +31868,13 @@ function applyGroupingSets(rows, spec, columns, resolveAggSortKind, limits = {})
31861
31868
  resolveAggSortKind,
31862
31869
  limits.evaluationContext
31863
31870
  );
31871
+ materializeAggregateDependencies(
31872
+ outRow,
31873
+ groupRows,
31874
+ having,
31875
+ resolveAggSortKind,
31876
+ limits.evaluationContext
31877
+ );
31864
31878
  attachGroupingRowMeta(outRow, includedCanonicalIds);
31865
31879
  result.push(outRow);
31866
31880
  }
@@ -33121,7 +33135,8 @@ function runFullScan(input) {
33121
33135
  resolvedGroupingSpec,
33122
33136
  stmt.columns,
33123
33137
  aggregateSortKindResolver,
33124
- { maxGeneratedRows: B65_MAX_GENERATED_ROWS, evaluationContext }
33138
+ { maxGeneratedRows: B65_MAX_GENERATED_ROWS, evaluationContext },
33139
+ stmt.having
33125
33140
  );
33126
33141
  } else if (grouping.type === "PLAIN" || hasAggregateColumns(stmt.columns)) {
33127
33142
  rows = applyGroupBy(
@@ -33135,7 +33150,8 @@ function runFullScan(input) {
33135
33150
  resolveFieldType: fieldTypeResolver,
33136
33151
  resolveFieldSemantics: fieldSemanticsResolver,
33137
33152
  evaluationContext
33138
- }
33153
+ },
33154
+ stmt.having
33139
33155
  );
33140
33156
  }
33141
33157
  warnOnUnresolvedAggregateComparisons(stmt.columns, rows, warnings);