All Products
Search
Document Center

Realtime Compute for Apache Flink:UNION ALL

Last Updated:Jul 05, 2024

This topic describes how the compatibility between a deployment and the state data is affected after you modify UNION ALL in an SQL statement for the deployment.

Modifications that do not affect or partially affect the compatibility

Change the order of input queries in UNION ALL. This modification does not affect the state data compatibility of downstream stateful operators.

create table MyTable2 (
  a int,
  b bigint,
  c varchar,
  d int
);

-- Original SQL statement: 
select a, sum(b), max(c) from (
  select a, b, c from MyTable union all select a, b, c from MyTable2
) group by a;


-- Change the order of input queries in UNION ALL. After this modification, the deployment remains fully compatible with the state data. 
select a, sum(b), max(c) from (
  select a, b, c from MyTable2 union all select a, b, c from MyTable
) group by a;

Modifications that cause full incompatibility

Add an input query to or delete an input query from UNION ALL. This modification causes state data incompatibility for downstream stateful operators.

create table MyTable2 (
  a int,
  b bigint,
  c varchar,
  d int
);

-- Original SQL statement: 
select a, sum(b), max(c) from (
  select a, b, c from MyTable union all select a, b, c from MyTable2
) group by a;

create table MyTable3 (
  a int,
  b bigint,
  c varchar,
  d int
);

-- Add an input query to UNION ALL. After this modification, the deployment becomes incompatible with the state data. 
select a, sum(b), max(c) from (
  select a, b, c from MyTable
  union all
  select a, b, c from MyTable2
  union all
  select a, b, c from MyTable3
) group by a;