1

I've been trying to SOURCE a file with SQL statements in the Flink sql-client. From the docs:

SOURCE Reads a SQL SELECT query from a file and executes it on the Flink cluster.

This uses the Docker images for Flink version 1.13.1, Scala 2.11. Everything else about this Flink distribution works fine, as far as I can tell.

Within the container:

/opt/flink# echo "select 'hello';" > test.sql
/opt/flink# sql-client.sh

Then within the sql-client:

Flink SQL> select 'hello';
-- works as intended
[INFO] Result retrieval cancelled.

Flink SQL> source test.sql;
[ERROR] Could not execute SQL statement. Reason:
org.apache.calcite.runtime.CalciteException: Non-query expression encountered in illegal context

I'm sure it's a very obvious mistake. What am I missing?

1 Answer 1

2
+50

SOURCE command is not a public API in previous version and it has been removed in 1.13. As an alternative, we provided sql-client.sh -f test.sql to execute a SQL file which is a way widely used in other systems. See more: https://ci.apache.org/projects/flink/flink-docs-release-1.13/docs/dev/table/sqlclient/#execute-sql-files

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks, that's what I suspected, just couldn't find the release note that mentioned the deprecation of SOURCE. I'm using the initialization mode with -i now, which works great.
In this -f mode however, SET command does not seem to work : SET 'table.dml-sync' = 'true'; [ERROR] Could not execute SQL statement. Reason: org.apache.flink.sql.parser.impl.ParseException: Encountered "\'table.dml-sync\'" at line 2, column 5.
Hi, is it possible using -f option to execute the statements contained in a file, and then continue the session in interactive mode? This may be very useful during development in order to try some experiments starting from a consolidated set of statements contained into the file. Maybe this was possible using the SOURCE.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.