21

It's very convenient to be able to set script variables. For example,

SET start_date = 20151201;

SELECT * FROM some_table where date = {$hiveconf:start_date};

Does Presto have this capability?

Kevin Morris
  • 213
  • 1
  • 2
  • 4

3 Answers3

18

You can do this

WITH VARIABLES AS (SELECT VALUE AS VAR1, VALUE AS VAR2)
SELECT * 
FROM TABLE CROSS JOIN VARIABLES 
WHERE COLUMN = VAR1
Mahmoud Alhyari
  • 221
  • 2
  • 3
14

Not yet. Presto only have set session command for setting some presto properties during current session. For example SET SESSION distributed_join=true;

But presto can not set a variable and use it in following sql like hive does.

袁安峰
  • 652
  • 6
  • 5
1

Not quite a script variable per say; but some UIs like DataGrip (probably DBeaver as well) emulate passing variables; e.g.:

where date = ${start_date}
Neil
  • 7,482
  • 6
  • 50
  • 56