I am a newbie of Apache Drill, and I need to run a SQL script through sqlline. In most SQL client, it is allowed to use some variables in sqlline, so hereby I would like to ask that is it possible to use variables in sqlline of Apache Drill?
Someone asked a similar question on Drill user mailing list. Here is the answer from the same link:
You could achieve this by writing a wrapper script:
#!/bin/env bash
VARIABLE="testvalue"
SQL="SELECT '${VARIABLE}' from sys.version;"
sqlline -u jdbc:drill: -n cmatta -p xxxx <<< $SQL
Here's a real world example where I substitute all occurrences of the text 'staticLoadTime' in a drill file with the variable ${staticLoadTime} using sed and then pipe the result to sqlline. This avoids having to create a wrapper or other temporary file.
sed 's/staticLoadTime/${staticLoadTime}/g' ${Source}.drill | sqlline -u jdbc:drill:zk=local
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With