@rex0220/kintone-sql-tools 3.82.0 → 3.84.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
@@ -23693,8 +23693,9 @@ function validateGroupingRefMembership(ref, resolve3, canonicalItems) {
23693
23693
  }
23694
23694
  function validateGroupingStatic(stmt) {
23695
23695
  const normalized = normalizeGroupingSpec(stmt);
23696
+ const projectedColumns = [...stmt.columns, ...stmt.hiddenWindows ?? []];
23696
23697
  const groupingRefs = [];
23697
- for (const column of stmt.columns) {
23698
+ for (const column of projectedColumns) {
23698
23699
  collectGroupingRefs(column, groupingRefs);
23699
23700
  }
23700
23701
  collectGroupingRefs(stmt.having, groupingRefs);
@@ -23702,7 +23703,7 @@ function validateGroupingStatic(stmt) {
23702
23703
  const forbiddenGroupingRefs = [];
23703
23704
  collectGroupingRefs(stmt.where, forbiddenGroupingRefs);
23704
23705
  collectGroupingRefs(stmt.joins, forbiddenGroupingRefs);
23705
- collectAggregateArgumentGroupingRefs(stmt.columns, forbiddenGroupingRefs);
23706
+ collectAggregateArgumentGroupingRefs(projectedColumns, forbiddenGroupingRefs);
23706
23707
  collectAggregateArgumentGroupingRefs(stmt.having, forbiddenGroupingRefs);
23707
23708
  if (forbiddenGroupingRefs.length > 0) {
23708
23709
  throw new Error(
@@ -23731,7 +23732,7 @@ function validateGroupingPlanning(stmt, resolve3, planningGuardHook = () => void
23731
23732
  validateGroupingStatic(stmt);
23732
23733
  const normalized = normalizeGroupingSpec(stmt);
23733
23734
  const groupingRefs = [];
23734
- for (const column of stmt.columns) {
23735
+ for (const column of [...stmt.columns, ...stmt.hiddenWindows ?? []]) {
23735
23736
  collectGroupingRefs(column, groupingRefs);
23736
23737
  }
23737
23738
  collectGroupingRefs(stmt.having, groupingRefs);
@@ -24232,6 +24233,7 @@ function collectRequiredFieldsByTable(stmt, plainGroupByPlan, sourceAware) {
24232
24233
  };
24233
24234
  const walkFieldValue = (fv, phase = "select") => {
24234
24235
  if (fv.type === "FIELD") {
24236
+ if (fv.hiddenWindowRef) return;
24235
24237
  if (fv.aggregateRef) {
24236
24238
  walkAgg(fv.aggregateRef, phase);
24237
24239
  return;
@@ -37733,7 +37735,7 @@ async function buildGroupingFieldResolver(stmt, client, cacheContext, materializ
37733
37735
  async function validateSelectGroupingPlanning(stmt, client, cacheContext, materializedTables) {
37734
37736
  resolvedGroupingSpecs.delete(stmt);
37735
37737
  const normalized = normalizeGroupingSpec(stmt);
37736
- const hasGroupingNodes = JSON.stringify(stmt.columns).includes('"GROUPING_') || JSON.stringify(stmt.orderBy).includes('"GROUPING_');
37738
+ const hasGroupingNodes = JSON.stringify(stmt.columns).includes('"GROUPING_') || JSON.stringify(stmt.hiddenWindows ?? []).includes('"GROUPING_') || JSON.stringify(stmt.orderBy).includes('"GROUPING_');
37737
37739
  if (normalized.type === "GROUPING_SETS" || hasGroupingNodes) {
37738
37740
  const resolver = await buildGroupingFieldResolver(stmt, client, cacheContext, materializedTables);
37739
37741
  const resolvedSpec = validateGroupingPlanning(