Search code examples
flink-sql

Local Variables in FLINK SQL


This is probably a silly question but I have been wondering if it's possible to use variables like

DECLARE @TestVariable AS VARCHAR(100)='Hello World'
PRINT @TestVariable

Looking at the documentation, it seems impossible but a page regarding Hive compatibility makes me question this: https://nightlies.apache.org/flink/flink-docs-release-1.17/docs/dev/table/hive-compatibility/hive-dialect/set/

Would installing the Hive dependencies allow me to use variables in SQL Flink queries? Or am I dead wrong?

Thank you very much,


Solution

  • You can only do this when you enable the Hive compatibility in Flink SQL. It's currently not supported otherwise. There is a feature request for this, which you can find under https://issues.apache.org/jira/browse/FLINK-17377