mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-06 00:02:13 +00:00
fix: allow SQL args in managed // materialize scripts (#9733)
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
6d94865109
commit
fa3596885b
@@ -1284,28 +1284,10 @@ async fn create_script_internal<'c>(
|
||||
if let Err(e) = windmill_parser::sql_materialize::classify_wrap(&ns.content) {
|
||||
return Err(Error::BadRequest(e.message()));
|
||||
}
|
||||
// Managed materialize strips line comments when it wraps the SELECT,
|
||||
// so a `-- $name (TYPE)` declaration is lost while its `$name`
|
||||
// reference survives in the embedded SELECT — it would run unbound.
|
||||
// Managed materialize takes no SQL args (the partition is supplied by
|
||||
// the engine, not bound). Reject declared args with a clear error.
|
||||
if let Ok(sig) = windmill_parser_sql::parse_duckdb_sig(&ns.content) {
|
||||
if !sig.args.is_empty() {
|
||||
let names = sig
|
||||
.args
|
||||
.iter()
|
||||
.map(|a| format!("${}", a.name))
|
||||
.collect::<Vec<_>>()
|
||||
.join(", ");
|
||||
return Err(Error::BadRequest(format!(
|
||||
"managed `// materialize` cannot take SQL arguments ({names}): wrapping your \
|
||||
SELECT drops the `-- $arg` declarations, so they would run unbound. The \
|
||||
partition is supplied by the engine — reference its value with the \
|
||||
`{{partition}}` token, or use `// materialize manual` to write the DDL (and \
|
||||
bind args) yourself."
|
||||
)));
|
||||
}
|
||||
}
|
||||
// SQL args are supported: managed materialize strips line comments
|
||||
// (including `-- $name (type)` declarations) when it wraps the SELECT,
|
||||
// but the executor parses the signature from the un-wrapped script, so
|
||||
// `$name` references in the SELECT stay bound at run time.
|
||||
}
|
||||
// `key=` (merge) and `append` are mutually exclusive reconciliation
|
||||
// strategies; append (INSERT-only) wins. Surface the conflict rather
|
||||
|
||||
Reference in New Issue
Block a user