Search code examples
flink-sql

Setting column values as column names in the Flink SQL query result


I would like to read a table that has values that will be the column names of the Flink SQL query result. For example, I have t1 as

name value
----------
sp_1 100
sp_2 200
sp_3 300
...  ...

Now I want the result of the query to look like this (t2):

sp_1 sp_2 sp_3 ...
100  200  300

Assume all the sp_* have been created in t2.

Is it possible to achieve it through Flink SQL?

Flink version: 1.13.6


Solution

  • I believe this would be possible using something like PIVOT and UNPIVOT functions, which are at the time of writing this not yet supported. You can track https://issues.apache.org/jira/browse/FLINK-23179 for updates.