Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]
Created on
10-15-2024
08:24 AM
- last edited on
04-20-2026
11:24 PM
by
GrazittiAPI
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