3

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?

Rui
  • 3,454
  • 6
  • 37
  • 70

2 Answers2

1

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
adeneche
  • 182
  • 4
1

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

zchrykng
  • 1,066
  • 1
  • 10
  • 20