1

How do you UNION ALL multiple prepared statements in Athena/Presto?

Lets say I have PreparedStatement1 as:

aws athena create-prepared-statement --statement-name PreparedStatement1 --query-statement "SELECT colA1 AS col1, colA2 AS col2 FROM table1 WHERE category=?" --work-group primary

PreparedStatement2 as:

aws athena create-prepared-statement --statement-name PreparedStatement2 --query-statement "SELECT colB1 AS col1, colB2 AS col2 FROM table2 WHERE category=?" --work-group primary

I would like to union both of them by

(EXECUTE PreparedStatement1 USING category1)

UNION ALL

(EXECUTE PreparedStatement2 USING category2)

ORDER BY col1

But it doesnt work. I get an error

mismatched input 'EXECUTE'. Expecting: '(', 'LATERAL', 'UNNEST', <identifier>, <query>

Is it possible to do this in Athena/Presto? I would like to union all more than 2 prepared statements

user1179317
  • 2,693
  • 3
  • 34
  • 62

0 Answers0