id: tabular_union
name: Union
description: >
  Combine multiple tables vertically (stack rows). All tables must have
  compatible schemas. Optionally deduplicate rows.
version: 1.0.0
category: combine
type: table-to-table
default_implementation: duckdb

inputs:
  - name: tables
    type: table
    format: parquet
    description: Two or more tables to combine
    required: true
    multiple: true

requires: {}  # structural — operates on any table

outputs:
  - name: result
    type: table
    format: parquet
    description: Combined table

params:
  distinct:
    type: boolean
    default: false
    description: If true, remove duplicate rows (UNION vs UNION ALL)

# backends: audited 2026-08-14 (defect 50). A key means a runtime that DISPATCHES this op —
# folia-engine `dispatch_op` (products/sdk/folia-engine/src/lib.rs), a `registerOp`/OP_TABLE
# entry in packages/compute, `_BUILTIN_OP_MAP` in folia/compute.py, or a backend manifest
# (folia/backends/*/backend.yaml).
backends:
  js:
    function: tabular_union
    dispatch: packages/compute/src/ops/tabular-sql.ts
  python:
    function: tabular.ops.union
    dispatch: folia/compute.py _BUILTIN_OP_MAP

display_hints:
  table:
    renderer: tanstack-table
