( from: UnionAll, allInputs: Record<string, KeyedStream>, collections: Record<string, Collection>, subscriptions: Record<string, CollectionSubscription>, callbacks: Record<string, LazyCollectionCallbacks>, lazySources: Set<string>, optimizableOrderByCollections: Record<string, OrderByOptimizationInfo>, setWindowFn: (windowFn: (options: WindowOptions) => void) => void, cache: QueryCache, queryMapping: QueryMapping, aliasToCollectionId: Record<string, string>, aliasRemapping: Record<string, string>, sourceWhereClauses: Map<string, BasicExpression<boolean>>, )
| 1167 | } |
| 1168 | |
| 1169 | function processUnionAll( |
| 1170 | from: UnionAll, |
| 1171 | allInputs: Record<string, KeyedStream>, |
| 1172 | collections: Record<string, Collection>, |
| 1173 | subscriptions: Record<string, CollectionSubscription>, |
| 1174 | callbacks: Record<string, LazyCollectionCallbacks>, |
| 1175 | lazySources: Set<string>, |
| 1176 | optimizableOrderByCollections: Record<string, OrderByOptimizationInfo>, |
| 1177 | setWindowFn: (windowFn: (options: WindowOptions) => void) => void, |
| 1178 | cache: QueryCache, |
| 1179 | queryMapping: QueryMapping, |
| 1180 | aliasToCollectionId: Record<string, string>, |
| 1181 | aliasRemapping: Record<string, string>, |
| 1182 | sourceWhereClauses: Map<string, BasicExpression<boolean>>, |
| 1183 | ): { |
| 1184 | alias: string |
| 1185 | pipeline: NamespacedAndKeyedStream |
| 1186 | collectionId: string |
| 1187 | sources: Record<string, KeyedStream> |
| 1188 | sourceIncludes: Array<SourceInclude> |
| 1189 | directIncludes: Array<IncludesCompilationResult> |
| 1190 | isUnionFrom: boolean |
| 1191 | } { |
| 1192 | if (from.queries.length === 0) { |
| 1193 | throw new UnsupportedFromTypeError(`empty unionAll`) |
| 1194 | } |
| 1195 | |
| 1196 | const sources: Record<string, KeyedStream> = {} |
| 1197 | const sourceIncludes: Array<SourceInclude> = [] |
| 1198 | const directIncludes: Array<IncludesCompilationResult> = [] |
| 1199 | let pipeline: NamespacedAndKeyedStream | undefined |
| 1200 | let mainCollectionId = `` |
| 1201 | const branchAliases = new Set<string>() |
| 1202 | |
| 1203 | for (let index = 0; index < from.queries.length; index++) { |
| 1204 | const branch = from.queries[index]! |
| 1205 | for (const source of getAllSources(branch)) { |
| 1206 | if (branchAliases.has(source.alias)) { |
| 1207 | throw new Error( |
| 1208 | `Duplicate source alias "${source.alias}" in unionAll query branches. ` + |
| 1209 | `Use distinct aliases in each branch before passing them to unionAll().`, |
| 1210 | ) |
| 1211 | } |
| 1212 | branchAliases.add(source.alias) |
| 1213 | } |
| 1214 | const branchResult = compileQuery( |
| 1215 | branch, |
| 1216 | allInputs, |
| 1217 | collections, |
| 1218 | subscriptions, |
| 1219 | callbacks, |
| 1220 | lazySources, |
| 1221 | optimizableOrderByCollections, |
| 1222 | setWindowFn, |
| 1223 | cache, |
| 1224 | queryMapping, |
| 1225 | ) |
| 1226 |
no test coverage detected