-
Notifications
You must be signed in to change notification settings - Fork 837
feat: add support for contextual vars in SQL #6791
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Claude finished @hugocasa's task —— View job Comprehensive PR ReviewI've completed my review of PR #6791 that adds support for contextual variables in SQL. This is a well-implemented feature that extends Windmill's contextual variable system to all SQL database executors. Todo List
Review SummaryOverall Assessment: ✅ APPROVED - This is a clean, well-implemented feature that follows established patterns and maintains security best practices. Code Quality & ImplementationStrengths:
Implementation Details:
Security Analysis✅ No Security Issues Found
Performance Considerations✅ Minimal Performance Impact
Potential Issues & SuggestionsMinor Issues:
Suggestions for Future Enhancement:
Testing InstructionsTo verify the contextual variable functionality in SQL scripts: Setup: Navigate to the Windmill script editor and create a new SQL script (PostgreSQL, MySQL, BigQuery, MSSQL, Oracle, Snowflake, or DuckDB). Testing Process:
Expected Behavior: The This implementation successfully extends Windmill's contextual variable system to SQL scripts while maintaining security, performance, and code quality standards. The feature follows established patterns and provides a consistent user experience across all supported SQL database types. |
Deploying windmill with
|
| Latest commit: |
da64ecc
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://ec98cb0b.windmill.pages.dev |
| Branch Preview URL: | https://hc-sql-contextual-vars.windmill.pages.dev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Important
Looks good to me! 👍
Reviewed everything up to da64ecc in 3 minutes and 12 seconds. Click for details.
- Reviewed
462lines of code in10files - Skipped
0files when reviewing. - Skipped posting
3draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. backend/windmill-worker/src/sanitized_sql_params.rs:36
- Draft comment:
In thereplace_contextual_variablesfunction, you loop over each unique token and usecode.replaceto update the SQL string. While this works, note that repeatedly replacing the entire string may be inefficient for large SQL statements. Also, consider logging a warning or handling the case where a contextual variable token appears but no value is provided in thecontextual_variablesmap. - Reason this comment was not posted:
Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 20% vs. threshold = 50% The performance concern about string.replace() is speculative - we don't know if SQL statements will be large or if this will cause performance issues. The suggestion about logging missing variables is a feature request rather than a clear bug. Neither point identifies a definite issue that needs fixing. The performance suggestion could be valid if we knew more about typical SQL statement sizes. Missing variable logging could help with debugging. Without evidence that the performance is actually problematic or that missing variable logging is a requirement, these suggestions are speculative nice-to-haves rather than clear issues. The comment should be removed as it makes speculative suggestions without clear evidence of problems that need fixing.
2. frontend/src/lib/components/EditorBar.svelte:452
- Draft comment:
For SQL languages (e.g. postgresql, mysql, etc.), the code inserts tokens as%%${name}%%but the backend regex expects tokens beginning with%%WM_. This mismatch may prevent contextual variable replacement. Please verify if the intended format for contextual variables should include a 'WM_' prefix or update the regex accordingly. - Reason this comment was not posted:
Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 0% vs. threshold = 50% The comment makes a specific claim about backend regex expectations but provides no evidence. Without seeing the backend code, we can't verify if there truly is a mismatch. The comment is speculative - "may prevent" suggests uncertainty. The suggestion to add "WM_" prefix is not clearly justified. I could be wrong if there is a well-known convention in the codebase for SQL variable tokens to use WM_ prefix. The backend could have strict requirements I'm unaware of. Even if there is a convention, the comment should provide evidence. Making assumptions about backend requirements without proof violates the rule about needing strong evidence. Delete this comment because it makes speculative claims about backend requirements without evidence. If there is a real mismatch, it should be documented with proof.
3. frontend/src/lib/components/EditorBar.svelte:418
- Draft comment:
The conditional logic for inserting contextual variables in various languages is implemented with multiple if/else blocks. Consider refactoring this logic to use a mapping or helper function to reduce duplication and improve maintainability. - Reason this comment was not posted:
Comment was not on a location in the diff, so it can't be submitted as a review comment.
Workflow ID: wflow_UMXQijXHUUBDgmfn
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
Important
Add support for contextual variables in SQL queries across multiple executors and update the frontend to support these changes.
bigquery_executor.rs,duckdb_executor.rs,mssql_executor.rs,mysql_executor.rs,oracledb_executor.rs,pg_executor.rs,snowflake_executor.rs).sanitize_and_interpolate_unsafe_sql_argsinsanitized_sql_params.rsto handle contextual variables.replace_contextual_variables()insanitized_sql_params.rsto replace contextual variables in SQL queries.EditorBar.svelteto support contextual variable insertion for SQL languages (e.g.,postgresql,mysql,bigquery).This description was created by
for da64ecc. You can customize this summary. It will automatically update as commits are pushed.