I have to execute the following query against Hive from Python:
SELECT * FROM user WHERE age > ${hiveconf:AGE}
As for now I have the following working code snippet:
import pyhs2
with pyhs2.connect(host='localhost',
port=60850,
authMechanism="PLAIN",
user='hduser',
database='default') as conn:
with conn.cursor() as cur:
cur.execute("SELECT * FRPM user WHERE age > ?", 10)
So I can pass parameters to a query with PyHs2. But how can I perform variable substitution from Python code in order to not change the original query (i.e. replace ${hiveconf:AGE}
with some value in a clean manner)?