databendlabs/databend · error
can not use connection_name when create connection
Error message
can not use connection_name when create connection
What it means
parse_uri_location builds storage params directly from inline CONNECTION options and a URI, so referencing a named connection (connection_name) is meaningless and disallowed there. If the connection options include connection_name while creating a connection or resolving a URI location, this InvalidInput error is thrown.
Solutions
- Remove CONNECTION_NAME from the inline CONNECTION options in CREATE CONNECTION
- Specify the actual storage options (endpoint_url, credentials, etc.) inline instead
- Use the named connection where allowed (e.g. in stage definitions), not when creating a connection
Example fix
-- before CREATE CONNECTION c CONNECTION=(CONNECTION_NAME='prod_s3'); -- after CREATE CONNECTION c STORAGE_TYPE='s3' ENDPOINT_URL='https://s3.amazonaws.com';
Defensive patterns
Strategy: validation
Validate before calling
if opts.contains_key("connection_name") && is_create_connection_ddl {
return Err("CONNECTION_NAME cannot be used inside CREATE CONNECTION".into());
} Try / catch
match err.kind() { ErrorKind::InvalidInput if msg.contains("can not use connection_name") => /* strip CONNECTION_NAME and inline real options */, _ => return Err(err) } Prevention
- Never nest CONNECTION_NAME inside CREATE CONNECTION
- Use named connections only where supported (stage definitions)
- Generate DDL from templates that exclude connection_name for create-connection paths
When it happens
Trigger: CREATE CONNECTION ... CONNECTION=(CONNECTION_NAME='other') — nesting a connection reference inside connection creation; passing a connection_name option in a stage/connection DDL that resolves URI options inline.
Common situations: Confusing named-connection usage (USE CONNECTION / CONNECTION_NAME on stages) with CREATE CONNECTION DDL; templated SQL that always injects CONNECTION_NAME.
Related errors
- connection_name can not be used with other connection…
- path in URL must end with '/
- input connection is not a valid protocol
- {}
- sync crash me panic
AI-assisted analysis of databendlabs/databend@288d84d76e (2026-09-11).
Data as JSON: /api/errors/af77b7185acbebab.
Report an issue: GitHub.
Appendix: source
Thrown at src/query/sql/src/planner/binder/location.rs:549
ErrorKind::InvalidInput,
anyhow!("protocol {protocol} is not supported yet."),
));
}
Ok(ParsedUriLocation {
root,
path,
protocol,
})
}
pub async fn parse_uri_location(l: &mut UriLocation) -> Result<(StorageParams, String)> {
let parts = parse_uri_location_parts(l)?;
if l.connection.get("connection_name").is_some() {
return Err(Error::new(
ErrorKind::InvalidInput,
anyhow!("can not use connection_name when create connection"),
));
}
parse_uri_location_resolved(l, parts).await
}
pub fn apply_uri_connection(
l: &mut UriLocation,
name: &str,
conn: UserDefinedConnection,
) -> Result<()> {
let protocol = l.protocol.parse::<Scheme>()?;
let proto = conn.storage_type.parse::<Scheme>().map_err(|err| {
Error::new(
ErrorKind::InvalidInput,
anyhow!("input connection is not a valid protocol: {err:?}"),
)
})?;View on GitHub (pinned to 288d84d76e)