Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagesql
titleCreateTable
CREATE TABLE Orders ( order_id INT, order_type STRING, `date` TIMESTAMP, price INT, number INT ) 
PARTITIONED BY (order_type) 
WITH ( 'write-mode' = 'append-only', 'bucket' = '-1' );

...

We want this table to be used for OLAP offline analysis, such as once a day statistics. But its data volume and traffic volume are large, so we hope it can update by itself:

Code Block
languagesql
titleStreamInsert
INSERT INTO Orders SELECT * FROM OrderSource;


Conduct off-line analysis and query to calculate the total sales in one day:

Code Block
languagesql
titleBatchQuery
SELECT sum(price * number) FROM Orders GROUP BY DATE_FORMAT(`date`, 'yyyyMMdd’);


Statistical order type transaction quantity:

Code Block
languagesql
titleBatchQuery
SELECT order_type, sum(*) FROM Orders GROUP BY order_type;


The order type has changed, and all historical data needs to be changed (flink-version >= 1.17) :

Code Block
languagesql
titleBatchUpdate
UPDATE Orders SET order_type = 'banana' WHERE order_type = 'apple' AND `date` > TO_TIMESTAMP('2020-02-02', 'yyyy-HH-dd’);


Public Interfaces

Only the table property 'bucket' = '-1' is exported to public.

...

4. Support parallelly insert data into one bucket.


The sql "INSERT INTO Orders SELECT * FROM OrderSource" create a dag like below:


The writes all belong to one bucket, they could insert into one bucket parallelly. So we don't worry about the performance while inserting.

...