I am using Flink Table API. I have a table definition that I want to select all fields and convert them to a JSON string in a new field.
My table has three fields; a: String, b: Int, c: Timestamp.
If I do
INSERT INTO kinesis
SELECT a, b, c from my_table
The kinesis stream has json records;
{
"a" : value,
"b": value,
"c": value
}
However, I want something similar to Spark's functions;
INSERT INTO kinesis
SELECT "constant_value" as my source, to_json(struct(*)) as playload from my_table
So, expected result is;
{
"my_source": "constant_value",
"payload": "json string from the first example that has a,b,c"
}
I can't see any to_json
or struct()
functions in Flink. Is it possible to implement?