Created 10-15-2024 08:24 AM
There are two different examples of SQL in SQL Server
1. DECLARE @Max_date_id varchar(10)
SELECT @Max_date_id = MAX(date_id) FROM t_my_table
SELECT @Max_date_id
2. DECLARE @Max_date_id varchar(10) = (SELECT MAX(date_id) FROM t_my_table)
SELECT @Max_date_id
How can I do the same thing in "Impala Query Manager"?
Created 10-15-2024 09:03 AM
Hi @AKO ,
Impala has variable substitution like this:
[hostname.local.net:21000] default> SET VAR:query=SELECT 1+2;
Variable QUERY set to SELECT 1+2
[hostname.local.net:21000] default> ${VAR:query};
Query: SELECT 1+2
Query submitted at: 2024-10-15 15:54:29 (Coordinator: https://hostname.local.net:25000)
Query progress can be monitored at: https://hostname.local.net:25000/query_plan?query_id=nnnn
+-------+
| 1 + 2 |
+-------+
| 3 |
+-------+
Fetched 1 row(s) in 1.15s
See official Impala docs at:
https://impala.apache.org/docs/build/html/topics/impala_shell_running_commands.html
This is a feature of impala-shell, and not impala itself, so depending on what you call "Impala Query Manager", your experience might be different.
If you want a solution that is more database independent, then I recommend to use a view or a SELECT CTE (WITH statement) instead:
WITH sub_query AS (
SELECT 1+2
)
SELECT * FROM sub_query;
Created 10-15-2024 09:03 AM
Hi @AKO ,
Impala has variable substitution like this:
[hostname.local.net:21000] default> SET VAR:query=SELECT 1+2;
Variable QUERY set to SELECT 1+2
[hostname.local.net:21000] default> ${VAR:query};
Query: SELECT 1+2
Query submitted at: 2024-10-15 15:54:29 (Coordinator: https://hostname.local.net:25000)
Query progress can be monitored at: https://hostname.local.net:25000/query_plan?query_id=nnnn
+-------+
| 1 + 2 |
+-------+
| 3 |
+-------+
Fetched 1 row(s) in 1.15s
See official Impala docs at:
https://impala.apache.org/docs/build/html/topics/impala_shell_running_commands.html
This is a feature of impala-shell, and not impala itself, so depending on what you call "Impala Query Manager", your experience might be different.
If you want a solution that is more database independent, then I recommend to use a view or a SELECT CTE (WITH statement) instead:
WITH sub_query AS (
SELECT 1+2
)
SELECT * FROM sub_query;
Created 10-15-2024 10:03 AM
I know about CTE solution I was trying to find if the variable like SQL Server solution is there or not. I will use CTE. thanks