| 206 | // ------------------------------ |
| 207 | |
| 208 | WindowedStream::WindowedStream(thread_db* tdbb, Optimizer* opt, |
| 209 | ObjectsArray<WindowSourceNode::Window>& windows, RecordSource* next) |
| 210 | : RecordSource(opt->getCompilerScratch()), |
| 211 | m_joinedStream(nullptr) |
| 212 | { |
| 213 | const auto csb = opt->getCompilerScratch(); |
| 214 | |
| 215 | m_next = FB_NEW_POOL(csb->csb_pool) BufferedStream(csb, next); |
| 216 | m_impure = csb->allocImpure<Impure>(); |
| 217 | m_cardinality = next->getCardinality(); |
| 218 | |
| 219 | // Process the unpartioned and unordered map, if existent. |
| 220 | |
| 221 | for (auto& window : windows) |
| 222 | { |
| 223 | // While here, verify not supported functions/clauses. |
| 224 | |
| 225 | if (window.order || window.frameExtent->unit == FrameExtent::Unit::ROWS) |
| 226 | { |
| 227 | for (const auto& source : window.map->sourceList) |
| 228 | { |
| 229 | if (const auto aggNode = nodeAs<AggNode>(source)) |
| 230 | { |
| 231 | const char* arg = nullptr; |
| 232 | |
| 233 | if (aggNode->distinct) |
| 234 | arg = "DISTINCT"; |
| 235 | else if (!(aggNode->getCapabilities() & AggNode::CAP_SUPPORTS_WINDOW_FRAME)) |
| 236 | arg = aggNode->aggInfo.name; |
| 237 | |
| 238 | if (arg) |
| 239 | { |
| 240 | string msg; |
| 241 | msg.printf("%s is not supported in windows with ORDER BY or frame by ROWS clauses", arg); |
| 242 | |
| 243 | status_exception::raise( |
| 244 | Arg::Gds(isc_wish_list) << |
| 245 | Arg::Gds(isc_random) << msg); |
| 246 | } |
| 247 | } |
| 248 | } |
| 249 | } |
| 250 | |
| 251 | if (!window.group && !window.order) |
| 252 | { |
| 253 | if (!m_joinedStream) |
| 254 | { |
| 255 | m_joinedStream = FB_NEW_POOL(csb->csb_pool) WindowStream(tdbb, csb, window.stream, |
| 256 | nullptr, FB_NEW_POOL(csb->csb_pool) BufferedStreamWindow(csb, m_next), |
| 257 | nullptr, window.map, window.frameExtent, window.exclusion); |
| 258 | } |
| 259 | else |
| 260 | { |
| 261 | m_joinedStream = FB_NEW_POOL(csb->csb_pool) WindowStream(tdbb, csb, window.stream, |
| 262 | nullptr, FB_NEW_POOL(csb->csb_pool) BufferedStream(csb, m_joinedStream), |
| 263 | nullptr, window.map, window.frameExtent, window.exclusion); |
| 264 | } |
| 265 |
nothing calls this directly
no test coverage detected