RWM Console cluster: risingwave-alinma.alinma-rw.svc.cluster.local

← cluster alinma_bff objects order_execution_summaries_mv
Overview Objects Graph History
materialized view · alinma_bff.order_execution_summaries_mv Explain plan ▶
Parallelism
2
Actors
12 / 12
running
Distribution
HASH
Rows
13
State size
3.9 KiB
Created
2026-08-13 17:28
Initialized
2026-08-13 17:28
Fragment flags
LOCALITY_PROVIDERMVIEWSNAPSHOT_BACKFILL_STREAM_SCANSTREAM_SCAN
Actors
ActorFragmentWorkerState
737596 52299 51 running
737597 52299 51 running
737598 52297 51 running
737599 52297 51 running
737600 52298 51 running
737601 52298 51 running
737602 52301 51 running
737603 52301 51 running
737604 52300 51 running
737605 52300 51 running
737606 52302 51 running
737607 52302 51 running
sql · alinma_bff.order_execution_summaries_mv — click to expand
CREATE MATERIALIZED VIEW alinma_bff.order_execution_summaries_mv AS
WITH execution_totals AS (
  SELECT
    ex.order_id,
    SUM(CAST(ex.quantity AS DECIMAL)) AS filled_quantity,
    SUM(
      CAST(ex.quantity AS DECIMAL) * CAST((
        ex.price -> 'amount' ->> 'value'
      ) AS DECIMAL)
    ) AS total_amount,
    MAX(
      COALESCE(ex.price -> 'currencyCode' ->> 'value', ex.price -> 'currency_code' ->> 'value')
    ) AS currency_code
  FROM alinma_bff.order_executions_bounded_mv AS ex
  GROUP BY
    ex.order_id
)
SELECT
  t.order_id,
  JSONB_BUILD_OBJECT(
    'filledQuantity',
    JSONB_BUILD_OBJECT('value', CAST(MAX(t.filled_quantity) AS VARCHAR)),
    'averagePrice',
    JSONB_BUILD_OBJECT(
      'currencyCode',
      JSONB_BUILD_OBJECT('value', COALESCE(MAX(t.currency_code), '')),
      'amount',
      JSONB_BUILD_OBJECT(
        'value',
        CASE
          WHEN MAX(t.filled_quantity) > 0
          THEN CAST((
            MAX(t.total_amount) / MAX(t.filled_quantity)
          ) AS VARCHAR)
          ELSE '0'
        END
      )
    ),
    'totalAmount',
    JSONB_BUILD_OBJECT(
      'currencyCode',
      JSONB_BUILD_OBJECT('value', COALESCE(MAX(t.currency_code), '')),
      'amount',
      JSONB_BUILD_OBJECT('value', CAST(MAX(t.total_amount) AS VARCHAR))
    ),
    'totalFees',
    JSONB_BUILD_OBJECT(
      'currencyCode',
      JSONB_BUILD_OBJECT('value', COALESCE(MAX(t.currency_code), '')),
      'amount',
      JSONB_BUILD_OBJECT('value', CAST(COALESCE(SUM(fl.amount), 0) AS VARCHAR))
    ),
    'fees',
    COALESCE(
      JSONB_AGG(
        JSONB_BUILD_OBJECT(
          'kind',
          fl.kind,
          'amount',
          JSONB_BUILD_OBJECT(
            'currencyCode',
            JSONB_BUILD_OBJECT('value', COALESCE(t.currency_code, '')),
            'amount',
            JSONB_BUILD_OBJECT('value', CAST(fl.amount AS VARCHAR))
          )
        ) ORDER BY fl.kind
      ) FILTER(WHERE
        NOT fl.order_id IS NULL),
      CAST('[]' AS JSONB)
    )
  ) AS execution_summary
FROM execution_totals AS t
LEFT JOIN alinma_bff.order_execution_fee_lines_mv AS fl
  ON fl.order_id = t.order_id
GROUP BY
  t.order_id
Lineage · alinma_bff.order_execution_summaries_mv 4 objects
Direct (1-hop) dependencies from rw_depend, across schemas. Click a neighbor to expand its dependencies; ⌘/Ctrl-click opens its page. Drag to pan, scroll to zoom. External source/sink endpoints (Kafka, Iceberg) are not shown.