Versions Compared

Key

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

...

  1. assign 'aggregation' to 'merge-engine' 
  2. designate aggregate function for each column of table.

For example,

unmigrated-wiki-

...

markup
--DDL
CREATE TABLE T (
    

...

pk STRING PRIMARY KEY NOT ENFOCED,
  

...

  sum_field1 BIGINT,
    max_field1 BIGINT,
    

...

default_

...

field BIGINT

...

 ) 
WITH ( 

...

'merge-engine' = 'aggregation',

...

'

...

aggregate-function' = '

...

{
    sum_field1:sum,
    max_field2:max
  }'   -- sum up all sum_field1 with same pk

...

; get max value of all max_field1 with same pk
);

...



-- DML

...


INSERT INTO T VALUES ('pk1', 1, 1, 1);

...


INSERT INTO T VALUES ('pk1', 1, 1, NULL);

...


-- verify

...


SELECT * FROM T;

...


=> output 'pk1', 2, 2

...

, NULL


Future Work
An advanced way of introducing Advanced usage of pre-aggregated merge Apart from creating table with pre-aggregated merge engine, into Flink table store is using materialized view to get pre-aggregated merge result from a source table is another choice.

CREATE MATERIALIZED VIEW T
with (
    'merge-engine' = 'aggregation'
) AS SELECT
    pk,
    SUM(field1) AS sum_field1,
    MAX(field2) AS max_field1
FROM source_t
GROUP BY pk ;

This will start a stream job . Then a stream job is started to synchronize data, consume source data, and write incrementally to T . This data synchronization job has no state.

Briefly list any new interfaces that will be introduced as part of this proposal or any existing interfaces that will be removed or changed. The purpose of this section is to concisely call out the public contract that

Proposed Changes

More information is described in JIRA.

Proposed Changes

An ConfigOption<String> type variable named ‘AGGREGATE_FUNCTION’ is defined in CoreOptions.java to retrieve configuration of 'aggregate-function' in WITH clause.

Adding one more value named 'PRE_AGGREGATE'  to enum MergeEngine type in CoreOptions.java. It acts as one type of the merge-engines supported by Flink table store.

In the constructor of ChangelogWithKeyFileStoreTable, using 'PRE_AGGREGATE' as one more case in switch-case to initialize merge-engine.

A subclass of MergeFunction named AggregateMergeFunction is created in AggregateMergeFunction.java to conduct pre-aggregated mergeDescribe the new thing you want to do in appropriate detail. This may be fairly extensive and have large subsections of its own. Or it may be a few sentences. Use judgement based on the scope of the change.

Compatibility, Deprecation, and Migration Plan

This is new feature, no compatibility, deprecation, and migration plan.

Test Plan

Each pre-aggregated merge function will be covered with IT tests.

...