Problem
altinity-sql-browser should support SQL queries with typed variables, for example:
WITH
{database:String} AS p_database,
{table:String} AS p_table
SELECT ...
Currently, there is no UI flow for detecting these variables while editing SQL and providing values before execution.
Proposed feature
While the user is typing a SQL query, the app should detect variables in the ClickHouse placeholder format:
For every detected variable, show an input field below the SQL editor header where the user can enter a value.
Example detected variables:
{database:String}
{table:String}
Should render fields like:
database: [________]
table: [________]
Execution behavior
When the query is executed, the app should substitute the variables with the entered values before sending the SQL to ClickHouse.
Example:
WITH
{database:String} AS p_database,
{table:String} AS p_table
SELECT ...
With values:
database = default
table = events
Should be sent to ClickHouse as:
WITH
'default' AS p_database,
'events' AS p_table
SELECT ...
Scope
This feature should apply only to SELECT queries.
It should not apply to VIEW definitions. Views have their own variables, and those variables should not be substituted by the app.
Requirements
- Detect variables in the format
{name:Type} while editing SQL.
- Show a row below the SQL editor header with inputs for detected variables.
- Keep variable values editable before execution.
- Substitute variables only when executing
SELECT queries.
- Do not substitute variables in
VIEW definitions.
- Preserve existing behavior for queries without variables.
Acceptance criteria
- A
SELECT query containing {database:String} and {table:String} displays two input fields: database and table.
- Running the query sends SQL with the entered values substituted.
- A
VIEW definition containing variables is sent unchanged.
- Queries without variables continue to work as before.
Problem
altinity-sql-browsershould support SQL queries with typed variables, for example:WITH {database:String} AS p_database, {table:String} AS p_table SELECT ...Currently, there is no UI flow for detecting these variables while editing SQL and providing values before execution.
Proposed feature
While the user is typing a SQL query, the app should detect variables in the ClickHouse placeholder format:
{name:Type}For every detected variable, show an input field below the SQL editor header where the user can enter a value.
Example detected variables:
{database:String} {table:String}Should render fields like:
Execution behavior
When the query is executed, the app should substitute the variables with the entered values before sending the SQL to ClickHouse.
Example:
WITH {database:String} AS p_database, {table:String} AS p_table SELECT ...With values:
Should be sent to ClickHouse as:
WITH 'default' AS p_database, 'events' AS p_table SELECT ...Scope
This feature should apply only to
SELECTqueries.It should not apply to
VIEWdefinitions. Views have their own variables, and those variables should not be substituted by the app.Requirements
{name:Type}while editing SQL.SELECTqueries.VIEWdefinitions.Acceptance criteria
SELECTquery containing{database:String}and{table:String}displays two input fields:databaseandtable.VIEWdefinition containing variables is sent unchanged.