|
| 1 | +# Copyright Materialize, Inc. and contributors. All rights reserved. |
| 2 | +# |
| 3 | +# Use of this software is governed by the Business Source License |
| 4 | +# included in the LICENSE file at the root of this repository. |
| 5 | +# |
| 6 | +# As of the Change Date specified in that file, in accordance with |
| 7 | +# the Business Source License, use of this software will be governed |
| 8 | +# by the Apache License, Version 2.0. |
| 9 | + |
| 10 | +# two_runtime_query_dataflow scenario: the acceptance test for the interactive |
| 11 | +# slow path (N1-N3). Unlike two_runtime_index.spec, which peeks a maintenance |
| 12 | +# index directly (the fast path), this creates a genuine INTERACTIVE QUERY |
| 13 | +# DATAFLOW: a `count(*)` reduce that imports a maintenance index and is itself |
| 14 | +# exported under a transient id (`t4000`), so the multiplexer routes its |
| 15 | +# `CreateDataflow` to the interactive runtime (see `mz_compute_client::multiplex`). |
| 16 | +# |
| 17 | +# The maintenance index is created but deliberately left unscheduled before the |
| 18 | +# query dataflow is submitted, so nothing has been published to the shared |
| 19 | +# arrangement-sharing registry yet. The interactive runtime builds the query |
| 20 | +# dataflow immediately anyway, binding its import to a real but empty publication |
| 21 | +# point (a placeholder) rather than deferring the build, which would break the |
| 22 | +# deterministic construction order every worker must follow. The query's own |
| 23 | +# `schedule` is then sent immediately, before the maintenance index is scheduled, |
| 24 | +# mirroring what the real compute controller always does for a transient |
| 25 | +# collection (`Instance::maybe_schedule_collection`: scheduled right away, without |
| 26 | +# waiting for its inputs). Only afterward is the maintenance index scheduled, which |
| 27 | +# renders it and adopts the placeholder in place; that publication (never a bare |
| 28 | +# poll) wakes the import, which begins producing. The result peek then returns the |
| 29 | +# correct reduced rows, proving the bind -> fill -> resolve path completed off the |
| 30 | +# maintenance worker. |
| 31 | +create-instance |
| 32 | +---- |
| 33 | +ok |
| 34 | + |
| 35 | +update-configuration |
| 36 | +---- |
| 37 | +ok |
| 38 | + |
| 39 | +initialization-complete |
| 40 | +---- |
| 41 | +ok |
| 42 | + |
| 43 | +write-rows shard=r ts=0 |
| 44 | + 1 alpha |
| 45 | + 2 beta |
| 46 | + 3 gamma |
| 47 | +---- |
| 48 | +wrote 3 |
| 49 | + |
| 50 | +# The maintenance index over shard `r`. Registering it lets `import index=2001` |
| 51 | +# below reference it; its dataflow is intentionally left unscheduled, so no |
| 52 | +# arrangement is published yet. |
| 53 | +create-dataflow name=maint-index as-of=0 |
| 54 | + import source=1000 shard=r upper=1 |
| 55 | + build id=2000 |
| 56 | + Project (#0, #1) |
| 57 | + Get u1000 |
| 58 | + export kind=index index=2001 on=2000 key=[0] |
| 59 | +---- |
| 60 | +ok |
| 61 | + |
| 62 | +# A one-column schema for the count reduce's output (a single bigint). |
| 63 | +define-schema name=count_out |
| 64 | + count bigint |
| 65 | +---- |
| 66 | +ok |
| 67 | + |
| 68 | +# The interactive query dataflow: `count(*)` over the (still unpublished) |
| 69 | +# maintenance index, exported under a transient id (`t4000`) so it is routed to |
| 70 | +# the interactive runtime instead of maintenance. |
| 71 | +create-dataflow name=interactive-count as-of=0 |
| 72 | + import index=2001 |
| 73 | + build id=3000 |
| 74 | + Reduce aggregates=[count(*)] |
| 75 | + Get u2000 |
| 76 | + export index=t4000 on=3000 key=[0] |
| 77 | +---- |
| 78 | +ok |
| 79 | + |
| 80 | +# Scheduled before the maintenance index: the dataflow is built but its import is |
| 81 | +# still an empty placeholder at this point, so this `Schedule` races ahead of the |
| 82 | +# publication, exactly as the real controller's immediate-schedule-of-transient |
| 83 | +# behavior would. |
| 84 | +schedule id=t4000 |
| 85 | +---- |
| 86 | +ok |
| 87 | + |
| 88 | +# Scheduling the maintenance index renders it and adopts the placeholder, waking |
| 89 | +# the interactive query dataflow's import via the publication notification. |
| 90 | +schedule id=2001 |
| 91 | +---- |
| 92 | +ok |
| 93 | + |
| 94 | +# The interactive runtime ran the reduce once notified of the publication, off the |
| 95 | +# maintenance worker. The result is the correct count. |
| 96 | +peek id=t4000 schema=count_out ts=0 |
| 97 | +---- |
| 98 | +3 |
0 commit comments