Flink SQL: Do not materialize NULL fields when inserting into MongoDB

68 Views Asked by At
CREATE TABLE test
(
    _id STRING PRIMARY KEY NOT ENFORCED,
    a INT
) WITH (
      'connector' = 'mongodb',
      'uri' = 'mongodb://user:password@database:27017',
      'database' = 'database',
      'collection' = 'test'
      );

INSERT INTO test
VALUES ('id',
           (SELECT bar
        FROM (SELECT 1 AS foo)
        LEFT JOIN (SELECT 2 AS bar)
        ON foo = bar));

Desired result in MongoDB:

{ "_id" : "id"}

Actual:

{ "_id" : "id", "a" : null }

Is it possible to not materialize the field with NULL value using just Flink SQL or will I have to use the datastream API?

I could not find any option to change this behaviour in the documentation.

0

There are 0 best solutions below