* Detects whether a SELECT projection contains any aggregate expressions. * Recursively traverses nested select objects. * * @param select - The SELECT object from the IR * @returns True if any field is an aggregate, false otherwise
(select: Select)
| 1064 | * @returns True if any field is an aggregate, false otherwise |
| 1065 | */ |
| 1066 | function selectHasAggregates(select: Select): boolean { |
| 1067 | for (const value of Object.values(select)) { |
| 1068 | if (typeof value === `object`) { |
| 1069 | const v: any = value |
| 1070 | if (v.type === `agg`) return true |
| 1071 | if (!(`type` in v)) { |
| 1072 | if (selectHasAggregates(v as unknown as Select)) return true |
| 1073 | } |
| 1074 | } |
| 1075 | } |
| 1076 | return false |
| 1077 | } |
| 1078 | |
| 1079 | /** |
| 1080 | * Recursively collects all PropRef references from an expression. |