Skip to content

Instantly share code, notes, and snippets.

@apstndb
Last active September 15, 2020 05:16
Show Gist options
  • Select an option

  • Save apstndb/7cb095ed696c54781a9b5a56522aee2d to your computer and use it in GitHub Desktop.

Select an option

Save apstndb/7cb095ed696c54781a9b5a56522aee2d to your computer and use it in GitHub Desktop.

Revisions

  1. apstndb revised this gist Sep 15, 2020. 3 changed files with 139 additions and 1 deletion.
    140 changes: 139 additions & 1 deletion UnofficialSpannerOperatorCollection.md
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,52 @@
    # Unofficial Cloud Spanner operator collection

    [Query execution operators](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en) にはドキュメンテーションされていない operator もあり、 metadata やそれぞれの child links についても解説されているわけではないためここにまとめる。
    [Query execution operators](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en) にはドキュメンテーションされていない operator もあり、 metadata やそれぞれの child links についてもほぼ解説されていないためここにまとめる。

    対象: 実行計画を可視化や解析のために処理するツール作成者や、含まれる情報全てをクエリの理解に役立てたいと考えるユーザ

    TODO: Metadata や ChildLinks の表の形式化を進める。

    ## 実行計画の構造

    実行計画の実体は [`google.spanner.v1.QueryPlan`](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1?hl=en#queryplan) であり、各クライアントや Web UI が表示するものは REST API や gRPC API の `ExecuteSql` もしくは `ExecuteStreamingSql` API 経由で `QueryMode``PLAN` もしくは `PROFILE` を指定することで取得した `QueryPlan` そのものである。

    `QueryPlan`[`PlanNode`](https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1?hl=en#plannode) の集合であり、 `PlanNode` は operator と一対一で対応する。
    `PlanNode` の動作は `display_name` によって特定できる operator の種類と、 operator の動作を変える `metadata` によって決まり、`child_links` に入力として使う子の operator が列挙されている。

    実行計画に含まれる operator にはストリームを返す Relational operator の他にも Scalar operator があるが、 Scalar operator の方は親の Relational operator の一部として表示される。

    ![Web UI 上の実行計画](basic-webui.png)

    例えば上記の Table Scan operator の実体は [Scan](#scan) operator であり、 `Table Scan: Songs` の部分及び `full scan: true` は metadata からの情報を合わせて表示している。また、デフォルトでは折りたたまれている変数名とスキャン対象の列名の対応関係は全て Scalar operator である。

    <details>
    <summary>上記 Table Scan に対応する生の PlanNode の YAML 表現</summary>

    ```
    - childLinks:
    - childIndex: 4
    variable: SingerId
    - childIndex: 5
    variable: AlbumId
    - childIndex: 6
    variable: TrackId
    - childIndex: 7
    variable: SongName
    - childIndex: 8
    variable: Duration
    - childIndex: 9
    variable: SongGenre
    displayName: Scan
    index: 3
    kind: RELATIONAL
    metadata:
    Full scan: 'true'
    scan_target: Songs
    scan_type: TableScan
    ```

    </details>

    ## Relational operators

    `kind: RELATIONAL` なもので、行のストリームを返す operator である。
    @@ -659,3 +702,98 @@ replica 内にローカルな Outer Apply Join を行う。Input 側の Relation
    `shortRepresentation.description` に名前を持つ参照で metadata も子も持たない。
    Sort 系の operator の Key で降順の場合は `shortRepresentation.description``$ItemId (DESC)` のように `(DESC)` が含まれる。

    ## QueryPlan=PROFILE の構造

    ![Web UI 上でのプロファイル情報](basic-profile-webui.png)

    上記のような実行統計は `QueryMode=PROFILE` でクエリを実行した際に付与される情報の一部をレンダリングしている。上部に表示されるクエリ全体の実行統計は [ResultSetStats.queryStats](https://cloud.google.com/spanner/docs/reference/rest/v1/ResultSetStats?hl=en), 下部の各 operator ごとに表示されている統計は [PlanNode.executionStats](https://cloud.google.com/spanner/docs/reference/rest/v1/ResultSetStats?hl=en#PlanNode) を元の情報としている。

    <details>
    <summary>QueryPlan=PROFILE 時のレスポンスの YAML 表現からの抜粋</summary>

    ```yaml
    stats:
    queryPlan:
    planNodes:
    # (中略)
    - childLinks:
    - childIndex: 6
    variable: SongName
    displayName: Scan
    executionStats:
    cpu_time:
    total: "0.7"
    unit: msecs
    deleted_rows:
    total: "0"
    unit: rows
    execution_summary:
    num_executions: "1"
    filesystem_delay_seconds:
    total: "4.04"
    unit: msecs
    filtered_rows:
    total: "0"
    unit: rows
    latency:
    total: "4.51"
    unit: msecs
    rows:
    total: "100"
    unit: rows
    scanned_rows:
    total: "100"
    unit: rows
    index: 5
    kind: RELATIONAL
    metadata:
    Full scan: "true"
    scan_target: SongsBySingerAlbumSongNameDesc
    scan_type: IndexScan
    # (中略)
    queryStats:
    bytes_returned: "1486"
    cpu_time: 2.23 msecs
    data_bytes_read: "55163"
    deleted_rows_scanned: "0"
    elapsed_time: 7.3 msecs
    filesystem_delay_seconds: 4.04 msecs
    optimizer_statistics_package: ""
    optimizer_version: "2"
    query_plan_creation_time: 1.3 msecs
    query_text: SELECT s.SongName FROM Songs AS s LIMIT 100
    remote_server_calls: 0/0
    rows_returned: "100"
    rows_scanned: "100"
    runtime_creation_time: 0 msecs
    statistics_load_time: 0
    ```
    </details>
    含まれるプロファイル情報はほぼ何もドキュメンテーションされていないが、活用可能なものが多い。
    ### 既知のクエリ全体の実行統計
    |key|example|description|
    |---|---|---|
    |bytes_returned| `1486`|最終的にクライアントに返る結果のバイト数|
    |cpu_time| `2.23 msecs`| 使用した CPU 時間の合計 |
    |data_bytes_read| `55163`|読み出したバイト数|
    |deleted_rows_scanned| `0`|スキャンされた削除済の行数(いわゆる tombstone によるもの?)|
    |elapsed_time| `7.3 msecs`|総経過時間|
    |filesystem_delay_seconds| `4.04 msecs`|スキャン時に発生したファイルシステム由来の待ち時間|
    |optimizer_statistics_package| ``|未リリース機能に関するもの|
    |optimizer_version| `2`| クエリに利用された [optimizer version](https://cloud.google.com/spanner/docs/query-optimizer/overview?hl=en#query_optimizer_versioning) |
    |query_plan_creation_time| `1.3 msecs`| クエリプランの作成に掛かった時間。[Life of query](https://cloud.google.com/spanner/docs/whitepapers/life-of-query?hl=en#caching) に書かれている処理を行う時間で、同一のものは[キャッシュ](https://cloud.google.com/spanner/docs/whitepapers/life-of-query?hl=en#caching)されるのでクエリパラメータの使用により軽減される。|
    |query_text| `SELECT s.SongName FROM Songs AS s LIMIT 100`|統計の対象のクエリ本文|
    |remote_server_calls| `0/0`| distributed operator で他のサーバを呼んだ数。分子が `num_executions` の合計、分母が `remote_calls.total` の合計?(未確定)|
    |rows_returned| `100`|クライアントに返る結果の行数|
    |rows_scanned| `100`|各 Scan が読み出した行数|
    |runtime_creation_time| `0 msecs`|不明|
    |statistics_load_time| `0`|不明|

    ### 既知の PlanNode ごとの実行統計

    (TODO: operator ごとに違うのでどう書くかを考える)

    Binary file added basic-profile-webui.png
    Loading
    Sorry, something went wrong. Reload?
    Sorry, we cannot display this file.
    Sorry, this file is invalid so it cannot be displayed.
    Binary file added basic-webui.png
    Loading
    Sorry, something went wrong. Reload?
    Sorry, we cannot display this file.
    Sorry, this file is invalid so it cannot be displayed.
  2. apstndb revised this gist Sep 14, 2020. 1 changed file with 53 additions and 51 deletions.
    104 changes: 53 additions & 51 deletions UnofficialSpannerOperatorCollection.md
    Original file line number Diff line number Diff line change
    @@ -29,8 +29,8 @@ TODO: Metadata や ChildLinks の表の形式化を進める。

    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL|(Input) | | | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。通常 Create Batch を持つ。|
    |RELATIONAL| Map | | | Input 側の値に応じて分散実行される Relational operator であり、通常 Batch Scan と Cross Apply を含む。|
    |RELATIONAL|(Input) | | | いわゆる駆動表に対応する入力側のサブツリーであり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。通常 Create Batch を持つ。|
    |RELATIONAL| Map | | | Input 側の値に応じて分散実行されるサブツリーであり、通常 Batch Scan と Cross Apply を含む。|
    |SCALAR | Split Range | | | 分散実行する対象の replica をキーから限定するための Function |
    |SCALAR | Batch | Yes | Yes | Input 側の Batch から生成する行の定義? |

    @@ -50,8 +50,8 @@ TODO: Metadata や ChildLinks の表の形式化を進める。

    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| (Input) | | | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。通常 Create Batch を持つ。|
    |RELATIONAL| Map | | | Input 側の値に応じて分散実行される Relational operator であり、通常 Batch Scan と Cross Apply を含む。|
    |RELATIONAL| (Input) | | | いわゆる駆動表に対応する入力側のサブツリーであり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。通常 Create Batch を持つ。|
    |RELATIONAL| Map | | | Input 側の値に応じて分散実行されるサブツリーであり、通常 Batch Scan と Cross Apply を含む。|
    |SCALAR | Split Range | | | 分散実行する対象の replica をキーから限定するための Function |

    #### Distributed Outer Apply
    @@ -70,8 +70,8 @@ TODO: Metadata や ChildLinks の表の形式化を進める。

    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| (Input) | | | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。通常 Create Batch を持つ。|
    |RELATIONAL| Map | | | Input 側の値に応じて分散実行される Relational operator であり、通常 Batch Scan と Cross Apply を含む。|
    |RELATIONAL| (Input) | | | いわゆる駆動表に対応する入力側のサブツリーであり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。通常 Create Batch を持つ。|
    |RELATIONAL| Map | | | Input 側の値に応じて分散実行されるサブツリーであり、通常 Batch Scan と Cross Apply を含む。|
    |SCALAR | Split Range | | | 分散実行する対象の replica をキーから限定するための Function |
    |SCALAR | Batch | Yes | Yes | 結合条件を満たさなかった時に Input 側の Batch から生成する行の定義 |

    @@ -91,8 +91,8 @@ TODO: Metadata や ChildLinks の表の形式化を進める。

    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| (Input) | | | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。通常 Create Batch を持つ。|
    |RELATIONAL| Map | | | Input 側の値に応じて分散実行される Relational operator であり、通常 Batch Scan と Cross Apply を含む。|
    |RELATIONAL| (Input) | | | いわゆる駆動表に対応する入力側のサブツリーであり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。通常 Create Batch を持つ。|
    |RELATIONAL| Map | | | Input 側の値に応じて分散実行されるサブツリーであり、通常 Batch Scan と Cross Apply を含む。|
    |SCALAR | Split Range | | | 分散実行する対象の replica をキーから限定するための Function |
    |SCALAR | Batch | Yes | Yes | Input 側の Batch から生成する行の定義? |

    @@ -114,7 +114,7 @@ TODO: Metadata や ChildLinks の表の形式化を進める。

    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | | 入力として分散実行される Relation operator |
    |RELATIONAL| | | | 入力として分散実行されるサブツリー |
    |SCALAR | Split Range | | | 分散実行する対象の replica をキーから限定するための Function |

    ### Leaf operators
    @@ -131,8 +131,8 @@ Relational operator の子を持たない Relational operator 群。

    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |SCALAR | | Yes | | 配列の値に対応する変数名を指示する Scalar operator |
    |SCALAR | | Yes | | 配列の添字に対応する変数名を指示する Scalar operator |
    |SCALAR | | Yes | | 配列の値に対応する変数名を指示する |
    |SCALAR | | Yes | | 配列の添字に対応する変数名を指示する |

    #### Empty Relation

    @@ -164,7 +164,7 @@ Relational operator の子を持たない Relational operator 群。

    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |SCALAR | | Yes | Yes | スキャン対象の列を表現する Reference operator。 |
    |SCALAR | | Yes | Yes | スキャン対象の列を表現する |

    #### Unit Relation

    @@ -202,8 +202,8 @@ Relational operator の子を1つだけ持つ Relational operator 群。

    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | | 入力となる Relational operator |
    |SCALAR | Key | Yes | Yes | scalar_aggregate=true の時には存在しない。集約に使うキーを示す。|
    |RELATIONAL| | | | 入力 |
    |SCALAR | Key | Yes | Yes | `scalar_aggregate=true` の時には存在しない。集約に使うキーを示す。|
    |SCALAR | Agg| Yes | Yes |Aggregate 対象の値を示す。|

    #### Apply Mutations
    @@ -223,7 +223,7 @@ DML である `INSERT`, `UPDATE`, `DELETE` を処理する。サブツリーか

    |kind | type | variable | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | | 入力となる Relational operator |
    |RELATIONAL| | | | 入力 |

    #### BloomFilterBuild

    @@ -234,7 +234,7 @@ Bloom Filter を構築する。通常 Hash Join の Build 側に現れる。後

    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | |入力側の Relational operator |
    |RELATIONAL| | | |入力 |

    #### Compute

    @@ -246,8 +246,8 @@ Bloom Filter を構築する。通常 Hash Join の Build 側に現れる。後

    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | | 入力側の Relation operator |
    |SCALAR | | Yes | Yes | 新しく計算する値を示す Scalar operator |
    |RELATIONAL| | | | 入力 |
    |SCALAR | | Yes | Yes | 新しく計算する値を示す |

    #### Compute Struct

    @@ -259,8 +259,8 @@ Bloom Filter を構築する。通常 Hash Join の Build 側に現れる。後

    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | | 入力側の Relation operator |
    |SCALAR | | Yes | Yes | STRUCT の各フィールドを表す Scalar operator |
    |RELATIONAL| | | | 入力 |
    |SCALAR | | Yes | Yes | STRUCT の各フィールドを表す |

    #### Create Batch

    @@ -272,7 +272,7 @@ Bloom Filter を構築する。通常 Hash Join の Build 側に現れる。後

    |kind | type | variable | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | | 入力側の Relation operator |
    |RELATIONAL| | | | 入力 |
    |SCALAR | | variable | | batch の名前を指定する |

    #### Filter
    @@ -305,6 +305,8 @@ Scan のすぐ上に位置し、スキャンに伴うフィルタを行う。Sca

    Limit のみを行う。 `ORDER BY` を指定しないか、キー順と一致する順序で指定して `LIMIT` を指定した際に現れる。

    * https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#limit

    ##### Metadata

    | key | values | description |
    @@ -315,10 +317,9 @@ Limit のみを行う。 `ORDER BY` を指定しないか、キー順と一致

    |kind | type | variable | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | | ソート対象の入力となる Relation operator。 |
    |SCALAR | Limit | | | 取得する行数を指定する Scalar operator |

    * https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#limit
    |RELATIONAL| | | | ソート対象の入力 |
    |SCALAR | Limit | | | 取得する行数を指定する |
    |SCALAR | Offset | | | `OFFSET` 指定時に読み飛ばす行数を指定する |

    #### MiniBatchAssign

    @@ -385,8 +386,8 @@ ORDER BY と LIMIT 両方の処理をする operator。Sort Limit とほぼ同

    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | | ソート対象の入力となる Relation operator。 |
    |SCALAR | Limit | | | 取得する行数を指定する Scalar operator |
    |RELATIONAL| | | | ソート対象の入力 |
    |SCALAR | Limit | | | 取得する行数 |
    |SCALAR | MajorKey | Yes | Yes | ソートキーのうち、入力でソート済な部分が順に指定される。 |
    |SCALAR | MinorKey | Yes | Yes | ソートキーのうち、入力でソートされていない部分が順に指定される。 |
    |SCALAR | Value | Yes | Yes | ソートキー以外で取り出す列が順に指定される。 |
    @@ -403,7 +404,7 @@ ORDER BY と LIMIT 両方の処理をする operator。Sort Limit とほぼ同

    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | | 入力となる Relational operator |
    |RELATIONAL| | | | 入力 |
    |SCALAR | | Yes | | description が `<random id>` となる Reference を指す variable であり、後に Filter で名前が参照される。 |

    #### RowCount
    @@ -416,7 +417,7 @@ ORDER BY と LIMIT 両方の処理をする operator。Sort Limit とほぼ同

    |kind | type | variable | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | | 入力となる Relational operator |
    |RELATIONAL| | | | 入力 |

    #### Serialize Result

    @@ -428,8 +429,8 @@ ORDER BY と LIMIT 両方の処理をする operator。Sort Limit とほぼ同

    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | | 入力となる Relation operator。 |
    |SCALAR | | | Yes | `metadata.rowType.fields` に現れる順で対応する式を表現する Scalar operator。 |
    |RELATIONAL| | | | 入力 |
    |SCALAR | | | Yes | `metadata.rowType.fields` に現れる順で対応する式を表現する |
    |SCALAR | Scalar | | Yes | 式で参照される Scalar Subquery と名前を結びつけるために使われる。 |

    #### Sort
    @@ -442,7 +443,7 @@ ORDER BY と LIMIT 両方の処理をする operator。Sort Limit とほぼ同

    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | | ソート対象の入力となる Relation operator。 |
    |RELATIONAL| | | | ソート対象の入力 |
    |SCALAR | Key | Yes | Yes | ソートキーとなる列が Reference で順に指定される。 |
    |SCALAR | Value | Yes | Yes | ソートキー以外で取り出す列が Reference で順に指定される。 |

    @@ -462,8 +463,9 @@ ORDER BY と LIMIT 両方の処理をする operator。Sort とほぼ同じだ

    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | | ソート対象の入力となる Relation operator。 |
    |SCALAR | Limit | | | 取得する行数を指定する Scalar operator |
    |RELATIONAL| | | | ソート対象の入力 |
    |SCALAR | Limit | | | 取得する行数 |
    |SCALAR | Offset | | | 読み飛ばす行数 |
    |SCALAR | Key | Yes | Yes | ソートキーが順に指定される。 |
    |SCALAR | Value | Yes | Yes | ソートキー以外で取り出す列が順に指定される。 |

    @@ -482,8 +484,8 @@ ORDER BY と LIMIT 両方の処理をする operator。Sort とほぼ同じだ

    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | | 保存対象の入力となる Relation operator。 |
    |SCALAR | | | | 一時テーブルの列となる Scalar operator |
    |RELATIONAL| | | | 保存対象の入力 |
    |SCALAR | | | | 一時テーブルの列 |

    #### Union Input

    @@ -495,8 +497,8 @@ Union All operator のそれぞれの枝からの入力を揃えるための ope

    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | | それぞれの枝の本体となる Relation operator |
    |SCALAR | `input_{n}` | | | Union All operator の結果の n 列目となる式の Scalar operator |
    |RELATIONAL| | | | それぞれの枝の本体 |
    |SCALAR | `input_{n}` | | | Union All operator の結果の n 列目となる式 |

    ### Binary operators

    @@ -513,8 +515,8 @@ replica 内にローカルな Apply Join を行う。Input 側の Relational ope

    |kind | type | variable | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| (Input) | | | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。|
    |RELATIONAL| Map | | | Input 側の値に応じて実行される Relational operator|
    |RELATIONAL| (Input) | | | いわゆる駆動表となる入力側のサブツリーであり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。|
    |RELATIONAL| Map | | | Input 側の値に応じて実行されるサブツリー |

    #### Hash Join

    @@ -533,11 +535,11 @@ Build 側の全 row を元にハッシュマップを構築してから Probe

    |kind | type | variable | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| Build | | | 構築するハッシュマップ側になる Relational operator |
    |RELATIONAL| Probe | | | ハッシュマップに通す側の Relational operator |
    |RELATIONAL| Build | | | 構築するハッシュマップ側になるサブツリー |
    |RELATIONAL| Probe | | | ハッシュマップに通す側のサブツリー |
    |SCALAR | Condition | | | JOIN 条件となる Function |
    |SCALAR | Build | Yes | Yes | Build 側からハッシュマップに含める列を指定する Scalar operator |
    |SCALAR | Probe | Yes | Yes | Probe 側から variable を定義する Scalar operator |
    |SCALAR | Build | Yes | Yes | Build 側からハッシュマップに含める列を指定 |
    |SCALAR | Probe | Yes | Yes | Probe 側から variable を定義 |

    #### Outer Apply

    @@ -550,8 +552,8 @@ replica 内にローカルな Outer Apply Join を行う。Input 側の Relation

    |kind | type | variable | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| (Input) | | | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。|
    |RELATIONAL| Map | | | Input 側の値に応じて実行される Relational operator|
    |RELATIONAL| (Input) | | | いわゆる駆動表となる入力側のサブツリーであり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。|
    |RELATIONAL| Map | | | Input 側の値に応じて実行されるサブツリー |
    |SCALAR | | Yes | * | 結合条件を満たさなかった時に Input 側から生成する行の定義 |

    ### N-ary operators
    @@ -568,7 +570,7 @@ replica 内にローカルな Outer Apply Join を行う。Input 側の Relation

    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | Yes | UNION 対象を指す任意個数の Union Input operator |
    |RELATIONAL| | | Yes | UNION 対象を指す任意個数の Union Input operator |
    |SCALAR | | Yes | Yes | Union All operator の結果の n 列目の名前を持ち、 `input_{n}` と対応付ける Scalar operator |

    ## Scalar operators
    @@ -589,8 +591,8 @@ replica 内にローカルな Outer Apply Join を行う。Input 側の Relation

    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | | サブクエリとなる Relational operator で中で variable を定義する。 |
    |SCALAR | | | | サブクエリの中の variable を参照する Scalar operator。サブクエリの各 row に対して配列の要素を計算するために使われる。 |
    |RELATIONAL| | | | サブクエリとなるサブツリーで中で variable を定義する。 |
    |SCALAR | | | | サブクエリの中の variable を参照する式。サブクエリの各 row に対して配列の要素を計算するために使われる。 |

    #### Scalar Subquery

    @@ -602,7 +604,7 @@ replica 内にローカルな Outer Apply Join を行う。Input 側の Relation

    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | | サブクエリとなる Relational operator で、中で variable を定義する。 |
    |RELATIONAL| | | | サブクエリとなるサブツリーで、中で variable を定義する。 |
    |SCALAR | | | | サブクエリの中の variable を参照する。 |

    ### その他の Scalar operators
    @@ -619,7 +621,7 @@ replica 内にローカルな Outer Apply Join を行う。Input 側の Relation

    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |SCALAR | | | Yes | 配列の各値を表現する Scalar operator を指す|
    |SCALAR | | | Yes | 配列の各値を表現する式|

    #### Constant

  3. apstndb revised this gist Sep 14, 2020. 1 changed file with 83 additions and 28 deletions.
    111 changes: 83 additions & 28 deletions UnofficialSpannerOperatorCollection.md
    Original file line number Diff line number Diff line change
    @@ -8,10 +8,12 @@ TODO: Metadata や ChildLinks の表の形式化を進める。

    `kind: RELATIONAL` なもので、行のストリームを返す operator である。

    ### [Distributed operators](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#distributed_operators)
    ### Distributed operators

    分散実行される operator 群であり、 `subquery_cluster_node` が指す方の子の Relational operator からなる実行計画のサブツリーを `Split Range` の条件を満たす remote server で実行するとで、 server を跨ぐ replica から結果を得るという共通点がある。

    * https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#distributed_operators

    #### Distributed Anti Semi Apply

    (Undocumented)
    @@ -32,10 +34,12 @@ TODO: Metadata や ChildLinks の表の形式化を進める。
    |SCALAR | Split Range | | | 分散実行する対象の replica をキーから限定するための Function |
    |SCALAR | Batch | Yes | Yes | Input 側の Batch から生成する行の定義? |

    #### [Distributed Cross Apply](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#distributed-cross-apply)
    #### Distributed Cross Apply

    分散 Apply Join を行う。Input 側の Relational operator から取り出した値を使って、対応する Map 側の Relational operator を適切な replica で実行することで分散 JOIN を実現する。

    * https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#distributed-cross-apply

    ##### Metadata

    | key | values | description |
    @@ -50,10 +54,12 @@ TODO: Metadata や ChildLinks の表の形式化を進める。
    |RELATIONAL| Map | | | Input 側の値に応じて分散実行される Relational operator であり、通常 Batch Scan と Cross Apply を含む。|
    |SCALAR | Split Range | | | 分散実行する対象の replica をキーから限定するための Function |

    #### [Distributed Outer Apply](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#distributed-outer-apply)
    #### Distributed Outer Apply

    `LEFT OUTER JOIN` などを処理するために分散 OUTER JOIN を行う。Distributed Cross Apply と似た構造を持つ。

    * https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#distributed-outer-apply)

    ##### Metadata

    | key | values | description |
    @@ -90,12 +96,14 @@ TODO: Metadata や ChildLinks の表の形式化を進める。
    |SCALAR | Split Range | | | 分散実行する対象の replica をキーから限定するための Function |
    |SCALAR | Batch | Yes | Yes | Input 側の Batch から生成する行の定義? |

    #### [Distributed Union](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#distributed-cross-apply)
    #### Distributed Union

    各 replica で子の Relation operator を実行し、結果をまとめる。
    クエリ対象の replica を他の server(remote server) が持つ場合、remote server を呼び出すため remote call が発生し、 `executionStats` に記録される`。
    `call_type` が Local なものは、特定の server 内の結果をまとめる。

    * https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#distributed-cross-apply

    ##### Metadata
    | key | values | description |
    |-----|--------|-------------|
    @@ -113,31 +121,37 @@ TODO: Metadata や ChildLinks の表の形式化を進める。

    Relational operator の子を持たない Relational operator 群。

    #### [Array Unnest](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#array-unnest)
    #### Array Unnest

    配列の値と添字を元に Relation を作り出す operator。

    * https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#array-unnest

    ##### ChildLinks

    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |SCALAR | | Yes | | 配列の値に対応する変数名を指示する Scalar operator |
    |SCALAR | | Yes | | 配列の添字に対応する変数名を指示する Scalar operator |

    #### [Empty Relation](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#empty-relation)
    #### Empty Relation

    空の Relation を生成する。`LIMIT 0` を指定した際には常に結果は 0 行で何も Scan 等の入力をする必要がないが、 Relation operator ではある必要があるので使われる。

    * https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#empty-relation

    ##### ChildLinks

    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |SCALAR | | | | 0 を意味する Constant |

    #### [Scan](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#scan)
    #### Scan

    各入力からのスキャンを行う。`PlanNode.displayName` としては Scan だが、一般的に `scan_type` の値と合わせて Index Scan, Table Scan などと表示される。

    * https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#scan

    ##### Metadata

    | key | values | description |
    @@ -152,11 +166,13 @@ Relational operator の子を持たない Relational operator 群。
    |----------|-----|--------|---|-------------|
    |SCALAR | | Yes | Yes | スキャン対象の列を表現する Reference operator。 |

    #### [Unit Relation](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#unit-relation)
    #### Unit Relation

    特に値を持たない単一の行を生成する。 Unit Relation を受ける Compute や Serialize Result で実際の列の値が設定される。
    例: `SELECT 42`, `SELECT 42 UNION ALL SELECT 43`

    * https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#unit-relation

    ##### Child Links

    |kind | type | variable? | multiple? | description |
    @@ -167,11 +183,13 @@ Relational operator の子を持たない Relational operator 群。

    Relational operator の子を1つだけ持つ Relational operator 群。

    #### [Aggregate](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#aggregate)
    #### Aggregate

    `GROUP BY` に対応する集約を行う。
    入力がインデックス等で既にソート済であり、その順序で集約することでハッシュテーブルを使わなくて良い時は `call_type` が Stream となり Stream Aggregate と呼ばれる。

    * https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#aggregate

    ##### Metadata

    | key | values | description |
    @@ -188,10 +206,12 @@ Relational operator の子を1つだけ持つ Relational operator 群。
    |SCALAR | Key | Yes | Yes | scalar_aggregate=true の時には存在しない。集約に使うキーを示す。|
    |SCALAR | Agg| Yes | Yes |Aggregate 対象の値を示す。|

    #### [Apply Mutations](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#aggregate)
    #### Apply Mutations

    DML である `INSERT`, `UPDATE`, `DELETE` を処理する。サブツリーから row として取得した主キーと更新後の値を適用すると考えられるが、どの列をどのような式で更新するかのような定義は実行計画上は見えない。

    * https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#aggregate

    ##### Metadata

    | key | values | description |
    @@ -216,62 +236,72 @@ Bloom Filter を構築する。通常 Hash Join の Build 側に現れる。後
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | |入力側の Relational operator |

    #### [Compute](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#compute_struct)
    #### Compute

    入力のそれぞれの行に対して新しい列を追加する。

    * https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#compute_struct

    ##### ChildLinks

    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | | 入力側の Relation operator |
    |SCALAR | | Yes | Yes | 新しく計算する値を示す Scalar operator |

    #### [Compute Struct](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#compute_struct)
    #### Compute Struct

    入力のそれぞれの行に対して STRUCT を生成する。 Compute Batch の入力や `AS STRUCT` を使ったサブクエリなどで現れる。

    * https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#compute_struct

    ##### ChildLinks

    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | | 入力側の Relation operator |
    |SCALAR | | Yes | Yes | STRUCT の各フィールドを表す Scalar operator |

    #### [Create Batch](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#create_batch)
    #### Create Batch

    入力から batch を作成する。主に Distributed Cross Apply で入力をまとめて対応する replica に送り、 Batch Scan で参照するために使われる。

    * https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#create_batch

    ##### ChildLinks

    |kind | type | variable | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | | 入力側の Relation operator |
    |SCALAR | | variable | | batch の名前を指定する |

    #### [Filter](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#filter)
    #### Filter

    スキャンとは独立して任意のタイミングで行をフィルタする。

    * https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#filter

    ##### ChildLinks
    |kind | type | variable | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | | フィルタの入力となる Scan |
    |SCALAR | Condition | | | 入力からフィルタする Function |

    #### [FilterScan](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#filter_scan)
    #### FilterScan

    Scan のすぐ上に位置し、スキャンに伴うフィルタを行う。Scan の一部として働くため `executionStats` を持たず、実行時の挙動は Scan 側の `rows`, `filtered_rows` などを通して確認できる。

    * https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#filter_scan

    ##### ChildLinks
    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | | フィルタの入力となる Scan |
    |SCALAR | Seek Condition | | | スキャン対象のキー範囲を絞るシークに使う Function であり、 [アクセス述語](https://use-the-index-luke.com/ja/sql/where-clause/searching-for-ranges/greater-less-between-tuning-sql-access-filter-predicates)に対応する。|
    |SCALAR | Residual Condition | | | スキャン後のフィルタに使う Function であり、[フィルタ述語](https://use-the-index-luke.com/ja/sql/where-clause/searching-for-ranges/greater-less-between-tuning-sql-access-filter-predicates)に対応する。 |

    #### [Limit](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#limit)
    #### Limit

    Limit のみを行う。 `ORDER BY` を指定しないか、キー順と一致する順序で指定して `LIMIT` を指定した際に現れる。

    @@ -288,6 +318,8 @@ Limit のみを行う。 `ORDER BY` を指定しないか、キー順と一致
    |RELATIONAL| | | | ソート対象の入力となる Relation operator。 |
    |SCALAR | Limit | | | 取得する行数を指定する Scalar operator |

    * https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#limit

    #### MiniBatchAssign

    (Undocumented)
    @@ -386,10 +418,12 @@ ORDER BY と LIMIT 両方の処理をする operator。Sort Limit とほぼ同
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | | 入力となる Relational operator |

    #### [Serialize Result](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#serialize_result)
    #### Serialize Result

    最終的に ResultSet に含まれる値を組み立てる。これよりも上の operator で row の値を操作することはない。

    * https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#serialize_result

    ##### ChildLinks

    |kind | type | variable? | multiple? | description |
    @@ -398,10 +432,12 @@ ORDER BY と LIMIT 両方の処理をする operator。Sort Limit とほぼ同
    |SCALAR | | | Yes | `metadata.rowType.fields` に現れる順で対応する式を表現する Scalar operator。 |
    |SCALAR | Scalar | | Yes | 式で参照される Scalar Subquery と名前を結びつけるために使われる。 |

    #### [Sort](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#sort)
    #### Sort

    `ORDER BY` によるソートのみをする operator。Sort Limit とほぼ同じだが、 `LIMIT` を設定しない場合はこちらになる。

    * https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#sort

    ##### ChildLinks

    |kind | type | variable? | multiple? | description |
    @@ -410,10 +446,12 @@ ORDER BY と LIMIT 両方の処理をする operator。Sort Limit とほぼ同
    |SCALAR | Key | Yes | Yes | ソートキーとなる列が Reference で順に指定される。 |
    |SCALAR | Value | Yes | Yes | ソートキー以外で取り出す列が Reference で順に指定される。 |

    #### [Sort Limit](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#sort)
    #### Sort Limit

    ORDER BY と LIMIT 両方の処理をする operator。Sort とほぼ同じだが、 `LIMIT` を使う場合はこちらになる。

    * https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#sort

    ##### Metadata

    | key | values | description |
    @@ -447,10 +485,12 @@ ORDER BY と LIMIT 両方の処理をする operator。Sort とほぼ同じだ
    |RELATIONAL| | | | 保存対象の入力となる Relation operator。 |
    |SCALAR | | | | 一時テーブルの列となる Scalar operator |

    #### [Union Input](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#union_input)
    #### Union Input

    Union All operator のそれぞれの枝からの入力を揃えるための operator。

    * https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#union_input

    ##### ChildLinks

    |kind | type | variable? | multiple? | description |
    @@ -462,22 +502,27 @@ Union All operator のそれぞれの枝からの入力を揃えるための ope

    Relational operator の子を2つ持つ Relational operator 群。

    #### [Cross Apply](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#cross-apply)
    #### Cross Apply

    replica 内にローカルな Apply Join を行う。Input 側の Relational operator から取り出した値を使って、対応する Map 側の Relational operator を実行することで JOIN を実現する。
    主に Distributed Cross Apply の中で使われる場合と、 INTERLEAVE されたテーブル間の JOIN で使われる場合がある。

    * https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#cross-apply

    ##### ChildLinks

    |kind | type | variable | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| (Input) | | | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。|
    |RELATIONAL| Map | | | Input 側の値に応じて実行される Relational operator|
    #### [Hash Join](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#hash-join)

    #### Hash Join

    ハッシュ結合を行う。
    Build 側の全 row を元にハッシュマップを構築してから Probe 側の各 row の値を使ってハッシュマップを引くことで Condition を評価して JOIN を行う。

    * https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#hash-join

    ##### Metadata

    | key | values | description |
    @@ -494,11 +539,13 @@ Build 側の全 row を元にハッシュマップを構築してから Probe
    |SCALAR | Build | Yes | Yes | Build 側からハッシュマップに含める列を指定する Scalar operator |
    |SCALAR | Probe | Yes | Yes | Probe 側から variable を定義する Scalar operator |

    #### [Outer Apply](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#outer-apply)
    #### Outer Apply

    replica 内にローカルな Outer Apply Join を行う。Input 側の Relational operator から取り出した値を使って、対応する Map 側の Relational operator を実行することで JOIN を実現する。
    主に Distributed Outer Apply の中で使われる場合と、 INTERLEAVE されたテーブル間の JOIN で使われる場合がある。

    * https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#outer-apply

    ##### ChildLinks

    |kind | type | variable | multiple? | description |
    @@ -511,10 +558,12 @@ replica 内にローカルな Outer Apply Join を行う。Input 側の Relation

    任意の数の Relational operator の子を持つ Relational operator 群。`Union All` 以外確認されていない。

    #### [Union All](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#union_all)
    #### Union All

    `UNION ALL` を表現する operator で、任意の数の子の Union Input が返す行を合わせて返す。

    * https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#union_all

    ##### ChildLinks

    |kind | type | variable? | multiple? | description |
    @@ -530,21 +579,25 @@ replica 内にローカルな Outer Apply Join を行う。Input 側の Relation

    サブクエリは1つの Relational operator を子に持ち、 ARRAY やスカラに変換する Scalar operator として処理される。[Scalar subqueries](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#scalar_subqueries) で説明されているように最適化の結果 Cross Apply などで実現されることもある。

    #### [Array Subquery](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#array_subqueries)
    #### Array Subquery

    子のサブクエリと式から配列を計算する。

    * https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#array_subqueries

    ##### Child Links

    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | | サブクエリとなる Relational operator で中で variable を定義する。 |
    |SCALAR | | | | サブクエリの中の variable を参照する Scalar operator。サブクエリの各 row に対して配列の要素を計算するために使われる。 |

    #### [Scalar Subquery](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#unit-relation)
    #### Scalar Subquery

    子のサブクエリと式からスカラ値を計算する。

    * https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#unit-relation

    ##### Child Links

    |kind | type | variable? | multiple? | description |
    @@ -587,14 +640,16 @@ replica 内にローカルな Outer Apply Join を行う。Input 側の Relation
    #### Parameter

    (Undocumented)
    クエリパラメータに対応する Scalar operator であり、実行時に `Statement.params` の name metadata と一致する名前の値に置き換えられる。
    クエリパラメータに対応する Scalar operator であり、実行時に `Statement.params` の name metadata と一致する名前の値として評価される。

    通常はパラメータはスカラ値である前提でクエリが評価されるので、 [Working with STRUCT objects](https://cloud.google.com/spanner/docs/structs?hl=en) にあるような配列や構造体型のパラメータを使うクエリは `param_types` に型を渡さないとエラーとなり、実行計画の取得はできない点に注意する必要がある。

    ##### Metadata

    | key | values | description |
    |-----|--------|-------------|
    | name | | パラメータ名 |
    | type | scalar, ? | |
    | type | array, scalar, ... | クエリパラメータが配列かスカラ値かを示す。 `STRUCT` 型の値も `scalar` となる。 |

    #### Reference

  4. apstndb revised this gist Sep 8, 2020. 1 changed file with 86 additions and 86 deletions.
    172 changes: 86 additions & 86 deletions UnofficialSpannerOperatorCollection.md
    Original file line number Diff line number Diff line change
    @@ -25,12 +25,12 @@ TODO: Metadata や ChildLinks の表の形式化を進める。

    ##### ChildLinks

    |kind | type | variable | position | description |
    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL|(Input) | | 0 | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。通常 Create Batch を持つ。|
    |RELATIONAL| Map | | 0 | Input 側の値に応じて分散実行される Relational operator であり、通常 Batch Scan と Cross Apply を含む。|
    |SCALAR | Split Range | | 0 | 分散実行する対象の replica をキーから限定するための Function |
    |SCALAR | Batch | Yes | * | Input 側の Batch から生成する行の定義? |
    |RELATIONAL|(Input) | | | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。通常 Create Batch を持つ。|
    |RELATIONAL| Map | | | Input 側の値に応じて分散実行される Relational operator であり、通常 Batch Scan と Cross Apply を含む。|
    |SCALAR | Split Range | | | 分散実行する対象の replica をキーから限定するための Function |
    |SCALAR | Batch | Yes | Yes | Input 側の Batch から生成する行の定義? |

    #### [Distributed Cross Apply](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#distributed-cross-apply)

    @@ -44,11 +44,11 @@ TODO: Metadata や ChildLinks の表の形式化を進める。

    ##### ChildLinks

    |kind | type | variable | position | description |
    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| (Input) | | 0 | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。通常 Create Batch を持つ。|
    |RELATIONAL| Map | | 0 | Input 側の値に応じて分散実行される Relational operator であり、通常 Batch Scan と Cross Apply を含む。|
    |SCALAR | Split Range | | 0 | 分散実行する対象の replica をキーから限定するための Function |
    |RELATIONAL| (Input) | | | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。通常 Create Batch を持つ。|
    |RELATIONAL| Map | | | Input 側の値に応じて分散実行される Relational operator であり、通常 Batch Scan と Cross Apply を含む。|
    |SCALAR | Split Range | | | 分散実行する対象の replica をキーから限定するための Function |

    #### [Distributed Outer Apply](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#distributed-outer-apply)

    @@ -62,12 +62,12 @@ TODO: Metadata や ChildLinks の表の形式化を進める。

    ##### ChildLinks

    |kind | type | variable | position | description |
    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| (Input) | | 0 | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。通常 Create Batch を持つ。|
    |RELATIONAL| Map | | 0 | Input 側の値に応じて分散実行される Relational operator であり、通常 Batch Scan と Cross Apply を含む。|
    |SCALAR | Split Range | | 0 | 分散実行する対象の replica をキーから限定するための Function |
    |SCALAR | Batch | Yes | * | 結合条件を満たさなかった時に Input 側の Batch から生成する行の定義 |
    |RELATIONAL| (Input) | | | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。通常 Create Batch を持つ。|
    |RELATIONAL| Map | | | Input 側の値に応じて分散実行される Relational operator であり、通常 Batch Scan と Cross Apply を含む。|
    |SCALAR | Split Range | | | 分散実行する対象の replica をキーから限定するための Function |
    |SCALAR | Batch | Yes | Yes | 結合条件を満たさなかった時に Input 側の Batch から生成する行の定義 |


    #### Distributed Semi Apply
    @@ -83,12 +83,12 @@ TODO: Metadata や ChildLinks の表の形式化を進める。

    ##### ChildLinks

    |kind | type | variable | position | description |
    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| (Input) | | 0 | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。通常 Create Batch を持つ。|
    |RELATIONAL| Map | | 0 | Input 側の値に応じて分散実行される Relational operator であり、通常 Batch Scan と Cross Apply を含む。|
    |SCALAR | Split Range | | 0 | 分散実行する対象の replica をキーから限定するための Function |
    |SCALAR | Batch | Yes | * | Input 側の Batch から生成する行の定義? |
    |RELATIONAL| (Input) | | | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。通常 Create Batch を持つ。|
    |RELATIONAL| Map | | | Input 側の値に応じて分散実行される Relational operator であり、通常 Batch Scan と Cross Apply を含む。|
    |SCALAR | Split Range | | | 分散実行する対象の replica をキーから限定するための Function |
    |SCALAR | Batch | Yes | Yes | Input 側の Batch から生成する行の定義? |

    #### [Distributed Union](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#distributed-cross-apply)

    @@ -104,10 +104,10 @@ TODO: Metadata や ChildLinks の表の形式化を進める。

    ##### ChildLinks

    |kind | type | variable | position | description |
    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | | 入力として分散実行される Relation operator |
    |SCALAR | Split Range | | 0 | 分散実行する対象の replica をキーから限定するための Function |
    |SCALAR | Split Range | | | 分散実行する対象の replica をキーから限定するための Function |

    ### Leaf operators

    @@ -119,20 +119,20 @@ Relational operator の子を持たない Relational operator 群。

    ##### ChildLinks

    |kind | type | variable | position | description |
    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |SCALAR | | Yes | 0 | 配列の値に対応する変数名を指示する Scalar operator |
    |SCALAR | | Yes | 1 | 配列の添字に対応する変数名を指示する Scalar operator |
    |SCALAR | | Yes | | 配列の値に対応する変数名を指示する Scalar operator |
    |SCALAR | | Yes | | 配列の添字に対応する変数名を指示する Scalar operator |

    #### [Empty Relation](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#empty-relation)

    空の Relation を生成する。`LIMIT 0` を指定した際には常に結果は 0 行で何も Scan 等の入力をする必要がないが、 Relation operator ではある必要があるので使われる。

    ##### ChildLinks

    |kind | type | variable | position | description |
    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |SCALAR | | | 0 | 0 を意味する Constant |
    |SCALAR | | | | 0 を意味する Constant |

    #### [Scan](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#scan)

    @@ -148,9 +148,9 @@ Relational operator の子を持たない Relational operator 群。

    ##### ChildLinks

    |kind | type | variable? | position | description |
    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |SCALAR | | Yes | * | スキャン対象の列を表現する Reference operator。 |
    |SCALAR | | Yes | Yes | スキャン対象の列を表現する Reference operator。 |

    #### [Unit Relation](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#unit-relation)

    @@ -159,9 +159,9 @@ Relational operator の子を持たない Relational operator 群。

    ##### Child Links

    |kind | type | variable? | position | description |
    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |SCALAR | | | 0 | `1` を表現する Constant が常に指定される。|
    |SCALAR | | | Yes | `1` を表現する Constant が常に指定される。|

    ### Unary operators

    @@ -182,11 +182,11 @@ Relational operator の子を1つだけ持つ Relational operator 群。

    ##### ChildLinks

    |kind | type | variable | position | description |
    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | | 入力となる Relational operator |
    |SCALAR | Key | Yes | * | scalar_aggregate=true の時には存在しない。集約に使うキーを示す。|
    |SCALAR | Agg| Yes | * |Aggregate 対象の値を示す。|
    |SCALAR | Key | Yes | Yes | scalar_aggregate=true の時には存在しない。集約に使うキーを示す。|
    |SCALAR | Agg| Yes | Yes |Aggregate 対象の値を示す。|

    #### [Apply Mutations](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#aggregate)

    @@ -201,7 +201,7 @@ DML である `INSERT`, `UPDATE`, `DELETE` を処理する。サブツリーか

    ##### ChildLinks

    |kind | type | variable | position | description |
    |kind | type | variable | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | | 入力となる Relational operator |

    @@ -212,7 +212,7 @@ Bloom Filter を構築する。通常 Hash Join の Build 側に現れる。後

    ##### ChildLinks

    |kind | type | variable | position | description |
    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | |入力側の Relational operator |

    @@ -222,29 +222,29 @@ Bloom Filter を構築する。通常 Hash Join の Build 側に現れる。後

    ##### ChildLinks

    |kind | type | variable | position | description |
    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | | 入力側の Relation operator |
    |SCALAR | | variable | * | 新しく計算する値を示す Scalar operator |
    |SCALAR | | Yes | Yes | 新しく計算する値を示す Scalar operator |

    #### [Compute Struct](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#compute_struct)

    入力のそれぞれの行に対して STRUCT を生成する。 Compute Batch の入力や `AS STRUCT` を使ったサブクエリなどで現れる。

    ##### ChildLinks

    |kind | type | variable | position | description |
    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | | 入力側の Relation operator |
    |SCALAR | | variable | * | STRUCT の各フィールドを表す Scalar operator |
    |SCALAR | | Yes | Yes | STRUCT の各フィールドを表す Scalar operator |

    #### [Create Batch](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#create_batch)

    入力から batch を作成する。主に Distributed Cross Apply で入力をまとめて対応する replica に送り、 Batch Scan で参照するために使われる。

    ##### ChildLinks

    |kind | type | variable | position | description |
    |kind | type | variable | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | | 入力側の Relation operator |
    |SCALAR | | variable | | batch の名前を指定する |
    @@ -254,22 +254,22 @@ Bloom Filter を構築する。通常 Hash Join の Build 側に現れる。後
    スキャンとは独立して任意のタイミングで行をフィルタする。

    ##### ChildLinks
    |kind | type | variable | position | description |
    |kind | type | variable | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | | フィルタの入力となる Scan |
    |SCALAR | Condition | | 0 | 入力からフィルタする Function |
    |SCALAR | Condition | | | 入力からフィルタする Function |

    #### [FilterScan](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#filter_scan)

    Scan のすぐ上に位置し、スキャンに伴うフィルタを行う。Scan の一部として働くため `executionStats` を持たず、実行時の挙動は Scan 側の `rows`, `filtered_rows` などを通して確認できる。

    ##### ChildLinks
    |kind | type | variable | position | description |
    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | | フィルタの入力となる Scan |
    |SCALAR | Seek Condition | | 0 | スキャン対象のキー範囲を絞るシークに使う Function であり、 [アクセス述語](https://use-the-index-luke.com/ja/sql/where-clause/searching-for-ranges/greater-less-between-tuning-sql-access-filter-predicates)に対応する。|
    |SCALAR | Residual Condition | | 0 | スキャン後のフィルタに使う Function であり、[フィルタ述語](https://use-the-index-luke.com/ja/sql/where-clause/searching-for-ranges/greater-less-between-tuning-sql-access-filter-predicates)に対応する。 |
    |SCALAR | Seek Condition | | | スキャン対象のキー範囲を絞るシークに使う Function であり、 [アクセス述語](https://use-the-index-luke.com/ja/sql/where-clause/searching-for-ranges/greater-less-between-tuning-sql-access-filter-predicates)に対応する。|
    |SCALAR | Residual Condition | | | スキャン後のフィルタに使う Function であり、[フィルタ述語](https://use-the-index-luke.com/ja/sql/where-clause/searching-for-ranges/greater-less-between-tuning-sql-access-filter-predicates)に対応する。 |

    #### [Limit](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#limit)

    @@ -283,10 +283,10 @@ Limit のみを行う。 `ORDER BY` を指定しないか、キー順と一致

    ##### ChildLinks

    |kind | type | variable | position | description |
    |kind | type | variable | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | | ソート対象の入力となる Relation operator。 |
    |SCALAR | Limit | | 0 | 取得する行数を指定する Scalar operator |
    |SCALAR | Limit | | | 取得する行数を指定する Scalar operator |

    #### MiniBatchAssign

    @@ -297,7 +297,7 @@ MiniBatchAssign より下にある以外はよく分かっていない。

    ##### ChildLinks

    |kind | type | variable? | position | description |
    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | | 入力となる Relation operator。 |
    |SCALAR | | | | Scalar operator。バッチサイズを指示している? |
    @@ -312,7 +312,7 @@ MiniBatchAssign より上にある以外はよく分かっていない。

    ##### ChildLinks

    |kind | type | variable? | position | description |
    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | | 入力となる Relation operator。 |

    @@ -330,12 +330,12 @@ MiniBatchAssign より上にある以外はよく分かっていない。

    ##### ChildLinks

    |kind | type | variable? | position | description |
    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | | ソート対象の入力となる Relation operator。 |
    |SCALAR | MajorKey | Yes | * | ソートキーのうち、入力でソート済な部分が順に指定される。 |
    |SCALAR | MinorKey | Yes | * | ソートキーのうち、入力でソートされていない部分が順に指定される。 |
    |SCALAR | Value | Yes | * | ソートキー以外で取り出す列が順に指定される。 |
    |SCALAR | MajorKey | Yes | Yes | ソートキーのうち、入力でソート済な部分が順に指定される。 |
    |SCALAR | MinorKey | Yes | Yes | ソートキーのうち、入力でソートされていない部分が順に指定される。 |
    |SCALAR | Value | Yes | Yes | ソートキー以外で取り出す列が順に指定される。 |

    #### Minor Sort Limit

    @@ -351,13 +351,13 @@ ORDER BY と LIMIT 両方の処理をする operator。Sort Limit とほぼ同

    ##### ChildLinks

    |kind | type | variable? | position | description |
    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | | ソート対象の入力となる Relation operator。 |
    |SCALAR | Limit | | 0 | 取得する行数を指定する Scalar operator |
    |SCALAR | MajorKey | Yes | * | ソートキーのうち、入力でソート済な部分が順に指定される。 |
    |SCALAR | MinorKey | Yes | * | ソートキーのうち、入力でソートされていない部分が順に指定される。 |
    |SCALAR | Value | Yes | * | ソートキー以外で取り出す列が順に指定される。 |
    |SCALAR | Limit | | | 取得する行数を指定する Scalar operator |
    |SCALAR | MajorKey | Yes | Yes | ソートキーのうち、入力でソート済な部分が順に指定される。 |
    |SCALAR | MinorKey | Yes | Yes | ソートキーのうち、入力でソートされていない部分が順に指定される。 |
    |SCALAR | Value | Yes | Yes | ソートキー以外で取り出す列が順に指定される。 |


    #### Random Id Assign
    @@ -369,7 +369,7 @@ ORDER BY と LIMIT 両方の処理をする operator。Sort Limit とほぼ同

    ##### ChildLinks

    |kind | type | variable? | position | description |
    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | | 入力となる Relational operator |
    |SCALAR | | Yes | | description が `<random id>` となる Reference を指す variable であり、後に Filter で名前が参照される。 |
    @@ -392,23 +392,23 @@ ORDER BY と LIMIT 両方の処理をする operator。Sort Limit とほぼ同

    ##### ChildLinks

    |kind | type | variable? | position | description |
    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | | 入力となる Relation operator。 |
    |SCALAR | | | * | `metadata.rowType.fields` に現れる順で対応する式を表現する Scalar operator。 |
    |SCALAR | Scalar | | * | 式で参照される Scalar Subquery と名前を結びつけるために使われる。 |
    |SCALAR | | | Yes | `metadata.rowType.fields` に現れる順で対応する式を表現する Scalar operator。 |
    |SCALAR | Scalar | | Yes | 式で参照される Scalar Subquery と名前を結びつけるために使われる。 |

    #### [Sort](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#sort)

    `ORDER BY` によるソートのみをする operator。Sort Limit とほぼ同じだが、 `LIMIT` を設定しない場合はこちらになる。

    ##### ChildLinks

    |kind | type | variable? | position | description |
    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | | ソート対象の入力となる Relation operator。 |
    |SCALAR | Key | Yes | * | ソートキーとなる列が Reference で順に指定される。 |
    |SCALAR | Value | Yes | * | ソートキー以外で取り出す列が Reference で順に指定される。 |
    |SCALAR | Key | Yes | Yes | ソートキーとなる列が Reference で順に指定される。 |
    |SCALAR | Value | Yes | Yes | ソートキー以外で取り出す列が Reference で順に指定される。 |

    #### [Sort Limit](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#sort)

    @@ -422,12 +422,12 @@ ORDER BY と LIMIT 両方の処理をする operator。Sort とほぼ同じだ

    ##### ChildLinks

    |kind | type | variable? | position | description |
    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | | ソート対象の入力となる Relation operator。 |
    |SCALAR | Limit | | 0 | 取得する行数を指定する Scalar operator |
    |SCALAR | Key | Yes | * | ソートキーが順に指定される。 |
    |SCALAR | Value | Yes | * | ソートキー以外で取り出す列が順に指定される。 |
    |SCALAR | Limit | | | 取得する行数を指定する Scalar operator |
    |SCALAR | Key | Yes | Yes | ソートキーが順に指定される。 |
    |SCALAR | Value | Yes | Yes | ソートキー以外で取り出す列が順に指定される。 |

    #### SpoolBuild

    @@ -442,7 +442,7 @@ ORDER BY と LIMIT 両方の処理をする operator。Sort とほぼ同じだ

    ##### ChildLinks

    |kind | type | variable? | position | description |
    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | | 保存対象の入力となる Relation operator。 |
    |SCALAR | | | | 一時テーブルの列となる Scalar operator |
    @@ -453,7 +453,7 @@ Union All operator のそれぞれの枝からの入力を揃えるための ope

    ##### ChildLinks

    |kind | type | variable? | position | description |
    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | | それぞれの枝の本体となる Relation operator |
    |SCALAR | `input_{n}` | | | Union All operator の結果の n 列目となる式の Scalar operator |
    @@ -469,7 +469,7 @@ replica 内にローカルな Apply Join を行う。Input 側の Relational ope

    ##### ChildLinks

    |kind | type | variable | position | description |
    |kind | type | variable | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| (Input) | | | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。|
    |RELATIONAL| Map | | | Input 側の値に応じて実行される Relational operator|
    @@ -486,13 +486,13 @@ Build 側の全 row を元にハッシュマップを構築してから Probe

    ##### ChildLinks

    |kind | type | variable | position | description |
    |kind | type | variable | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| Build | | | 構築するハッシュマップ側になる Relational operator |
    |RELATIONAL| Probe | | | ハッシュマップに通す側の Relational operator |
    |SCALAR | Condition | | 0 | JOIN 条件となる Function |
    |SCALAR | Build | Yes | * | Build 側からハッシュマップに含める列を指定する Scalar operator |
    |SCALAR | Probe | Yes | * | Probe 側から variable を定義する Scalar operator |
    |SCALAR | Condition | | | JOIN 条件となる Function |
    |SCALAR | Build | Yes | Yes | Build 側からハッシュマップに含める列を指定する Scalar operator |
    |SCALAR | Probe | Yes | Yes | Probe 側から variable を定義する Scalar operator |

    #### [Outer Apply](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#outer-apply)

    @@ -501,7 +501,7 @@ replica 内にローカルな Outer Apply Join を行う。Input 側の Relation

    ##### ChildLinks

    |kind | type | variable | position | description |
    |kind | type | variable | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| (Input) | | | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。|
    |RELATIONAL| Map | | | Input 側の値に応じて実行される Relational operator|
    @@ -517,10 +517,10 @@ replica 内にローカルな Outer Apply Join を行う。Input 側の Relation

    ##### ChildLinks

    |kind | type | variable? | position | description |
    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | * | UNION 対象を指す任意個数の Union Input operator |
    |SCALAR | | Yes | * | Union All operator の結果の n 列目の名前を持ち、 `input_{n}` と対応付ける Scalar operator |
    |RELATIONAL| | | Yes | UNION 対象を指す任意個数の Union Input operator |
    |SCALAR | | Yes | Yes | Union All operator の結果の n 列目の名前を持ち、 `input_{n}` と対応付ける Scalar operator |

    ## Scalar operators

    @@ -536,7 +536,7 @@ replica 内にローカルな Outer Apply Join を行う。Input 側の Relation

    ##### Child Links

    |kind | type | variable? | position | description |
    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | | サブクエリとなる Relational operator で中で variable を定義する。 |
    |SCALAR | | | | サブクエリの中の variable を参照する Scalar operator。サブクエリの各 row に対して配列の要素を計算するために使われる。 |
    @@ -547,7 +547,7 @@ replica 内にローカルな Outer Apply Join を行う。Input 側の Relation

    ##### Child Links

    |kind | type | variable? | position | description |
    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | | サブクエリとなる Relational operator で、中で variable を定義する。 |
    |SCALAR | | | | サブクエリの中の variable を参照する。 |
    @@ -564,9 +564,9 @@ replica 内にローカルな Outer Apply Join を行う。Input 側の Relation

    ##### Child Links

    |kind | type | variable? | position | description |
    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |SCALAR | | | * | 配列の各値を表現する Scalar operator を指す。 |
    |SCALAR | | | Yes | 配列の各値を表現する Scalar operator を指す。 |

    #### Constant

    @@ -580,9 +580,9 @@ replica 内にローカルな Outer Apply Join を行う。Input 側の Relation

    ##### Child Links

    |kind | type | variable? | position | description |
    |kind | type | variable? | multiple? | description |
    |----------|-----|--------|---|-------------|
    |SCALAR | | | * | 各オペランド |
    |SCALAR | | | Yes | 各オペランド |

    #### Parameter

  5. apstndb revised this gist Sep 8, 2020. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions UnofficialSpannerOperatorCollection.md
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,8 @@

    [Query execution operators](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en) にはドキュメンテーションされていない operator もあり、 metadata やそれぞれの child links についても解説されているわけではないためここにまとめる。

    TODO: Metadata や ChildLinks の表の形式化を進める。

    ## Relational operators

    `kind: RELATIONAL` なもので、行のストリームを返す operator である。
  6. apstndb revised this gist Sep 8, 2020. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions UnofficialSpannerOperatorCollection.md
    Original file line number Diff line number Diff line change
    @@ -291,6 +291,8 @@ Limit のみを行う。 `ORDER BY` を指定しないか、キー順と一致
    (Undocumented)
    MiniBatchAssign より下にある以外はよく分かっていない。

    [Shard 最適化クエリ](https://github.com/gcpug/nouhau/blob/spanner/shard/spanner/note/shard/README.md#v3) などで確認されている。

    ##### ChildLinks

    |kind | type | variable? | position | description |
    @@ -304,6 +306,8 @@ MiniBatchAssign より下にある以外はよく分かっていない。

    MiniBatchAssign より上にある以外はよく分かっていない。

    [Shard 最適化クエリ](https://github.com/gcpug/nouhau/blob/spanner/shard/spanner/note/shard/README.md#v3) などで確認されている。

    ##### ChildLinks

    |kind | type | variable? | position | description |
    @@ -372,6 +376,8 @@ ORDER BY と LIMIT 両方の処理をする operator。Sort Limit とほぼ同

    (Undocumented)

    [Shard 最適化クエリ](https://github.com/gcpug/nouhau/blob/spanner/shard/spanner/note/shard/README.md#v3) などで確認されている。

    ##### ChildLinks

    |kind | type | variable | position | description |
  7. apstndb revised this gist Sep 8, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion UnofficialSpannerOperatorCollection.md
    Original file line number Diff line number Diff line change
    @@ -195,7 +195,7 @@ DML である `INSERT`, `UPDATE`, `DELETE` を処理する。サブツリーか
    | key | values | description |
    |-----|--------|-------------|
    | operator_type | INSERT, UPDATE, DELETE | |
    | table | | 更新対称のテーブル |
    | table | | 更新対象のテーブル |

    ##### ChildLinks

  8. apstndb revised this gist Sep 8, 2020. No changes.
  9. apstndb revised this gist Sep 8, 2020. 1 changed file with 37 additions and 37 deletions.
    74 changes: 37 additions & 37 deletions UnofficialSpannerOperatorCollection.md
    Original file line number Diff line number Diff line change
    @@ -28,7 +28,7 @@
    |RELATIONAL|(Input) | | 0 | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。通常 Create Batch を持つ。|
    |RELATIONAL| Map | | 0 | Input 側の値に応じて分散実行される Relational operator であり、通常 Batch Scan と Cross Apply を含む。|
    |SCALAR | Split Range | | 0 | 分散実行する対象の replica をキーから限定するための Function |
    |SCALAR | Batch | Yes | * | Batch |
    |SCALAR | Batch | Yes | * | Input 側の Batch から生成する行の定義? |

    #### [Distributed Cross Apply](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#distributed-cross-apply)

    @@ -86,7 +86,7 @@
    |RELATIONAL| (Input) | | 0 | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。通常 Create Batch を持つ。|
    |RELATIONAL| Map | | 0 | Input 側の値に応じて分散実行される Relational operator であり、通常 Batch Scan と Cross Apply を含む。|
    |SCALAR | Split Range | | 0 | 分散実行する対象の replica をキーから限定するための Function |
    |SCALAR | Batch | Yes | * | Batch |
    |SCALAR | Batch | Yes | * | Input 側の Batch から生成する行の定義? |

    #### [Distributed Union](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#distributed-cross-apply)

    @@ -104,7 +104,7 @@

    |kind | type | variable | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | 0 | 入力として分散実行される Relation operator |
    |RELATIONAL| | | | 入力として分散実行される Relation operator |
    |SCALAR | Split Range | | 0 | 分散実行する対象の replica をキーから限定するための Function |

    ### Leaf operators
    @@ -182,7 +182,7 @@ Relational operator の子を1つだけ持つ Relational operator 群。

    |kind | type | variable | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | 0 | 入力となる Relational operator |
    |RELATIONAL| | | | 入力となる Relational operator |
    |SCALAR | Key | Yes | * | scalar_aggregate=true の時には存在しない。集約に使うキーを示す。|
    |SCALAR | Agg| Yes | * |Aggregate 対象の値を示す。|

    @@ -201,7 +201,7 @@ DML である `INSERT`, `UPDATE`, `DELETE` を処理する。サブツリーか

    |kind | type | variable | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | 0 | 入力となる Relational operator |
    |RELATIONAL| | | | 入力となる Relational operator |

    #### BloomFilterBuild

    @@ -222,7 +222,7 @@ Bloom Filter を構築する。通常 Hash Join の Build 側に現れる。後

    |kind | type | variable | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | 0 | 入力側の Relation operator |
    |RELATIONAL| | | | 入力側の Relation operator |
    |SCALAR | | variable | * | 新しく計算する値を示す Scalar operator |

    #### [Compute Struct](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#compute_struct)
    @@ -233,7 +233,7 @@ Bloom Filter を構築する。通常 Hash Join の Build 側に現れる。後

    |kind | type | variable | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | 0 | 入力側の Relation operator |
    |RELATIONAL| | | | 入力側の Relation operator |
    |SCALAR | | variable | * | STRUCT の各フィールドを表す Scalar operator |

    #### [Create Batch](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#create_batch)
    @@ -244,7 +244,7 @@ Bloom Filter を構築する。通常 Hash Join の Build 側に現れる。後

    |kind | type | variable | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | 0 | 入力側の Relation operator |
    |RELATIONAL| | | | 入力側の Relation operator |
    |SCALAR | | variable | | batch の名前を指定する |

    #### [Filter](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#filter)
    @@ -254,7 +254,7 @@ Bloom Filter を構築する。通常 Hash Join の Build 側に現れる。後
    ##### ChildLinks
    |kind | type | variable | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | 0 | フィルタの入力となる Scan |
    |RELATIONAL| | | | フィルタの入力となる Scan |
    |SCALAR | Condition | | 0 | 入力からフィルタする Function |

    #### [FilterScan](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#filter_scan)
    @@ -265,7 +265,7 @@ Scan のすぐ上に位置し、スキャンに伴うフィルタを行う。Sca
    ##### ChildLinks
    |kind | type | variable | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | 0 | フィルタの入力となる Scan |
    |RELATIONAL| | | | フィルタの入力となる Scan |
    |SCALAR | Seek Condition | | 0 | スキャン対象のキー範囲を絞るシークに使う Function であり、 [アクセス述語](https://use-the-index-luke.com/ja/sql/where-clause/searching-for-ranges/greater-less-between-tuning-sql-access-filter-predicates)に対応する。|
    |SCALAR | Residual Condition | | 0 | スキャン後のフィルタに使う Function であり、[フィルタ述語](https://use-the-index-luke.com/ja/sql/where-clause/searching-for-ranges/greater-less-between-tuning-sql-access-filter-predicates)に対応する。 |

    @@ -283,7 +283,7 @@ Limit のみを行う。 `ORDER BY` を指定しないか、キー順と一致

    |kind | type | variable | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | 0 | ソート対象の入力となる Relation operator。 |
    |RELATIONAL| | | | ソート対象の入力となる Relation operator。 |
    |SCALAR | Limit | | 0 | 取得する行数を指定する Scalar operator |

    #### MiniBatchAssign
    @@ -295,8 +295,8 @@ MiniBatchAssign より下にある以外はよく分かっていない。

    |kind | type | variable? | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | 0 | 入力となる Relation operator。 |
    |SCALAR | | | 1 | Scalar operator。バッチサイズを指示している? |
    |RELATIONAL| | | | 入力となる Relation operator。 |
    |SCALAR | | | | Scalar operator。バッチサイズを指示している? |

    #### MiniBatchKeyOrder

    @@ -308,7 +308,7 @@ MiniBatchAssign より上にある以外はよく分かっていない。

    |kind | type | variable? | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | 0 | 入力となる Relation operator。 |
    |RELATIONAL| | | | 入力となる Relation operator。 |

    #### Minor Sort

    @@ -326,7 +326,7 @@ MiniBatchAssign より上にある以外はよく分かっていない。

    |kind | type | variable? | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | 0 | ソート対象の入力となる Relation operator。 |
    |RELATIONAL| | | | ソート対象の入力となる Relation operator。 |
    |SCALAR | MajorKey | Yes | * | ソートキーのうち、入力でソート済な部分が順に指定される。 |
    |SCALAR | MinorKey | Yes | * | ソートキーのうち、入力でソートされていない部分が順に指定される。 |
    |SCALAR | Value | Yes | * | ソートキー以外で取り出す列が順に指定される。 |
    @@ -347,7 +347,7 @@ ORDER BY と LIMIT 両方の処理をする operator。Sort Limit とほぼ同

    |kind | type | variable? | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | 0 | ソート対象の入力となる Relation operator。 |
    |RELATIONAL| | | | ソート対象の入力となる Relation operator。 |
    |SCALAR | Limit | | 0 | 取得する行数を指定する Scalar operator |
    |SCALAR | MajorKey | Yes | * | ソートキーのうち、入力でソート済な部分が順に指定される。 |
    |SCALAR | MinorKey | Yes | * | ソートキーのうち、入力でソートされていない部分が順に指定される。 |
    @@ -365,7 +365,7 @@ ORDER BY と LIMIT 両方の処理をする operator。Sort Limit とほぼ同

    |kind | type | variable? | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | 0 | 入力となる Relational operator |
    |RELATIONAL| | | | 入力となる Relational operator |
    |SCALAR | | Yes | | description が `<random id>` となる Reference を指す variable であり、後に Filter で名前が参照される。 |

    #### RowCount
    @@ -376,7 +376,7 @@ ORDER BY と LIMIT 両方の処理をする operator。Sort Limit とほぼ同

    |kind | type | variable | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | 0 | 入力となる Relational operator |
    |RELATIONAL| | | | 入力となる Relational operator |

    #### [Serialize Result](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#serialize_result)

    @@ -386,7 +386,7 @@ ORDER BY と LIMIT 両方の処理をする operator。Sort Limit とほぼ同

    |kind | type | variable? | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | 0 | 入力となる Relation operator。 |
    |RELATIONAL| | | | 入力となる Relation operator。 |
    |SCALAR | | | * | `metadata.rowType.fields` に現れる順で対応する式を表現する Scalar operator。 |
    |SCALAR | Scalar | | * | 式で参照される Scalar Subquery と名前を結びつけるために使われる。 |

    @@ -398,7 +398,7 @@ ORDER BY と LIMIT 両方の処理をする operator。Sort Limit とほぼ同

    |kind | type | variable? | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | 0 | ソート対象の入力となる Relation operator。 |
    |RELATIONAL| | | | ソート対象の入力となる Relation operator。 |
    |SCALAR | Key | Yes | * | ソートキーとなる列が Reference で順に指定される。 |
    |SCALAR | Value | Yes | * | ソートキー以外で取り出す列が Reference で順に指定される。 |

    @@ -416,7 +416,7 @@ ORDER BY と LIMIT 両方の処理をする operator。Sort とほぼ同じだ

    |kind | type | variable? | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | 0 | ソート対象の入力となる Relation operator。 |
    |RELATIONAL| | | | ソート対象の入力となる Relation operator。 |
    |SCALAR | Limit | | 0 | 取得する行数を指定する Scalar operator |
    |SCALAR | Key | Yes | * | ソートキーが順に指定される。 |
    |SCALAR | Value | Yes | * | ソートキー以外で取り出す列が順に指定される。 |
    @@ -436,8 +436,8 @@ ORDER BY と LIMIT 両方の処理をする operator。Sort とほぼ同じだ

    |kind | type | variable? | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | 0 | 保存対象の入力となる Relation operator。 |
    |SCALAR | | | * | 一時テーブルの列となる Scalar operator |
    |RELATIONAL| | | | 保存対象の入力となる Relation operator。 |
    |SCALAR | | | | 一時テーブルの列となる Scalar operator |

    #### [Union Input](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#union_input)

    @@ -447,8 +447,8 @@ Union All operator のそれぞれの枝からの入力を揃えるための ope

    |kind | type | variable? | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | 0 | それぞれの枝の本体となる Relation operator |
    |SCALAR | `input_{n}` | | 0 | Union All operator の結果の n 列目となる式の Scalar operator |
    |RELATIONAL| | | | それぞれの枝の本体となる Relation operator |
    |SCALAR | `input_{n}` | | | Union All operator の結果の n 列目となる式の Scalar operator |

    ### Binary operators

    @@ -463,8 +463,8 @@ replica 内にローカルな Apply Join を行う。Input 側の Relational ope

    |kind | type | variable | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| (Input) | | 0 | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。|
    |RELATIONAL| Map | | 0 | Input 側の値に応じて実行される Relational operator|
    |RELATIONAL| (Input) | | | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。|
    |RELATIONAL| Map | | | Input 側の値に応じて実行される Relational operator|
    #### [Hash Join](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#hash-join)

    ハッシュ結合を行う。
    @@ -480,8 +480,8 @@ Build 側の全 row を元にハッシュマップを構築してから Probe

    |kind | type | variable | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| Build | | 0 | 構築するハッシュマップ側になる Relational operator |
    |RELATIONAL| Probe | | 0 | ハッシュマップに通す側の Relational operator |
    |RELATIONAL| Build | | | 構築するハッシュマップ側になる Relational operator |
    |RELATIONAL| Probe | | | ハッシュマップに通す側の Relational operator |
    |SCALAR | Condition | | 0 | JOIN 条件となる Function |
    |SCALAR | Build | Yes | * | Build 側からハッシュマップに含める列を指定する Scalar operator |
    |SCALAR | Probe | Yes | * | Probe 側から variable を定義する Scalar operator |
    @@ -495,8 +495,8 @@ replica 内にローカルな Outer Apply Join を行う。Input 側の Relation

    |kind | type | variable | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| (Input) | | 0 | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。|
    |RELATIONAL| Map | | 0 | Input 側の値に応じて実行される Relational operator|
    |RELATIONAL| (Input) | | | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。|
    |RELATIONAL| Map | | | Input 側の値に応じて実行される Relational operator|
    |SCALAR | | Yes | * | 結合条件を満たさなかった時に Input 側から生成する行の定義 |

    ### N-ary operators
    @@ -505,13 +505,13 @@ replica 内にローカルな Outer Apply Join を行う。Input 側の Relation

    #### [Union All](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#union_all)

    `UNION ALL` を表現する operator で、子の Union Input 全てが返す Relation を合わせて返す
    `UNION ALL` を表現する operator で、任意の数の子の Union Input が返す行を合わせて返す

    ##### ChildLinks

    |kind | type | variable? | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | * | UNION 対象を指す Union Input operator |
    |RELATIONAL| | | * | UNION 対象を指す任意個数の Union Input operator |
    |SCALAR | | Yes | * | Union All operator の結果の n 列目の名前を持ち、 `input_{n}` と対応付ける Scalar operator |

    ## Scalar operators
    @@ -530,8 +530,8 @@ replica 内にローカルな Outer Apply Join を行う。Input 側の Relation

    |kind | type | variable? | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | 0 | サブクエリとなる Relational operator で中で variable を定義する。 |
    |SCALAR | | | 1 | サブクエリの中の variable を参照する Scalar operator。サブクエリの各 row に対して配列の要素を計算するために使われる。 |
    |RELATIONAL| | | | サブクエリとなる Relational operator で中で variable を定義する。 |
    |SCALAR | | | | サブクエリの中の variable を参照する Scalar operator。サブクエリの各 row に対して配列の要素を計算するために使われる。 |

    #### [Scalar Subquery](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#unit-relation)

    @@ -541,8 +541,8 @@ replica 内にローカルな Outer Apply Join を行う。Input 側の Relation

    |kind | type | variable? | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | 0 | サブクエリとなる Relational operator で、中で variable を定義する。 |
    |SCALAR | | | 1 | サブクエリの中の variable を参照する。 |
    |RELATIONAL| | | | サブクエリとなる Relational operator で、中で variable を定義する。 |
    |SCALAR | | | | サブクエリの中の variable を参照する。 |

    ### その他の Scalar operators

  10. apstndb revised this gist Sep 8, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion UnofficialSpannerOperatorCollection.md
    Original file line number Diff line number Diff line change
    @@ -25,7 +25,7 @@

    |kind | type | variable | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL|| (Input) | | 0 | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。通常 Create Batch を持つ。|
    |RELATIONAL|(Input) | | 0 | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。通常 Create Batch を持つ。|
    |RELATIONAL| Map | | 0 | Input 側の値に応じて分散実行される Relational operator であり、通常 Batch Scan と Cross Apply を含む。|
    |SCALAR | Split Range | | 0 | 分散実行する対象の replica をキーから限定するための Function |
    |SCALAR | Batch | Yes | * | Batch |
  11. apstndb revised this gist Sep 8, 2020. 1 changed file with 161 additions and 166 deletions.
    327 changes: 161 additions & 166 deletions UnofficialSpannerOperatorCollection.md
    Original file line number Diff line number Diff line change
    @@ -23,12 +23,12 @@

    ##### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | (Input) | | 0 | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。通常 Create Batch を持つ。|
    | Map | | 0 | Input 側の値に応じて分散実行される Relational operator であり、通常 Batch Scan と Cross Apply を含む。|
    | Split Range | | 0 | 分散実行する対象の replica をキーから限定するための Function |
    | Batch | Yes | * | Batch |
    |kind | type | variable | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL|| (Input) | | 0 | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。通常 Create Batch を持つ。|
    |RELATIONAL| Map | | 0 | Input 側の値に応じて分散実行される Relational operator であり、通常 Batch Scan と Cross Apply を含む。|
    |SCALAR | Split Range | | 0 | 分散実行する対象の replica をキーから限定するための Function |
    |SCALAR | Batch | Yes | * | Batch |

    #### [Distributed Cross Apply](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#distributed-cross-apply)

    @@ -42,11 +42,11 @@

    ##### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | (Input) | | 0 | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。通常 Create Batch を持つ。|
    | Map | | 0 | Input 側の値に応じて分散実行される Relational operator であり、通常 Batch Scan と Cross Apply を含む。|
    | Split Range | | 0 | 分散実行する対象の replica をキーから限定するための Function |
    |kind | type | variable | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| (Input) | | 0 | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。通常 Create Batch を持つ。|
    |RELATIONAL| Map | | 0 | Input 側の値に応じて分散実行される Relational operator であり、通常 Batch Scan と Cross Apply を含む。|
    |SCALAR | Split Range | | 0 | 分散実行する対象の replica をキーから限定するための Function |

    #### [Distributed Outer Apply](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#distributed-outer-apply)

    @@ -60,12 +60,12 @@

    ##### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | (Input) | | 0 | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。通常 Create Batch を持つ。|
    | Map | | 0 | Input 側の値に応じて分散実行される Relational operator であり、通常 Batch Scan と Cross Apply を含む。|
    | Split Range | | 0 | 分散実行する対象の replica をキーから限定するための Function |
    | Batch | Yes | * | 結合条件を満たさなかった時に Input 側の Batch から生成する行の定義 |
    |kind | type | variable | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| (Input) | | 0 | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。通常 Create Batch を持つ。|
    |RELATIONAL| Map | | 0 | Input 側の値に応じて分散実行される Relational operator であり、通常 Batch Scan と Cross Apply を含む。|
    |SCALAR | Split Range | | 0 | 分散実行する対象の replica をキーから限定するための Function |
    |SCALAR | Batch | Yes | * | 結合条件を満たさなかった時に Input 側の Batch から生成する行の定義 |


    #### Distributed Semi Apply
    @@ -81,12 +81,12 @@

    ##### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | (Input) | | 0 | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。通常 Create Batch を持つ。|
    | Map | | 0 | Input 側の値に応じて分散実行される Relational operator であり、通常 Batch Scan と Cross Apply を含む。|
    | Split Range | | 0 | 分散実行する対象の replica をキーから限定するための Function |
    | Batch | Yes | * | Batch |
    |kind | type | variable | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| (Input) | | 0 | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。通常 Create Batch を持つ。|
    |RELATIONAL| Map | | 0 | Input 側の値に応じて分散実行される Relational operator であり、通常 Batch Scan と Cross Apply を含む。|
    |SCALAR | Split Range | | 0 | 分散実行する対象の replica をキーから限定するための Function |
    |SCALAR | Batch | Yes | * | Batch |

    #### [Distributed Union](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#distributed-cross-apply)

    @@ -102,10 +102,10 @@

    ##### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | | | 0 | 入力として分散実行される Relation operator |
    | Split Range | | 0 | 分散実行する対象の replica をキーから限定するための Function |
    |kind | type | variable | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | 0 | 入力として分散実行される Relation operator |
    |SCALAR | Split Range | | 0 | 分散実行する対象の replica をキーから限定するための Function |

    ### Leaf operators

    @@ -117,20 +117,20 @@ Relational operator の子を持たない Relational operator 群。

    ##### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | | Yes | 0 | 配列の値に対応する変数名を指示する Scalar operator |
    | | Yes | 1 | 配列の添字に対応する変数名を指示する Scalar operator |
    |kind | type | variable | position | description |
    |----------|-----|--------|---|-------------|
    |SCALAR | | Yes | 0 | 配列の値に対応する変数名を指示する Scalar operator |
    |SCALAR | | Yes | 1 | 配列の添字に対応する変数名を指示する Scalar operator |

    #### [Empty Relation](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#empty-relation)

    空の Relation を生成する。`LIMIT 0` を指定した際には常に結果は 0 行で何も Scan 等の入力をする必要がないが、 Relation operator ではある必要があるので使われる。

    ##### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | | | 0 | 0 を意味する Constant |
    |kind | type | variable | position | description |
    |----------|-----|--------|---|-------------|
    |SCALAR | | | 0 | 0 を意味する Constant |

    #### [Scan](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#scan)

    @@ -146,9 +146,9 @@ Relational operator の子を持たない Relational operator 群。

    ##### ChildLinks

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | Yes | * | スキャン対象の列を表現する Reference operator。 |
    |kind | type | variable? | position | description |
    |----------|-----|--------|---|-------------|
    |SCALAR | | Yes | * | スキャン対象の列を表現する Reference operator。 |

    #### [Unit Relation](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#unit-relation)

    @@ -157,9 +157,9 @@ Relational operator の子を持たない Relational operator 群。

    ##### Child Links

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | | 0 | `1` を表現する Constant が常に指定される。|
    |kind | type | variable? | position | description |
    |----------|-----|--------|---|-------------|
    |SCALAR | | | 0 | `1` を表現する Constant が常に指定される。|

    ### Unary operators

    @@ -180,11 +180,11 @@ Relational operator の子を1つだけ持つ Relational operator 群。

    ##### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | | | 0 | 入力となる Relational operator |
    | Key | Yes | * | scalar_aggregate=true の時には存在しない。集約に使うキーを示す。|
    | Agg| Yes | * |Aggregate 対象の値を示す。|
    |kind | type | variable | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | 0 | 入力となる Relational operator |
    |SCALAR | Key | Yes | * | scalar_aggregate=true の時には存在しない。集約に使うキーを示す。|
    |SCALAR | Agg| Yes | * |Aggregate 対象の値を示す。|

    #### [Apply Mutations](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#aggregate)

    @@ -199,10 +199,9 @@ DML である `INSERT`, `UPDATE`, `DELETE` を処理する。サブツリーか

    ##### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | | | 0 | 入力となる Relational operator |

    |kind | type | variable | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | 0 | 入力となる Relational operator |

    #### BloomFilterBuild

    @@ -211,64 +210,64 @@ Bloom Filter を構築する。通常 Hash Join の Build 側に現れる。後

    ##### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | | | |入力側の Relational operator |
    |kind | type | variable | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | |入力側の Relational operator |

    #### [Compute](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#compute_struct)

    入力のそれぞれの行に対して新しい列を追加する。

    ##### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | | | 0 | 入力側の Relation operator |
    | | variable | * | 新しく計算する値を示す Scalar operator |
    |kind | type | variable | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | 0 | 入力側の Relation operator |
    |SCALAR | | variable | * | 新しく計算する値を示す Scalar operator |

    #### [Compute Struct](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#compute_struct)

    入力のそれぞれの行に対して STRUCT を生成する。 Compute Batch の入力や `AS STRUCT` を使ったサブクエリなどで現れる。

    ##### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | | | 0 | 入力側の Relation operator |
    | | variable | * | STRUCT の各フィールドを表す Scalar operator |
    |kind | type | variable | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | 0 | 入力側の Relation operator |
    |SCALAR | | variable | * | STRUCT の各フィールドを表す Scalar operator |

    #### [Create Batch](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#create_batch)

    入力から batch を作成する。主に Distributed Cross Apply で入力をまとめて対応する replica に送り、 Batch Scan で参照するために使われる。

    ##### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | | | 0 | 入力側の Relation operator |
    | | variable | | batch の名前を指定する |
    |kind | type | variable | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | 0 | 入力側の Relation operator |
    |SCALAR | | variable | | batch の名前を指定する |

    #### [Filter](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#filter)

    スキャンとは独立して任意のタイミングで行をフィルタする。

    ##### ChildLinks
    | type | variable | position | description |
    |-----|--------|---|-------------|
    | | | 0 | フィルタの入力となる Scan |
    | Condition | | 0 | 入力からフィルタする Function |
    |kind | type | variable | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | 0 | フィルタの入力となる Scan |
    |SCALAR | Condition | | 0 | 入力からフィルタする Function |

    #### [FilterScan](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#filter_scan)

    Scan のすぐ上に位置し、スキャンに伴うフィルタを行う。Scan の一部として働くため `executionStats` を持たず、実行時の挙動は Scan 側の `rows`, `filtered_rows` などを通して確認できる。

    ##### ChildLinks
    | type | variable | position | description |
    |-----|--------|---|-------------|
    | | | 0 | フィルタの入力となる Scan |
    | Seek Condition | | 0 | スキャン対象のキー範囲を絞るシークに使う Function であり、 [アクセス述語](https://use-the-index-luke.com/ja/sql/where-clause/searching-for-ranges/greater-less-between-tuning-sql-access-filter-predicates)に対応する。|
    | Residual Condition | | 0 | スキャン後のフィルタに使う Function であり、[フィルタ述語](https://use-the-index-luke.com/ja/sql/where-clause/searching-for-ranges/greater-less-between-tuning-sql-access-filter-predicates)に対応する。 |
    |kind | type | variable | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | 0 | フィルタの入力となる Scan |
    |SCALAR | Seek Condition | | 0 | スキャン対象のキー範囲を絞るシークに使う Function であり、 [アクセス述語](https://use-the-index-luke.com/ja/sql/where-clause/searching-for-ranges/greater-less-between-tuning-sql-access-filter-predicates)に対応する。|
    |SCALAR | Residual Condition | | 0 | スキャン後のフィルタに使う Function であり、[フィルタ述語](https://use-the-index-luke.com/ja/sql/where-clause/searching-for-ranges/greater-less-between-tuning-sql-access-filter-predicates)に対応する。 |

    #### [Limit](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#limit)

    @@ -282,10 +281,10 @@ Limit のみを行う。 `ORDER BY` を指定しないか、キー順と一致

    ##### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | | | 0 | ソート対象の入力となる Relation operator。 |
    | Limit | | 0 | 取得する行数を指定する Scalar operator |
    |kind | type | variable | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | 0 | ソート対象の入力となる Relation operator。 |
    |SCALAR | Limit | | 0 | 取得する行数を指定する Scalar operator |

    #### MiniBatchAssign

    @@ -294,10 +293,10 @@ MiniBatchAssign より下にある以外はよく分かっていない。

    ##### ChildLinks

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | | 0 | 入力となる Relation operator。 |
    | | | 1 | Scalar operator。バッチサイズを指示している? |
    |kind | type | variable? | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | 0 | 入力となる Relation operator。 |
    |SCALAR | | | 1 | Scalar operator。バッチサイズを指示している? |

    #### MiniBatchKeyOrder

    @@ -307,9 +306,9 @@ MiniBatchAssign より上にある以外はよく分かっていない。

    ##### ChildLinks

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | | 0 | 入力となる Relation operator。 |
    |kind | type | variable? | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | 0 | 入力となる Relation operator。 |

    #### Minor Sort

    @@ -325,12 +324,12 @@ MiniBatchAssign より上にある以外はよく分かっていない。

    ##### ChildLinks

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | | 0 | ソート対象の入力となる Relation operator。 |
    | MajorKey | Yes | * | ソートキーのうち、入力でソート済な部分が順に指定される。 |
    | MinorKey | Yes | * | ソートキーのうち、入力でソートされていない部分が順に指定される。 |
    | Value | Yes | * | ソートキー以外で取り出す列が順に指定される。 |
    |kind | type | variable? | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | 0 | ソート対象の入力となる Relation operator。 |
    |SCALAR | MajorKey | Yes | * | ソートキーのうち、入力でソート済な部分が順に指定される。 |
    |SCALAR | MinorKey | Yes | * | ソートキーのうち、入力でソートされていない部分が順に指定される。 |
    |SCALAR | Value | Yes | * | ソートキー以外で取り出す列が順に指定される。 |

    #### Minor Sort Limit

    @@ -346,13 +345,13 @@ ORDER BY と LIMIT 両方の処理をする operator。Sort Limit とほぼ同

    ##### ChildLinks

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | | 0 | ソート対象の入力となる Relation operator。 |
    | Limit | | 0 | 取得する行数を指定する Scalar operator |
    | MajorKey | Yes | * | ソートキーのうち、入力でソート済な部分が順に指定される。 |
    | MinorKey | Yes | * | ソートキーのうち、入力でソートされていない部分が順に指定される。 |
    | Value | Yes | * | ソートキー以外で取り出す列が順に指定される。 |
    |kind | type | variable? | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | 0 | ソート対象の入力となる Relation operator。 |
    |SCALAR | Limit | | 0 | 取得する行数を指定する Scalar operator |
    |SCALAR | MajorKey | Yes | * | ソートキーのうち、入力でソート済な部分が順に指定される。 |
    |SCALAR | MinorKey | Yes | * | ソートキーのうち、入力でソートされていない部分が順に指定される。 |
    |SCALAR | Value | Yes | * | ソートキー以外で取り出す列が順に指定される。 |


    #### Random Id Assign
    @@ -364,45 +363,44 @@ ORDER BY と LIMIT 両方の処理をする operator。Sort Limit とほぼ同

    ##### ChildLinks

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | | 0 | 入力となる Relational operator |
    | | Yes | | description が `<random id>` となる Reference を指す variable であり、後に Filter で名前が参照される。 |
    |kind | type | variable? | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | 0 | 入力となる Relational operator |
    |SCALAR | | Yes | | description が `<random id>` となる Reference を指す variable であり、後に Filter で名前が参照される。 |

    #### RowCount

    (Undocumented)

    ##### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | | | 0 | 入力となる Relational operator |

    |kind | type | variable | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | 0 | 入力となる Relational operator |

    #### [Serialize Result](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#serialize_result)

    最終的に ResultSet に含まれる値を組み立てる。これよりも上の operator で row の値を操作することはない。

    ##### ChildLinks

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | | 0 | 入力となる Relation operator。 |
    | | | * | `metadata.rowType.fields` に現れる順で対応する式を表現する Scalar operator。 |
    | Scalar | | * | 式で参照される Scalar Subquery と名前を結びつけるために使われる。 |
    |kind | type | variable? | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | 0 | 入力となる Relation operator。 |
    |SCALAR | | | * | `metadata.rowType.fields` に現れる順で対応する式を表現する Scalar operator。 |
    |SCALAR | Scalar | | * | 式で参照される Scalar Subquery と名前を結びつけるために使われる。 |

    #### [Sort](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#sort)

    `ORDER BY` によるソートのみをする operator。Sort Limit とほぼ同じだが、 `LIMIT` を設定しない場合はこちらになる。

    ##### ChildLinks

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | | 0 | ソート対象の入力となる Relation operator。 |
    | Key | Yes | * | ソートキーとなる列が Reference で順に指定される。 |
    | Value | Yes | * | ソートキー以外で取り出す列が Reference で順に指定される。 |
    |kind | type | variable? | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | 0 | ソート対象の入力となる Relation operator。 |
    |SCALAR | Key | Yes | * | ソートキーとなる列が Reference で順に指定される。 |
    |SCALAR | Value | Yes | * | ソートキー以外で取り出す列が Reference で順に指定される。 |

    #### [Sort Limit](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#sort)

    @@ -416,12 +414,12 @@ ORDER BY と LIMIT 両方の処理をする operator。Sort とほぼ同じだ

    ##### ChildLinks

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | | 0 | ソート対象の入力となる Relation operator。 |
    | Limit | | 0 | 取得する行数を指定する Scalar operator |
    | Key | Yes | * | ソートキーが順に指定される。 |
    | Value | Yes | * | ソートキー以外で取り出す列が順に指定される。 |
    |kind | type | variable? | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | 0 | ソート対象の入力となる Relation operator。 |
    |SCALAR | Limit | | 0 | 取得する行数を指定する Scalar operator |
    |SCALAR | Key | Yes | * | ソートキーが順に指定される。 |
    |SCALAR | Value | Yes | * | ソートキー以外で取り出す列が順に指定される。 |

    #### SpoolBuild

    @@ -436,21 +434,21 @@ ORDER BY と LIMIT 両方の処理をする operator。Sort とほぼ同じだ

    ##### ChildLinks

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | | 0 | 保存対象の入力となる Relation operator。 |
    | | | * | 一時テーブルの列となる Scalar operator |
    |kind | type | variable? | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | 0 | 保存対象の入力となる Relation operator。 |
    |SCALAR | | | * | 一時テーブルの列となる Scalar operator |

    #### [Union Input](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#union_input)

    Union All operator のそれぞれの枝からの入力を揃えるための operator。

    ##### ChildLinks

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | | 0 | それぞれの枝の本体となる Relation operator |
    | `input_{n}` | | 0 | Union All operator の結果の n 列目となる式の Scalar operator |
    |kind | type | variable? | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | 0 | それぞれの枝の本体となる Relation operator |
    |SCALAR | `input_{n}` | | 0 | Union All operator の結果の n 列目となる式の Scalar operator |

    ### Binary operators

    @@ -463,11 +461,10 @@ replica 内にローカルな Apply Join を行う。Input 側の Relational ope

    ##### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | (Input) | | 0 | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。|
    | Map | | 0 | Input 側の値に応じて実行される Relational operator|

    |kind | type | variable | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| (Input) | | 0 | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。|
    |RELATIONAL| Map | | 0 | Input 側の値に応じて実行される Relational operator|
    #### [Hash Join](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#hash-join)

    ハッシュ結合を行う。
    @@ -481,13 +478,13 @@ Build 側の全 row を元にハッシュマップを構築してから Probe

    ##### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | Build | | 0 | 構築するハッシュマップ側になる Relational operator |
    | Probe | | 0 | ハッシュマップに通す側の Relational operator |
    | Condition | | 0 | JOIN 条件となる Function |
    | Build | Yes | * | Build 側からハッシュマップに含める列を指定する Scalar operator |
    | Probe | Yes | * | Probe 側から variable を定義する Scalar operator |
    |kind | type | variable | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| Build | | 0 | 構築するハッシュマップ側になる Relational operator |
    |RELATIONAL| Probe | | 0 | ハッシュマップに通す側の Relational operator |
    |SCALAR | Condition | | 0 | JOIN 条件となる Function |
    |SCALAR | Build | Yes | * | Build 側からハッシュマップに含める列を指定する Scalar operator |
    |SCALAR | Probe | Yes | * | Probe 側から variable を定義する Scalar operator |

    #### [Outer Apply](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#outer-apply)

    @@ -496,11 +493,11 @@ replica 内にローカルな Outer Apply Join を行う。Input 側の Relation

    ##### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | (Input) | | 0 | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。|
    | Map | | 0 | Input 側の値に応じて実行される Relational operator|
    | | Yes | * | 結合条件を満たさなかった時に Input 側から生成する行の定義 |
    |kind | type | variable | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| (Input) | | 0 | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。|
    |RELATIONAL| Map | | 0 | Input 側の値に応じて実行される Relational operator|
    |SCALAR | | Yes | * | 結合条件を満たさなかった時に Input 側から生成する行の定義 |

    ### N-ary operators

    @@ -512,11 +509,10 @@ replica 内にローカルな Outer Apply Join を行う。Input 側の Relation

    ##### ChildLinks

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | | * | UNION 対象を指す Union Input operator |
    | | Yes | * | Union All operator の結果の n 列目の名前を持ち、 `input_{n}` と対応付ける Scalar operator |

    |kind | type | variable? | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | * | UNION 対象を指す Union Input operator |
    |SCALAR | | Yes | * | Union All operator の結果の n 列目の名前を持ち、 `input_{n}` と対応付ける Scalar operator |

    ## Scalar operators

    @@ -532,21 +528,21 @@ replica 内にローカルな Outer Apply Join を行う。Input 側の Relation

    ##### Child Links

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | | 0 | サブクエリとなる Relational operator で中で variable を定義する。 |
    | | | 1 | サブクエリの中の variable を参照する Scalar operator。サブクエリの各 row に対して配列の要素を計算するために使われる。 |
    |kind | type | variable? | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | 0 | サブクエリとなる Relational operator で中で variable を定義する。 |
    |SCALAR | | | 1 | サブクエリの中の variable を参照する Scalar operator。サブクエリの各 row に対して配列の要素を計算するために使われる。 |

    #### [Scalar Subquery](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#unit-relation)

    子のサブクエリと式からスカラ値を計算する。

    ##### Child Links

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | | 0 | サブクエリとなる Relational operator で、中で variable を定義する。 |
    | | | 1 | サブクエリの中の variable を参照する。 |
    |kind | type | variable? | position | description |
    |----------|-----|--------|---|-------------|
    |RELATIONAL| | | 0 | サブクエリとなる Relational operator で、中で variable を定義する。 |
    |SCALAR | | | 1 | サブクエリの中の variable を参照する。 |

    ### その他の Scalar operators

    @@ -560,10 +556,9 @@ replica 内にローカルな Outer Apply Join を行う。Input 側の Relation

    ##### Child Links

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | | * | 配列の各値を表現する Scalar operator を指す。 |

    |kind | type | variable? | position | description |
    |----------|-----|--------|---|-------------|
    |SCALAR | | | * | 配列の各値を表現する Scalar operator を指す。 |

    #### Constant

    @@ -577,9 +572,9 @@ replica 内にローカルな Outer Apply Join を行う。Input 側の Relation

    ##### Child Links

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | | * | 各オペランド |
    |kind | type | variable? | position | description |
    |----------|-----|--------|---|-------------|
    |SCALAR | | | * | 各オペランド |

    #### Parameter

  12. apstndb revised this gist Sep 8, 2020. 1 changed file with 20 additions and 18 deletions.
    38 changes: 20 additions & 18 deletions UnofficialSpannerOperatorCollection.md
    Original file line number Diff line number Diff line change
    @@ -165,43 +165,44 @@ Relational operator の子を持たない Relational operator 群。

    Relational operator の子を1つだけ持つ Relational operator 群。

    #### [Apply Mutations](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#aggregate)
    #### [Aggregate](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#aggregate)

    DML である `INSERT`, `UPDATE`, `DELETE` を処理する。サブツリーから row として取得した主キーと更新後の値を適用すると考えられるが、どの列をどのような式で更新するかのような定義は実行計画上は見えない。
    `GROUP BY` に対応する集約を行う。
    入力がインデックス等で既にソート済であり、その順序で集約することでハッシュテーブルを使わなくて良い時は `call_type` が Stream となり Stream Aggregate と呼ばれる。

    ##### Metadata

    | key | values | description |
    |-----|--------|-------------|
    | operator_type | INSERT, UPDATE, DELETE | |
    | table | | 更新対称のテーブル |
    | call_type | Local もしくは Global | |
    | iterator_type| Stream か未指定 | Stream か Hash による処理方法の区別を示す。|
    | scalar_aggregate| true か未指定 | |

    ##### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | | | 0 | 入力となる Relational operator |
    | Key | Yes | * | scalar_aggregate=true の時には存在しない。集約に使うキーを示す。|
    | Agg| Yes | * |Aggregate 対象の値を示す。|

    #### [Aggregate](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#aggregate)
    #### [Apply Mutations](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#aggregate)

    `GROUP BY` に対応する集約を行う。
    入力がインデックス等で既にソート済であり、その順序で集約することでハッシュテーブルを使わなくて良い時は `call_type` が Stream となり Stream Aggregate と呼ばれる。
    DML である `INSERT`, `UPDATE`, `DELETE` を処理する。サブツリーから row として取得した主キーと更新後の値を適用すると考えられるが、どの列をどのような式で更新するかのような定義は実行計画上は見えない。

    ##### Metadata

    | key | values | description |
    |-----|--------|-------------|
    | call_type | Local もしくは Global | |
    | iterator_type| Stream か未指定 | Stream か Hash による処理方法の区別を示す。|
    | scalar_aggregate| true か未指定 | |
    | operator_type | INSERT, UPDATE, DELETE | |
    | table | | 更新対称のテーブル |

    ##### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | | | 0 | 入力となる Relational operator |
    | Key | Yes | * | scalar_aggregate=true の時には存在しない。集約に使うキーを示す。|
    | Agg| Yes | * |Aggregate 対象の値を示す。|


    #### BloomFilterBuild

    @@ -213,27 +214,28 @@ Bloom Filter を構築する。通常 Hash Join の Build 側に現れる。後
    | type | variable | position | description |
    |-----|--------|---|-------------|
    | | | |入力側の Relational operator |
    #### [Compute Struct](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#compute_struct)

    入力のそれぞれの行に対して STRUCT を生成する。 Compute Batch の入力や `AS STRUCT` を使ったサブクエリなどで現れる。
    #### [Compute](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#compute_struct)

    入力のそれぞれの行に対して新しい列を追加する。

    ##### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | | | 0 | 入力側の Relation operator |
    | | variable | * | STRUCT の各フィールドを表す Scalar operator |
    | | variable | * | 新しく計算する値を示す Scalar operator |

    #### [Compute](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#compute_struct)
    #### [Compute Struct](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#compute_struct)

    入力のそれぞれの行に対して新しい列を追加する
    入力のそれぞれの行に対して STRUCT を生成する。 Compute Batch の入力や `AS STRUCT` を使ったサブクエリなどで現れる

    ##### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | | | 0 | 入力側の Relation operator |
    | | variable | * | 新しく計算する値を示す Scalar operator |
    | | variable | * | STRUCT の各フィールドを表す Scalar operator |

    #### [Create Batch](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#create_batch)

  13. apstndb revised this gist Sep 8, 2020. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions UnofficialSpannerOperatorCollection.md
    Original file line number Diff line number Diff line change
    @@ -518,6 +518,8 @@ replica 内にローカルな Outer Apply Join を行う。Input 側の Relation

    ## Scalar operators

    `kind: SCALAR` なもので、 `ARRAY` を含む値として評価されるサブクエリや式などを含む operator である。

    ### Subqueries

    サブクエリは1つの Relational operator を子に持ち、 ARRAY やスカラに変換する Scalar operator として処理される。[Scalar subqueries](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#scalar_subqueries) で説明されているように最適化の結果 Cross Apply などで実現されることもある。
  14. apstndb revised this gist Sep 8, 2020. 1 changed file with 268 additions and 229 deletions.
    497 changes: 268 additions & 229 deletions UnofficialSpannerOperatorCollection.md
    Original file line number Diff line number Diff line change
    @@ -1,312 +1,327 @@
    # Unofficial Cloud Spanner operator collection

    [Query execution operators](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en) にはドキュメンテーションされていない operator もあり、 metadata やそれぞれの child links についても解説されているわけではないためここにまとめる。

    ## Relational operators

    ### [Apply Mutations](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#aggregate)
    `kind: RELATIONAL` なもので、行のストリームを返す operator である。

    DML である `INSERT`, `UPDATE`, `DELETE` を処理する。サブツリーから row として取得した主キーと更新後の値を適用すると考えられるが、どの列をどのような式で更新するかのような定義は実行計画上は見えない。
    ### [Distributed operators](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#distributed_operators)

    分散実行される operator 群であり、 `subquery_cluster_node` が指す方の子の Relational operator からなる実行計画のサブツリーを `Split Range` の条件を満たす remote server で実行するとで、 server を跨ぐ replica から結果を得るという共通点がある。

    #### Distributed Anti Semi Apply

    #### Metadata
    (Undocumented)
    `NOT EXISTS` などを処理するために分散 Anti Semi Join を行う。Distributed Cross Apply と似た構造を持つ。

    ##### Metadata

    | key | values | description |
    |-----|--------|-------------|
    | operator_type | INSERT, UPDATE, DELETE | |
    | table | | 更新対称のテーブル |
    | subquery_cluster_node | | 分散実行する対象の Relation operator の ID |

    #### ChildLinks
    ##### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | | | 0 | 入力となる Relational operator |
    | (Input) | | 0 | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。通常 Create Batch を持つ。|
    | Map | | 0 | Input 側の値に応じて分散実行される Relational operator であり、通常 Batch Scan と Cross Apply を含む。|
    | Split Range | | 0 | 分散実行する対象の replica をキーから限定するための Function |
    | Batch | Yes | * | Batch |

    ### [Aggregate](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#aggregate)
    #### [Distributed Cross Apply](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#distributed-cross-apply)

    `GROUP BY` に対応する集約を行う。
    入力がインデックス等で既にソート済であり、その順序で集約することでハッシュテーブルを使わなくて良い時は `call_type` が Stream となり Stream Aggregate と呼ばれる。
    分散 Apply Join を行う。Input 側の Relational operator から取り出した値を使って、対応する Map 側の Relational operator を適切な replica で実行することで分散 JOIN を実現する。

    #### Metadata
    ##### Metadata

    | key | values | description |
    |-----|--------|-------------|
    | call_type | Local もしくは Global | |
    | iterator_type| Stream か未指定 | Stream か Hash による処理方法の区別を示す。|
    | scalar_aggregate| true か未指定 | |
    | subquery_cluster_node | | 分散実行する対象の Relation operator の ID |

    #### ChildLinks
    ##### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | Key | Yes | * | scalar_aggregate=true の時には存在しない。集約に使うキーを示す。|
    | Agg| Yes | * |Aggregate 対象の値を示す。|
    | (Input) | | 0 | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。通常 Create Batch を持つ。|
    | Map | | 0 | Input 側の値に応じて分散実行される Relational operator であり、通常 Batch Scan と Cross Apply を含む。|
    | Split Range | | 0 | 分散実行する対象の replica をキーから限定するための Function |

    ### [Array Unnest](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#array-unnest)
    #### [Distributed Outer Apply](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#distributed-outer-apply)

    配列の値と添字を元に Relation を作り出す operator
    `LEFT OUTER JOIN` などを処理するために分散 OUTER JOIN を行う。Distributed Cross Apply と似た構造を持つ

    #### ChildLinks
    ##### Metadata

    | key | values | description |
    |-----|--------|-------------|
    | subquery_cluster_node | | 分散実行する対象の Relation operator の ID |

    ##### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | | Yes | 0 | 配列の値に対応する変数名を指示する Scalar operator |
    | | Yes | 1 | 配列の添字に対応する変数名を指示する Scalar operator |
    | (Input) | | 0 | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。通常 Create Batch を持つ。|
    | Map | | 0 | Input 側の値に応じて分散実行される Relational operator であり、通常 Batch Scan と Cross Apply を含む。|
    | Split Range | | 0 | 分散実行する対象の replica をキーから限定するための Function |
    | Batch | Yes | * | 結合条件を満たさなかった時に Input 側の Batch から生成する行の定義 |


    ### BloomFilterBuild
    #### Distributed Semi Apply

    (Undocumented)
    Bloom Filter を構築する。通常 Hash Join の Build 側に現れる。後に `BLOOM_FILTER_MATCH` を Condition に持つ Filter で使われる
    `EXISTS` などを処理するために分散 Semi Join を行う。Distributed Cross Apply と似た構造を持つ

    #### ChildLinks
    ##### Metadata

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | | | |入力側の Relational operator |
    ### [Compute Struct](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#compute_struct)

    入力のそれぞれの行に対して STRUCT を生成する。 Compute Batch の入力や `AS STRUCT` を使ったサブクエリなどで現れる。
    | key | values | description |
    |-----|--------|-------------|
    | subquery_cluster_node | | 分散実行する対象の Relation operator の ID |

    #### ChildLinks
    ##### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | | | 0 | 入力側の Relation operator |
    | | variable | * | STRUCT の各フィールドを表す Scalar operator |
    | (Input) | | 0 | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。通常 Create Batch を持つ。|
    | Map | | 0 | Input 側の値に応じて分散実行される Relational operator であり、通常 Batch Scan と Cross Apply を含む。|
    | Split Range | | 0 | 分散実行する対象の replica をキーから限定するための Function |
    | Batch | Yes | * | Batch |

    ### [Compute](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#compute_struct)
    #### [Distributed Union](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#distributed-cross-apply)

    入力のそれぞれの行に対して新しい列を追加する。
    各 replica で子の Relation operator を実行し、結果をまとめる。
    クエリ対象の replica を他の server(remote server) が持つ場合、remote server を呼び出すため remote call が発生し、 `executionStats` に記録される`。
    `call_type` が Local なものは、特定の server 内の結果をまとめる。

    ##### Metadata
    | key | values | description |
    |-----|--------|-------------|
    | call_type | Local, 未指定 ||
    | subquery_cluster_node | | 分散実行する対象の Relation operator の ID |

    #### ChildLinks
    ##### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | | | 0 | 入力側の Relation operator |
    | | variable | * | 新しく計算する値を示す Scalar operator |
    | | | 0 | 入力として分散実行される Relation operator |
    | Split Range | | 0 | 分散実行する対象の replica をキーから限定するための Function |

    ### [Create Batch](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#create_batch)
    ### Leaf operators

    入力から batch を作成する。主に Distributed Cross Apply で入力をまとめて対応する replica に送り、 Batch Scan で参照するために使われる。
    Relational operator の子を持たない Relational operator 群。

    #### [Array Unnest](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#array-unnest)

    配列の値と添字を元に Relation を作り出す operator。

    #### ChildLinks
    ##### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | | | 0 | 入力側の Relation operator |
    | | variable | | batch の名前を指定する |
    | | Yes | 0 | 配列の値に対応する変数名を指示する Scalar operator |
    | | Yes | 1 | 配列の添字に対応する変数名を指示する Scalar operator |

    ### [Cross Apply](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#cross-apply)
    #### [Empty Relation](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#empty-relation)

    replica 内にローカルな Apply Join を行う。Input 側の Relational operator から取り出した値を使って、対応する Map 側の Relational operator を実行することで JOIN を実現する。
    主に Distributed Cross Apply の中で使われる場合と、 INTERLEAVE されたテーブル間の JOIN で使われる場合がある。
    空の Relation を生成する。`LIMIT 0` を指定した際には常に結果は 0 行で何も Scan 等の入力をする必要がないが、 Relation operator ではある必要があるので使われる。

    #### ChildLinks
    ##### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | (Input) | | 0 | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。|
    | Map | | 0 | Input 側の値に応じて実行される Relational operator|
    | | | 0 | 0 を意味する Constant |

    ### Distributed Anti Semi Apply
    #### [Scan](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#scan)

    (Undocumented)
    `NOT EXISTS` などを処理するために分散 Anti Semi Join を行う。Distributed Cross Apply と似た構造を持つ。
    各入力からのスキャンを行う。`PlanNode.displayName` としては Scan だが、一般的に `scan_type` の値と合わせて Index Scan, Table Scan などと表示される。

    #### Metadata
    ##### Metadata

    | key | values | description |
    |-----|--------|-------------|
    | subquery_cluster_node | | 分散実行する対象の Relation operator の ID |
    | Full scan | true もしくは未指定 ||
    | scan_target | | スキャン対象の名前を指示する。 |
    | scan_type | IndexScan, TableScan, SpoolScan, BatchScan | スキャン対象の種類を指示する。 |

    #### ChildLinks
    ##### ChildLinks

    | type | variable | position | description |
    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | (Input) | | 0 | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。通常 Create Batch を持つ。|
    | Map | | 0 | Input 側の値に応じて分散実行される Relational operator であり、通常 Batch Scan と Cross Apply を含む。|
    | Split Range | | 0 | 分散実行する対象の replica をキーから限定するための Function |
    | Batch | Yes | * | Batch |
    | | Yes | * | スキャン対象の列を表現する Reference operator。 |

    ### [Distributed Cross Apply](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#distributed-cross-apply)
    #### [Unit Relation](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#unit-relation)

    分散 Apply Join を行う。Input 側の Relational operator から取り出した値を使って、対応する Map 側の Relational operator を適切な replica で実行することで分散 JOIN を実現する。
    特に値を持たない単一の行を生成する。 Unit Relation を受ける Compute や Serialize Result で実際の列の値が設定される。
    例: `SELECT 42`, `SELECT 42 UNION ALL SELECT 43`

    ##### Child Links

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | | 0 | `1` を表現する Constant が常に指定される。|

    ### Unary operators

    Relational operator の子を1つだけ持つ Relational operator 群。

    #### [Apply Mutations](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#aggregate)

    DML である `INSERT`, `UPDATE`, `DELETE` を処理する。サブツリーから row として取得した主キーと更新後の値を適用すると考えられるが、どの列をどのような式で更新するかのような定義は実行計画上は見えない。

    #### Metadata
    ##### Metadata

    | key | values | description |
    |-----|--------|-------------|
    | subquery_cluster_node | | 分散実行する対象の Relation operator の ID |
    | operator_type | INSERT, UPDATE, DELETE | |
    | table | | 更新対称のテーブル |

    #### ChildLinks
    ##### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | (Input) | | 0 | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。通常 Create Batch を持つ。|
    | Map | | 0 | Input 側の値に応じて分散実行される Relational operator であり、通常 Batch Scan と Cross Apply を含む。|
    | Split Range | | 0 | 分散実行する対象の replica をキーから限定するための Function |
    | | | 0 | 入力となる Relational operator |

    ### [Distributed Outer Apply](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#distributed-outer-apply)
    #### [Aggregate](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#aggregate)

    `LEFT OUTER JOIN` などを処理するために分散 OUTER JOIN を行う。Distributed Cross Apply と似た構造を持つ。
    `GROUP BY` に対応する集約を行う。
    入力がインデックス等で既にソート済であり、その順序で集約することでハッシュテーブルを使わなくて良い時は `call_type` が Stream となり Stream Aggregate と呼ばれる。

    #### Metadata
    ##### Metadata

    | key | values | description |
    |-----|--------|-------------|
    | subquery_cluster_node | | 分散実行する対象の Relation operator の ID |
    | call_type | Local もしくは Global | |
    | iterator_type| Stream か未指定 | Stream か Hash による処理方法の区別を示す。|
    | scalar_aggregate| true か未指定 | |

    #### ChildLinks
    ##### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | (Input) | | 0 | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。通常 Create Batch を持つ。|
    | Map | | 0 | Input 側の値に応じて分散実行される Relational operator であり、通常 Batch Scan と Cross Apply を含む。|
    | Split Range | | 0 | 分散実行する対象の replica をキーから限定するための Function |
    | Batch | Yes | * | 結合条件を満たさなかった時に Input 側の Batch から生成する行の定義 |

    | | | 0 | 入力となる Relational operator |
    | Key | Yes | * | scalar_aggregate=true の時には存在しない。集約に使うキーを示す。|
    | Agg| Yes | * |Aggregate 対象の値を示す。|

    ### Distributed Semi Apply
    #### BloomFilterBuild

    (Undocumented)
    `EXISTS` などを処理するために分散 Semi Join を行う。Distributed Cross Apply と似た構造を持つ
    Bloom Filter を構築する。通常 Hash Join の Build 側に現れる。後に `BLOOM_FILTER_MATCH` を Condition に持つ Filter で使われる

    #### Metadata
    ##### ChildLinks

    | key | values | description |
    |-----|--------|-------------|
    | subquery_cluster_node | | 分散実行する対象の Relation operator の ID |
    | type | variable | position | description |
    |-----|--------|---|-------------|
    | | | |入力側の Relational operator |
    #### [Compute Struct](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#compute_struct)

    入力のそれぞれの行に対して STRUCT を生成する。 Compute Batch の入力や `AS STRUCT` を使ったサブクエリなどで現れる。

    #### ChildLinks
    ##### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | (Input) | | 0 | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。通常 Create Batch を持つ。|
    | Map | | 0 | Input 側の値に応じて分散実行される Relational operator であり、通常 Batch Scan と Cross Apply を含む。|
    | Split Range | | 0 | 分散実行する対象の replica をキーから限定するための Function |
    | Batch | Yes | * | Batch |

    ### [Distributed Union](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#distributed-cross-apply)
    | | | 0 | 入力側の Relation operator |
    | | variable | * | STRUCT の各フィールドを表す Scalar operator |

    各 replica で子の Relation operator を実行し、結果をまとめる。
    クエリ対象の replica を他の server(remote server) が持つ場合、remote server を呼び出すため remote call が発生し、 `executionStats` に記録される`。
    `call_type` が Local なものは、特定の server 内の結果をまとめる。
    #### [Compute](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#compute_struct)

    #### Metadata
    | key | values | description |
    |-----|--------|-------------|
    | call_type | Local, 未指定 ||
    | subquery_cluster_node | | 分散実行する対象の Relation operator の ID |
    入力のそれぞれの行に対して新しい列を追加する。

    #### ChildLinks
    ##### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | | | 0 | 入力として分散実行される Relation operator |
    | Split Range | | 0 | 分散実行する対象の replica をキーから限定するための Function |
    | | | 0 | 入力側の Relation operator |
    | | variable | * | 新しく計算する値を示す Scalar operator |

    ### [Empty Relation](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#empty-relation)
    #### [Create Batch](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#create_batch)

    空の Relation を生成する。`LIMIT 0` を指定した際には常に結果は 0 行で何も Scan 等の入力をする必要がないが、 Relation operator ではある必要があるので使われる
    入力から batch を作成する。主に Distributed Cross Apply で入力をまとめて対応する replica に送り、 Batch Scan で参照するために使われる

    #### ChildLinks
    ##### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | | | 0 | 0 を意味する Constant |
    | | | 0 | 入力側の Relation operator |
    | | variable | | batch の名前を指定する |

    ### [Filter](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#filter)
    #### [Filter](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#filter)

    スキャンとは独立して任意のタイミングで行をフィルタする。

    #### ChildLinks
    ##### ChildLinks
    | type | variable | position | description |
    |-----|--------|---|-------------|
    | | | 0 | フィルタの入力となる Scan |
    | Condition | | 0 | 入力からフィルタする Function |

    ### [FilterScan](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#filter_scan)
    #### [FilterScan](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#filter_scan)

    Scan のすぐ上に位置し、スキャンに伴うフィルタを行う。Scan の一部として働くため `executionStats` を持たず、実行時の挙動は Scan 側の `rows`, `filtered_rows` などを通して確認できる。

    #### ChildLinks
    ##### ChildLinks
    | type | variable | position | description |
    |-----|--------|---|-------------|
    | | | 0 | フィルタの入力となる Scan |
    | Seek Condition | | 0 | スキャン対象のキー範囲を絞るシークに使う Function であり、 [アクセス述語](https://use-the-index-luke.com/ja/sql/where-clause/searching-for-ranges/greater-less-between-tuning-sql-access-filter-predicates)に対応する。|
    | Residual Condition | | 0 | スキャン後のフィルタに使う Function であり、[フィルタ述語](https://use-the-index-luke.com/ja/sql/where-clause/searching-for-ranges/greater-less-between-tuning-sql-access-filter-predicates)に対応する。 |
    ### [Hash Join](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#hash-join)

    ハッシュ結合を行う。
    Build 側の全 row を元にハッシュマップを構築してから Probe 側の各 row の値を使ってハッシュマップを引くことで Condition を評価して JOIN を行う。

    #### Metadata

    | key | values | description |
    |-----|--------|-------------|
    | join_type | INNER, BUILD_OUTER, PROBE_OUTER, BUILD_SEMI, BUILD_ANTI_SEMI, ... | INNER 以外は Build と Probe がどちらかで意味が変わるので、 BUILD か PROBE が prefix になる。|

    #### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | Build | | 0 | 構築するハッシュマップ側になる Relational operator |
    | Probe | | 0 | ハッシュマップに通す側の Relational operator |
    | Condition | | 0 | JOIN 条件となる Function |
    | Build | Yes | * | Build 側からハッシュマップに含める列を指定する Scalar operator |
    | Probe | Yes | * | Probe 側から variable を定義する Scalar operator |

    ### [Limit](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#limit)
    #### [Limit](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#limit)

    Limit のみを行う。 `ORDER BY` を指定しないか、キー順と一致する順序で指定して `LIMIT` を指定した際に現れる。

    #### Metadata
    ##### Metadata

    | key | values | description |
    |-----|--------|-------------|
    | call_type | Local もしくは Global ||

    #### ChildLinks
    ##### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | | | 0 | ソート対象の入力となる Relation operator。 |
    | Limit | | 0 | 取得する行数を指定する Scalar operator |

    ### MiniBatchAssign
    #### MiniBatchAssign

    (Undocumented)
    MiniBatchAssign より下にある以外はよく分かっていない。

    #### ChildLinks
    ##### ChildLinks

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | | 0 | 入力となる Relation operator。 |
    | | | 1 | Scalar operator。バッチサイズを指示している? |

    ### MiniBatchKeyOrder
    #### MiniBatchKeyOrder

    (Undocumented)

    MiniBatchAssign より上にある以外はよく分かっていない。

    #### ChildLinks
    ##### ChildLinks

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | | 0 | 入力となる Relation operator。 |

    ### Minor Sort
    #### Minor Sort

    (Undocumented)

    ストリームの一部に対して ORDER BY の処理をする。Sort とほぼ同じだが、テーブルやインデックスとソート順の prefix が一致して全体の Sort が必要ない場合に使われる。

    #### Metadata
    ##### Metadata

    | key | values | description |
    |-----|--------|-------------|
    | call_type | Local もしくは Global ||

    #### ChildLinks
    ##### ChildLinks

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    @@ -315,19 +330,19 @@ MiniBatchAssign より上にある以外はよく分かっていない。
    | MinorKey | Yes | * | ソートキーのうち、入力でソートされていない部分が順に指定される。 |
    | Value | Yes | * | ソートキー以外で取り出す列が順に指定される。 |

    ### Minor Sort Limit
    #### Minor Sort Limit

    (Undocumented)

    ORDER BY と LIMIT 両方の処理をする operator。Sort Limit とほぼ同じだが、テーブルやインデックスとソート順の prefix が一致して全体の Sort が必要ない場合に使われる。

    #### Metadata
    ##### Metadata

    | key | values | description |
    |-----|--------|-------------|
    | call_type | Local もしくは Global ||

    #### ChildLinks
    ##### ChildLinks

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    @@ -337,96 +352,67 @@ ORDER BY と LIMIT 両方の処理をする operator。Sort Limit とほぼ同
    | MinorKey | Yes | * | ソートキーのうち、入力でソートされていない部分が順に指定される。 |
    | Value | Yes | * | ソートキー以外で取り出す列が順に指定される。 |

    ### [Outer Apply](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#outer-apply)

    replica 内にローカルな Outer Apply Join を行う。Input 側の Relational operator から取り出した値を使って、対応する Map 側の Relational operator を実行することで JOIN を実現する。
    主に Distributed Outer Apply の中で使われる場合と、 INTERLEAVE されたテーブル間の JOIN で使われる場合がある。

    #### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | (Input) | | 0 | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。|
    | Map | | 0 | Input 側の値に応じて実行される Relational operator|
    | | Yes | * | 結合条件を満たさなかった時に Input 側から生成する行の定義 |

    ### Random Id Assign
    #### Random Id Assign

    (Undocumented)

    `TABLESAMPLE` を使用した際に現れる。 Filter operator と組み合わせることで、ランダムに割り当てた値を元にフィルタすることでサンプリングを実現する。
    なお Sample について言及されている[ドキュメント](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#sample)のクエリがこの operator になるため、ドキュメントの解説が古い可能性が高い。

    #### ChildLinks
    ##### ChildLinks

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | | 0 | 入力となる Relational operator |
    | | Yes | | description が `<random id>` となる Reference を指す variable であり、後に Filter で名前が参照される。 |

    ### RowCount
    #### RowCount

    (Undocumented)

    #### ChildLinks
    ##### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | | | 0 | 入力となる Relational operator |

    ### [Scan](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#scan)

    各入力からのスキャンを行う。`PlanNode.displayName` としては Scan だが、一般的に `scan_type` の値と合わせて Index Scan, Table Scan などと表示される。

    #### Metadata

    | key | values | description |
    |-----|--------|-------------|
    | Full scan | true もしくは未指定 ||
    | scan_target | | スキャン対象の名前を指示する。 |
    | scan_type | IndexScan, TableScan, SpoolScan, BatchScan | スキャン対象の種類を指示する。 |

    #### ChildLinks

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | Yes | * | スキャン対象の列を表現する Reference operator。 |

    ### [Serialize Result](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#serialize_result)
    #### [Serialize Result](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#serialize_result)

    最終的に ResultSet に含まれる値を組み立てる。これよりも上の operator で row の値を操作することはない。

    #### ChildLinks
    ##### ChildLinks

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | | 0 | 入力となる Relation operator。 |
    | | | * | `metadata.rowType.fields` に現れる順で対応する式を表現する Scalar operator。 |
    | Scalar | | * | 式で参照される Scalar Subquery と名前を結びつけるために使われる。 |

    ### [Sort](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#sort)
    #### [Sort](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#sort)

    `ORDER BY` によるソートのみをする operator。Sort Limit とほぼ同じだが、 `LIMIT` を設定しない場合はこちらになる。

    #### ChildLinks
    ##### ChildLinks

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | | 0 | ソート対象の入力となる Relation operator。 |
    | Key | Yes | * | ソートキーとなる列が Reference で順に指定される。 |
    | Value | Yes | * | ソートキー以外で取り出す列が Reference で順に指定される。 |

    ### [Sort Limit](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#sort)
    #### [Sort Limit](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#sort)

    ORDER BY と LIMIT 両方の処理をする operator。Sort とほぼ同じだが、 `LIMIT` を使う場合はこちらになる。

    #### Metadata
    ##### Metadata

    | key | values | description |
    |-----|--------|-------------|
    | call_type | Local もしくは Global ||

    #### ChildLinks
    ##### ChildLinks

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    @@ -435,124 +421,177 @@ ORDER BY と LIMIT 両方の処理をする operator。Sort とほぼ同じだ
    | Key | Yes | * | ソートキーが順に指定される。 |
    | Value | Yes | * | ソートキー以外で取り出す列が順に指定される。 |

    ### SpoolBuild
    #### SpoolBuild

    (Undocumented)
    `WITH` などによる一時テーブルを保存する。 Spool Scan によって読み取られる。

    #### Metadata
    ##### Metadata

    | key | values | description |
    |-----|--------|-------------|
    | spool_name | | 構築する spool の名前 |

    #### ChildLinks
    ##### ChildLinks

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | | 0 | 保存対象の入力となる Relation operator。 |
    | | | * | 一時テーブルの列となる Scalar operator |
    ### [Union All](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#union_all)

    #### [Union Input](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#union_input)

    Union All operator のそれぞれの枝からの入力を揃えるための operator。

    ##### ChildLinks

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | | 0 | それぞれの枝の本体となる Relation operator |
    | `input_{n}` | | 0 | Union All operator の結果の n 列目となる式の Scalar operator |

    ### Binary operators

    Relational operator の子を2つ持つ Relational operator 群。

    #### [Cross Apply](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#cross-apply)

    replica 内にローカルな Apply Join を行う。Input 側の Relational operator から取り出した値を使って、対応する Map 側の Relational operator を実行することで JOIN を実現する。
    主に Distributed Cross Apply の中で使われる場合と、 INTERLEAVE されたテーブル間の JOIN で使われる場合がある。

    ##### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | (Input) | | 0 | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。|
    | Map | | 0 | Input 側の値に応じて実行される Relational operator|

    #### [Hash Join](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#hash-join)

    ハッシュ結合を行う。
    Build 側の全 row を元にハッシュマップを構築してから Probe 側の各 row の値を使ってハッシュマップを引くことで Condition を評価して JOIN を行う。

    ##### Metadata

    | key | values | description |
    |-----|--------|-------------|
    | join_type | INNER, BUILD_OUTER, PROBE_OUTER, BUILD_SEMI, BUILD_ANTI_SEMI, ... | INNER 以外は Build と Probe がどちらかで意味が変わるので、 BUILD か PROBE が prefix になる。|

    ##### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | Build | | 0 | 構築するハッシュマップ側になる Relational operator |
    | Probe | | 0 | ハッシュマップに通す側の Relational operator |
    | Condition | | 0 | JOIN 条件となる Function |
    | Build | Yes | * | Build 側からハッシュマップに含める列を指定する Scalar operator |
    | Probe | Yes | * | Probe 側から variable を定義する Scalar operator |

    #### [Outer Apply](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#outer-apply)

    replica 内にローカルな Outer Apply Join を行う。Input 側の Relational operator から取り出した値を使って、対応する Map 側の Relational operator を実行することで JOIN を実現する。
    主に Distributed Outer Apply の中で使われる場合と、 INTERLEAVE されたテーブル間の JOIN で使われる場合がある。

    ##### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | (Input) | | 0 | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。|
    | Map | | 0 | Input 側の値に応じて実行される Relational operator|
    | | Yes | * | 結合条件を満たさなかった時に Input 側から生成する行の定義 |

    ### N-ary operators

    任意の数の Relational operator の子を持つ Relational operator 群。`Union All` 以外確認されていない。

    #### [Union All](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#union_all)

    `UNION ALL` を表現する operator で、子の Union Input 全てが返す Relation を合わせて返す。

    #### ChildLinks
    ##### ChildLinks

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | | * | UNION 対象を指す Union Input operator |
    | | Yes | * | Union All operator の結果の n 列目の名前を持ち、 `input_{n}` と対応付ける Scalar operator |

    ### [Union Input](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#union_input)

    Union All operator のそれぞれの枝からの入力を揃えるための operator。
    ## Scalar operators

    ### Subqueries

    サブクエリは1つの Relational operator を子に持ち、 ARRAY やスカラに変換する Scalar operator として処理される。[Scalar subqueries](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#scalar_subqueries) で説明されているように最適化の結果 Cross Apply などで実現されることもある。

    #### [Array Subquery](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#array_subqueries)

    子のサブクエリと式から配列を計算する。

    #### ChildLinks
    ##### Child Links

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | | 0 | それぞれの枝の本体となる Relation operator |
    | `input_{n}` | | 0 | Union All operator の結果の n 列目となる式の Scalar operator |
    | | | 0 | サブクエリとなる Relational operator で中で variable を定義する。 |
    | | | 1 | サブクエリの中の variable を参照する Scalar operator。サブクエリの各 row に対して配列の要素を計算するために使われる。 |

    ### [Unit Relation](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#unit-relation)
    #### [Scalar Subquery](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#unit-relation)

    特に値を持たない単一の行を生成する。 Unit Relation を受ける Compute や Serialize Result で実際の列の値が設定される。
    例: `SELECT 42`, `SELECT 42 UNION ALL SELECT 43`
    子のサブクエリと式からスカラ値を計算する。

    #### Child Links
    ##### Child Links

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | | 0 | `1` を表現する Constant が常に指定される。|
    | | | 0 | サブクエリとなる Relational operator で、中で variable を定義する。 |
    | | | 1 | サブクエリの中の variable を参照する。 |

    ## Scalar operators
    ### その他の Scalar operators

    Subquery 系以外は実行計画の行としては表示されないため、ほぼドキュメンテーションされていない
    実行計画の内部表現としてはグラフ構造をなしているが、 Subquery と違って一般的にグラフとしては表示されず、ドキュメンテーションもされていない

    ### Array Constructor
    #### Array Constructor

    (Undocumented)
    配列リテラルに対応し、配列値を表現する。
    `shortRepresentation.description` は配列のリテラル表記となる。

    #### Child Links
    ##### Child Links

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | | * | 配列の各値を表現する Scalar operator を指す。 |

    ### [Array Subquery](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#array_subqueries)

    子のサブクエリと式から配列を計算する。

    #### Child Links

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | | 0 | サブクエリとなる Relational operator で中で variable を定義する。 |
    | | | 1 | サブクエリの中の variable を参照する Scalar operator。サブクエリの各 row に対して配列の要素を計算するために使われる。 |

    ### Constant
    #### Constant

    (Undocumented)
    定数を表す。`shortRepresentation.description` に値のリテラル表記や `<typed null>` などが文字列として入っている。

    ### Function
    #### Function

    (Undocumented)
    演算式と関数呼び出しを含む関数を表現する。`shortRepresentation.description` に演算子や関数名を含む式が文字列として入っている。

    #### Child Links
    ##### Child Links

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | | * | 各オペランド |

    ### Parameter
    #### Parameter

    (Undocumented)
    クエリパラメータに対応する Scalar operator であり、実行時に `Statement.params` の name metadata と一致する名前の値に置き換えられる。

    #### Metadata
    ##### Metadata

    | key | values | description |
    |-----|--------|-------------|
    | name | | パラメータ名 |
    | type | scalar, ? | |

    ### Reference
    #### Reference

    (Undocumented)
    `shortRepresentation.description` に名前を持つ参照で metadata も子も持たない。
    Sort 系の operator の Key で降順の場合は `shortRepresentation.description``$ItemId (DESC)` のように `(DESC)` が含まれる。

    ### [Scalar Subquery](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#unit-relation)

    子のサブクエリと式からスカラ値を計算する。

    #### Child Links

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | | 0 | サブクエリとなる Relational operator で、中で variable を定義する。 |
    | | | 1 | サブクエリの中の variable を参照する。 |
  15. apstndb revised this gist Sep 8, 2020. 1 changed file with 19 additions and 1 deletion.
    20 changes: 19 additions & 1 deletion UnofficialSpannerOperatorCollection.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,23 @@
    # Unofficial Cloud Spanner operator collection
    ## Relational operators

    ### [Apply Mutations](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#aggregate)

    DML である `INSERT`, `UPDATE`, `DELETE` を処理する。サブツリーから row として取得した主キーと更新後の値を適用すると考えられるが、どの列をどのような式で更新するかのような定義は実行計画上は見えない。

    #### Metadata

    | key | values | description |
    |-----|--------|-------------|
    | operator_type | INSERT, UPDATE, DELETE | |
    | table | | 更新対称のテーブル |

    #### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | | | 0 | 入力となる Relational operator |

    ### [Aggregate](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#aggregate)

    `GROUP BY` に対応する集約を行う。
    @@ -124,7 +142,7 @@ replica 内にローカルな Apply Join を行う。Input 側の Relational ope
    | Map | | 0 | Input 側の値に応じて分散実行される Relational operator であり、通常 Batch Scan と Cross Apply を含む。|
    | Split Range | | 0 | 分散実行する対象の replica をキーから限定するための Function |

    ### Distributed Outer Apply
    ### [Distributed Outer Apply](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#distributed-outer-apply)

    `LEFT OUTER JOIN` などを処理するために分散 OUTER JOIN を行う。Distributed Cross Apply と似た構造を持つ。

  16. apstndb revised this gist Sep 7, 2020. 1 changed file with 14 additions and 1 deletion.
    15 changes: 14 additions & 1 deletion UnofficialSpannerOperatorCollection.md
    Original file line number Diff line number Diff line change
    @@ -141,7 +141,7 @@ replica 内にローカルな Apply Join を行う。Input 側の Relational ope
    | (Input) | | 0 | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。通常 Create Batch を持つ。|
    | Map | | 0 | Input 側の値に応じて分散実行される Relational operator であり、通常 Batch Scan と Cross Apply を含む。|
    | Split Range | | 0 | 分散実行する対象の replica をキーから限定するための Function |
    | Batch | Yes | * | Batch |
    | Batch | Yes | * | 結合条件を満たさなかった時に Input 側の Batch から生成する行の定義 |


    ### Distributed Semi Apply
    @@ -319,6 +319,19 @@ ORDER BY と LIMIT 両方の処理をする operator。Sort Limit とほぼ同
    | MinorKey | Yes | * | ソートキーのうち、入力でソートされていない部分が順に指定される。 |
    | Value | Yes | * | ソートキー以外で取り出す列が順に指定される。 |

    ### [Outer Apply](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#outer-apply)

    replica 内にローカルな Outer Apply Join を行う。Input 側の Relational operator から取り出した値を使って、対応する Map 側の Relational operator を実行することで JOIN を実現する。
    主に Distributed Outer Apply の中で使われる場合と、 INTERLEAVE されたテーブル間の JOIN で使われる場合がある。

    #### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | (Input) | | 0 | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。|
    | Map | | 0 | Input 側の値に応じて実行される Relational operator|
    | | Yes | * | 結合条件を満たさなかった時に Input 側から生成する行の定義 |

    ### Random Id Assign

    (Undocumented)
  17. apstndb created this gist Sep 7, 2020.
    527 changes: 527 additions & 0 deletions UnofficialSpannerOperatorCollection.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,527 @@
    # Unofficial Cloud Spanner operator collection
    ## Relational operators
    ### [Aggregate](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#aggregate)

    `GROUP BY` に対応する集約を行う。
    入力がインデックス等で既にソート済であり、その順序で集約することでハッシュテーブルを使わなくて良い時は `call_type` が Stream となり Stream Aggregate と呼ばれる。

    #### Metadata

    | key | values | description |
    |-----|--------|-------------|
    | call_type | Local もしくは Global | |
    | iterator_type| Stream か未指定 | Stream か Hash による処理方法の区別を示す。|
    | scalar_aggregate| true か未指定 | |

    #### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | Key | Yes | * | scalar_aggregate=true の時には存在しない。集約に使うキーを示す。|
    | Agg| Yes | * |Aggregate 対象の値を示す。|

    ### [Array Unnest](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#array-unnest)

    配列の値と添字を元に Relation を作り出す operator。

    #### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | | Yes | 0 | 配列の値に対応する変数名を指示する Scalar operator |
    | | Yes | 1 | 配列の添字に対応する変数名を指示する Scalar operator |

    ### BloomFilterBuild

    (Undocumented)
    Bloom Filter を構築する。通常 Hash Join の Build 側に現れる。後に `BLOOM_FILTER_MATCH` を Condition に持つ Filter で使われる。

    #### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | | | |入力側の Relational operator |
    ### [Compute Struct](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#compute_struct)

    入力のそれぞれの行に対して STRUCT を生成する。 Compute Batch の入力や `AS STRUCT` を使ったサブクエリなどで現れる。

    #### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | | | 0 | 入力側の Relation operator |
    | | variable | * | STRUCT の各フィールドを表す Scalar operator |

    ### [Compute](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#compute_struct)

    入力のそれぞれの行に対して新しい列を追加する。

    #### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | | | 0 | 入力側の Relation operator |
    | | variable | * | 新しく計算する値を示す Scalar operator |

    ### [Create Batch](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#create_batch)

    入力から batch を作成する。主に Distributed Cross Apply で入力をまとめて対応する replica に送り、 Batch Scan で参照するために使われる。

    #### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | | | 0 | 入力側の Relation operator |
    | | variable | | batch の名前を指定する |

    ### [Cross Apply](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#cross-apply)

    replica 内にローカルな Apply Join を行う。Input 側の Relational operator から取り出した値を使って、対応する Map 側の Relational operator を実行することで JOIN を実現する。
    主に Distributed Cross Apply の中で使われる場合と、 INTERLEAVE されたテーブル間の JOIN で使われる場合がある。

    #### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | (Input) | | 0 | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。|
    | Map | | 0 | Input 側の値に応じて実行される Relational operator|

    ### Distributed Anti Semi Apply

    (Undocumented)
    `NOT EXISTS` などを処理するために分散 Anti Semi Join を行う。Distributed Cross Apply と似た構造を持つ。

    #### Metadata

    | key | values | description |
    |-----|--------|-------------|
    | subquery_cluster_node | | 分散実行する対象の Relation operator の ID |

    #### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | (Input) | | 0 | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。通常 Create Batch を持つ。|
    | Map | | 0 | Input 側の値に応じて分散実行される Relational operator であり、通常 Batch Scan と Cross Apply を含む。|
    | Split Range | | 0 | 分散実行する対象の replica をキーから限定するための Function |
    | Batch | Yes | * | Batch |

    ### [Distributed Cross Apply](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#distributed-cross-apply)

    分散 Apply Join を行う。Input 側の Relational operator から取り出した値を使って、対応する Map 側の Relational operator を適切な replica で実行することで分散 JOIN を実現する。

    #### Metadata

    | key | values | description |
    |-----|--------|-------------|
    | subquery_cluster_node | | 分散実行する対象の Relation operator の ID |

    #### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | (Input) | | 0 | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。通常 Create Batch を持つ。|
    | Map | | 0 | Input 側の値に応じて分散実行される Relational operator であり、通常 Batch Scan と Cross Apply を含む。|
    | Split Range | | 0 | 分散実行する対象の replica をキーから限定するための Function |

    ### Distributed Outer Apply

    `LEFT OUTER JOIN` などを処理するために分散 OUTER JOIN を行う。Distributed Cross Apply と似た構造を持つ。

    #### Metadata

    | key | values | description |
    |-----|--------|-------------|
    | subquery_cluster_node | | 分散実行する対象の Relation operator の ID |

    #### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | (Input) | | 0 | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。通常 Create Batch を持つ。|
    | Map | | 0 | Input 側の値に応じて分散実行される Relational operator であり、通常 Batch Scan と Cross Apply を含む。|
    | Split Range | | 0 | 分散実行する対象の replica をキーから限定するための Function |
    | Batch | Yes | * | Batch |


    ### Distributed Semi Apply

    (Undocumented)
    `EXISTS` などを処理するために分散 Semi Join を行う。Distributed Cross Apply と似た構造を持つ。

    #### Metadata

    | key | values | description |
    |-----|--------|-------------|
    | subquery_cluster_node | | 分散実行する対象の Relation operator の ID |

    #### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | (Input) | | 0 | 入力側の Relation operator であり、実際には type を持たないが Web UI やドキュメント等で Input と表示される。通常 Create Batch を持つ。|
    | Map | | 0 | Input 側の値に応じて分散実行される Relational operator であり、通常 Batch Scan と Cross Apply を含む。|
    | Split Range | | 0 | 分散実行する対象の replica をキーから限定するための Function |
    | Batch | Yes | * | Batch |

    ### [Distributed Union](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#distributed-cross-apply)

    各 replica で子の Relation operator を実行し、結果をまとめる。
    クエリ対象の replica を他の server(remote server) が持つ場合、remote server を呼び出すため remote call が発生し、 `executionStats` に記録される`。
    `call_type` が Local なものは、特定の server 内の結果をまとめる。

    #### Metadata
    | key | values | description |
    |-----|--------|-------------|
    | call_type | Local, 未指定 ||
    | subquery_cluster_node | | 分散実行する対象の Relation operator の ID |

    #### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | | | 0 | 入力として分散実行される Relation operator |
    | Split Range | | 0 | 分散実行する対象の replica をキーから限定するための Function |

    ### [Empty Relation](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#empty-relation)

    空の Relation を生成する。`LIMIT 0` を指定した際には常に結果は 0 行で何も Scan 等の入力をする必要がないが、 Relation operator ではある必要があるので使われる。

    #### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | | | 0 | 0 を意味する Constant |

    ### [Filter](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#filter)

    スキャンとは独立して任意のタイミングで行をフィルタする。

    #### ChildLinks
    | type | variable | position | description |
    |-----|--------|---|-------------|
    | | | 0 | フィルタの入力となる Scan |
    | Condition | | 0 | 入力からフィルタする Function |

    ### [FilterScan](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#filter_scan)

    Scan のすぐ上に位置し、スキャンに伴うフィルタを行う。Scan の一部として働くため `executionStats` を持たず、実行時の挙動は Scan 側の `rows`, `filtered_rows` などを通して確認できる。

    #### ChildLinks
    | type | variable | position | description |
    |-----|--------|---|-------------|
    | | | 0 | フィルタの入力となる Scan |
    | Seek Condition | | 0 | スキャン対象のキー範囲を絞るシークに使う Function であり、 [アクセス述語](https://use-the-index-luke.com/ja/sql/where-clause/searching-for-ranges/greater-less-between-tuning-sql-access-filter-predicates)に対応する。|
    | Residual Condition | | 0 | スキャン後のフィルタに使う Function であり、[フィルタ述語](https://use-the-index-luke.com/ja/sql/where-clause/searching-for-ranges/greater-less-between-tuning-sql-access-filter-predicates)に対応する。 |
    ### [Hash Join](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#hash-join)

    ハッシュ結合を行う。
    Build 側の全 row を元にハッシュマップを構築してから Probe 側の各 row の値を使ってハッシュマップを引くことで Condition を評価して JOIN を行う。

    #### Metadata

    | key | values | description |
    |-----|--------|-------------|
    | join_type | INNER, BUILD_OUTER, PROBE_OUTER, BUILD_SEMI, BUILD_ANTI_SEMI, ... | INNER 以外は Build と Probe がどちらかで意味が変わるので、 BUILD か PROBE が prefix になる。|

    #### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | Build | | 0 | 構築するハッシュマップ側になる Relational operator |
    | Probe | | 0 | ハッシュマップに通す側の Relational operator |
    | Condition | | 0 | JOIN 条件となる Function |
    | Build | Yes | * | Build 側からハッシュマップに含める列を指定する Scalar operator |
    | Probe | Yes | * | Probe 側から variable を定義する Scalar operator |

    ### [Limit](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#limit)

    Limit のみを行う。 `ORDER BY` を指定しないか、キー順と一致する順序で指定して `LIMIT` を指定した際に現れる。

    #### Metadata

    | key | values | description |
    |-----|--------|-------------|
    | call_type | Local もしくは Global ||

    #### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | | | 0 | ソート対象の入力となる Relation operator。 |
    | Limit | | 0 | 取得する行数を指定する Scalar operator |

    ### MiniBatchAssign

    (Undocumented)
    MiniBatchAssign より下にある以外はよく分かっていない。

    #### ChildLinks

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | | 0 | 入力となる Relation operator。 |
    | | | 1 | Scalar operator。バッチサイズを指示している? |

    ### MiniBatchKeyOrder

    (Undocumented)

    MiniBatchAssign より上にある以外はよく分かっていない。

    #### ChildLinks

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | | 0 | 入力となる Relation operator。 |

    ### Minor Sort

    (Undocumented)

    ストリームの一部に対して ORDER BY の処理をする。Sort とほぼ同じだが、テーブルやインデックスとソート順の prefix が一致して全体の Sort が必要ない場合に使われる。

    #### Metadata

    | key | values | description |
    |-----|--------|-------------|
    | call_type | Local もしくは Global ||

    #### ChildLinks

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | | 0 | ソート対象の入力となる Relation operator。 |
    | MajorKey | Yes | * | ソートキーのうち、入力でソート済な部分が順に指定される。 |
    | MinorKey | Yes | * | ソートキーのうち、入力でソートされていない部分が順に指定される。 |
    | Value | Yes | * | ソートキー以外で取り出す列が順に指定される。 |

    ### Minor Sort Limit

    (Undocumented)

    ORDER BY と LIMIT 両方の処理をする operator。Sort Limit とほぼ同じだが、テーブルやインデックスとソート順の prefix が一致して全体の Sort が必要ない場合に使われる。

    #### Metadata

    | key | values | description |
    |-----|--------|-------------|
    | call_type | Local もしくは Global ||

    #### ChildLinks

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | | 0 | ソート対象の入力となる Relation operator。 |
    | Limit | | 0 | 取得する行数を指定する Scalar operator |
    | MajorKey | Yes | * | ソートキーのうち、入力でソート済な部分が順に指定される。 |
    | MinorKey | Yes | * | ソートキーのうち、入力でソートされていない部分が順に指定される。 |
    | Value | Yes | * | ソートキー以外で取り出す列が順に指定される。 |

    ### Random Id Assign

    (Undocumented)

    `TABLESAMPLE` を使用した際に現れる。 Filter operator と組み合わせることで、ランダムに割り当てた値を元にフィルタすることでサンプリングを実現する。
    なお Sample について言及されている[ドキュメント](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#sample)のクエリがこの operator になるため、ドキュメントの解説が古い可能性が高い。

    #### ChildLinks

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | | 0 | 入力となる Relational operator |
    | | Yes | | description が `<random id>` となる Reference を指す variable であり、後に Filter で名前が参照される。 |

    ### RowCount

    (Undocumented)

    #### ChildLinks

    | type | variable | position | description |
    |-----|--------|---|-------------|
    | | | 0 | 入力となる Relational operator |

    ### [Scan](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#scan)

    各入力からのスキャンを行う。`PlanNode.displayName` としては Scan だが、一般的に `scan_type` の値と合わせて Index Scan, Table Scan などと表示される。

    #### Metadata

    | key | values | description |
    |-----|--------|-------------|
    | Full scan | true もしくは未指定 ||
    | scan_target | | スキャン対象の名前を指示する。 |
    | scan_type | IndexScan, TableScan, SpoolScan, BatchScan | スキャン対象の種類を指示する。 |

    #### ChildLinks

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | Yes | * | スキャン対象の列を表現する Reference operator。 |

    ### [Serialize Result](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#serialize_result)

    最終的に ResultSet に含まれる値を組み立てる。これよりも上の operator で row の値を操作することはない。

    #### ChildLinks

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | | 0 | 入力となる Relation operator。 |
    | | | * | `metadata.rowType.fields` に現れる順で対応する式を表現する Scalar operator。 |
    | Scalar | | * | 式で参照される Scalar Subquery と名前を結びつけるために使われる。 |

    ### [Sort](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#sort)

    `ORDER BY` によるソートのみをする operator。Sort Limit とほぼ同じだが、 `LIMIT` を設定しない場合はこちらになる。

    #### ChildLinks

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | | 0 | ソート対象の入力となる Relation operator。 |
    | Key | Yes | * | ソートキーとなる列が Reference で順に指定される。 |
    | Value | Yes | * | ソートキー以外で取り出す列が Reference で順に指定される。 |

    ### [Sort Limit](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#sort)

    ORDER BY と LIMIT 両方の処理をする operator。Sort とほぼ同じだが、 `LIMIT` を使う場合はこちらになる。

    #### Metadata

    | key | values | description |
    |-----|--------|-------------|
    | call_type | Local もしくは Global ||

    #### ChildLinks

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | | 0 | ソート対象の入力となる Relation operator。 |
    | Limit | | 0 | 取得する行数を指定する Scalar operator |
    | Key | Yes | * | ソートキーが順に指定される。 |
    | Value | Yes | * | ソートキー以外で取り出す列が順に指定される。 |

    ### SpoolBuild

    (Undocumented)
    `WITH` などによる一時テーブルを保存する。 Spool Scan によって読み取られる。

    #### Metadata

    | key | values | description |
    |-----|--------|-------------|
    | spool_name | | 構築する spool の名前 |

    #### ChildLinks

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | | 0 | 保存対象の入力となる Relation operator。 |
    | | | * | 一時テーブルの列となる Scalar operator |
    ### [Union All](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#union_all)

    `UNION ALL` を表現する operator で、子の Union Input 全てが返す Relation を合わせて返す。

    #### ChildLinks

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | | * | UNION 対象を指す Union Input operator |
    | | Yes | * | Union All operator の結果の n 列目の名前を持ち、 `input_{n}` と対応付ける Scalar operator |

    ### [Union Input](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#union_input)

    Union All operator のそれぞれの枝からの入力を揃えるための operator。

    #### ChildLinks

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | | 0 | それぞれの枝の本体となる Relation operator |
    | `input_{n}` | | 0 | Union All operator の結果の n 列目となる式の Scalar operator |

    ### [Unit Relation](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#unit-relation)

    特に値を持たない単一の行を生成する。 Unit Relation を受ける Compute や Serialize Result で実際の列の値が設定される。
    例: `SELECT 42`, `SELECT 42 UNION ALL SELECT 43`

    #### Child Links

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | | 0 | `1` を表現する Constant が常に指定される。|

    ## Scalar operators

    Subquery 系以外は実行計画の行としては表示されないため、ほぼドキュメンテーションされていない。

    ### Array Constructor

    (Undocumented)
    配列リテラルに対応し、配列値を表現する。
    `shortRepresentation.description` は配列のリテラル表記となる。

    #### Child Links

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | | * | 配列の各値を表現する Scalar operator を指す。 |

    ### [Array Subquery](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#array_subqueries)

    子のサブクエリと式から配列を計算する。

    #### Child Links

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | | 0 | サブクエリとなる Relational operator で中で variable を定義する。 |
    | | | 1 | サブクエリの中の variable を参照する Scalar operator。サブクエリの各 row に対して配列の要素を計算するために使われる。 |

    ### Constant

    (Undocumented)
    定数を表す。`shortRepresentation.description` に値のリテラル表記や `<typed null>` などが文字列として入っている。

    ### Function

    (Undocumented)
    演算式と関数呼び出しを含む関数を表現する。`shortRepresentation.description` に演算子や関数名を含む式が文字列として入っている。

    #### Child Links

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | | * | 各オペランド |

    ### Parameter

    (Undocumented)
    クエリパラメータに対応する Scalar operator であり、実行時に `Statement.params` の name metadata と一致する名前の値に置き換えられる。

    #### Metadata

    | key | values | description |
    |-----|--------|-------------|
    | name | | パラメータ名 |
    | type | scalar, ? | |

    ### Reference

    (Undocumented)
    `shortRepresentation.description` に名前を持つ参照で metadata も子も持たない。
    Sort 系の operator の Key で降順の場合は `shortRepresentation.description``$ItemId (DESC)` のように `(DESC)` が含まれる。

    ### [Scalar Subquery](https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#unit-relation)

    子のサブクエリと式からスカラ値を計算する。

    #### Child Links

    | type | variable? | position | description |
    |-----|--------|---|-------------|
    | | | 0 | サブクエリとなる Relational operator で、中で variable を定義する。 |
    | | | 1 | サブクエリの中の variable を参照する。 |