Created on 07-25-2018 09:42 AM - edited 09-16-2022 06:30 AM
Hello,
I am trying to assighn table names to variable in Impala editor on HUE but it does not seem to work.
set var:table_name=production_table;
select * from ${var:table_name}
I get the below error, when I execute the below set statement.
set var:table_name=production_table;
Created 12-09-2020 09:27 AM
Hi @sai, you can use this script.
For id column, 2 is default value. You don't have to define default value, its optional.
Created 07-09-2021 10:48 AM
¿How is it possible to set the value using a query not a fixed value? For example, if I have a select that retunrs a date, how can I add to a variable?
Created 07-11-2022 09:18 AM
Hi Steven9, is posible if you use as follow:
/* DROP, CREATE AND INSERT */
DROP IF EXIST YOUR_LIBRARY.YOUR_TABLE;
CREATE TABLE IF NOT EXISTS YOUR_LIBRARY.YOUR_TABLE(Ciudad VARCHAR(50), Valor BIGINT);
INSERT INTO TABLE YOUR_LIBRARY.YOUR_TABLE VALUES
(CAST("BOGOTA" AS VARCHAR(50)), 1000),
(CAST("CARTAGENA" AS VARCHAR(50)), 500),
(CAST("MEDELLIN" AS VARCHAR(50)), 50),
(CAST("PURIFICACION" AS VARCHAR(50)), 600),
(CAST("DOLORES" AS VARCHAR(50)), 250)
(CAST("CALI" AS VARCHAR(50)), 450),
;
/* VARIABLES */
${TRX=500};
${CITY="MEDELLIN"};
/* USING VARIABLES TO EXTRACT FROM TABLE */
SELECT * FROM YOUR_LIBRARY.YOUR_TABLE WHERE VALOR >= ${TRX};
SELECT * FROM YOUR_LIBRARY.YOUR_TABLE WHERE CIUDAD <> ${CITY};
Created 07-11-2022 01:21 PM
DROP TABLE IF EXISTS...
Created 07-11-2022 09:17 AM
Hi Sai, is possible if you use as follow
/* DROP, CREATE AND INSERT */
DROP IF EXIST YOUR_LIBRARY.YOUR_TABLE;
CREATE TABLE IF NOT EXISTS YOUR_LIBRARY.YOUR_TABLE(Ciudad VARCHAR(50), Valor BIGINT);
INSERT INTO TABLE YOUR_LIBRARY.YOUR_TABLE VALUES
(CAST("BOGOTA" AS VARCHAR(50)), 1000),
(CAST("CARTAGENA" AS VARCHAR(50)), 500),
(CAST("MEDELLIN" AS VARCHAR(50)), 50),
(CAST("PURIFICACION" AS VARCHAR(50)), 600),
(CAST("DOLORES" AS VARCHAR(50)), 250)
(CAST("CALI" AS VARCHAR(50)), 450),
;
/* VARIABLES */
${TRX=500};
${CITY="MEDELLIN"};
/* USING VARIABLES TO EXTRACT FROM TABLE */
SELECT * FROM YOUR_LIBRARY.YOUR_TABLE WHERE VALOR >= ${TRX};
SELECT * FROM YOUR_LIBRARY.YOUR_TABLE WHERE CIUDAD <> ${CITY};