{"record":{"id":"73d91103a12969e4","repo":"databendlabs/databend","slug":"name-node-in-uri-n2-and-from-connection-option","errorCode":null,"errorMessage":"name_node in uri({n2}) and from connection option 'name_node'({n1}) not match.","messagePattern":"name_node in uri\\((.+?)\\) and from connection option 'name_node'\\((.+?)\\) not match\\.","errorType":"validation","errorClass":"InvalidInput","httpStatus":null,"severity":"error","filePath":"src/query/sql/src/planner/binder/location.rs","lineNumber":375,"sourceCode":"}\n\n/// Generally, the URI is in the pattern hdfs://<namenode>/<path>.\n/// If <namenode> is empty (i.e. `hdfs:///<path>`),  use <namenode> configured somewhere else, e.g. in XML config file.\n/// For databend user can specify <namenode> in connection options.\n/// refer to https://www.vertica.com/docs/9.3.x/HTML/Content/Authoring/HadoopIntegrationGuide/libhdfs/HdfsURL.htm\n#[cfg(feature = \"storage-hdfs\")]\nfn parse_hdfs_params(l: &mut UriLocation, root: String) -> Result<StorageParams> {\n    let name_node_from_uri = if l.name.is_empty() {\n        None\n    } else {\n        Some(format!(\"hdfs://{}\", l.name))\n    };\n    let name_node_option = l.connection.get(\"name_node\");\n\n    let name_node = match (name_node_option, name_node_from_uri) {\n        (Some(n1), Some(n2)) => {\n            if n1 != &n2 {\n                return Err(Error::new(\n                    ErrorKind::InvalidInput,\n                    format!(\n                        \"name_node in uri({n2}) and from connection option 'name_node'({n1}) not match.\"\n                    ),\n                ));\n            } else {\n                n2\n            }\n        }\n        (Some(n1), None) => n1.to_string(),\n        (None, Some(n2)) => n2,\n        (None, None) => {\n            // we prefer user to specify name_node in options\n            return Err(Error::new(\n                ErrorKind::InvalidInput,\n                \"name_node is required for storage hdfs\",\n            ));\n        }","sourceCodeStart":357,"sourceCodeEnd":393,"githubUrl":"https://github.com/databendlabs/databend/blob/288d84d76e20a2f8f7173bda9691eb6ece301aa9/src/query/sql/src/planner/binder/location.rs#L357-L393","documentation":"When binding a location URI with the hdfs:// scheme, Databend parses the name node from the URI and also accepts a 'name_node' connection option. If both are present and their values differ, parse_hdfs_params rejects the statement because it cannot decide which name node is authoritative. This prevents silently reading from a different HDFS cluster than the one the user configured.","triggerScenarios":"Executing CREATE STAGE / location-based COPY with a URI like 'hdfs://nn1:8020/path' while the connection options also include name_node='nn2:8020' (any mismatched value, including differing port or host spelling).","commonSituations":"Copy-pasting a stage definition where the URI was updated but the options block still holds an old name_node; templated configs substituting different cluster hosts into URI and options; trailing-slash or port differences that make the strings unequal though they point at the same cluster.","solutions":["Make the name_node value in the connection options exactly match the host:port in the hdfs:// URI (string equality is required).","Remove the redundant 'name_node' connection option and rely solely on the URI.","Remove the host:port from the URI and specify it only via the name_node option.","Check for case, whitespace, or default-port differences (e.g. hdfs://nn:8020/ vs hdfs://nn/) that make values differ."],"exampleFix":"// before\nCREATE STAGE s URL = 'hdfs://nn1:8020/data/' CONNECTION = (name_node = 'nn2:8020');\n// after\nCREATE STAGE s URL = 'hdfs://nn1:8020/data/' CONNECTION = (name_node = 'nn1:8020');","handlingStrategy":"validation","validationCode":"// Rust\nif let (Some(opt), Some(uri_nn)) = (conn_opts.get(\"name_node\"), uri_host_port) {\n    assert_eq!(opt, &uri_nn, \"name_node option must match hdfs URI authority\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Specify name_node in exactly one place — prefer the URI authority only.","Use a single template variable for the cluster address in both URI and options.","Double-check port and spelling when copying stage definitions."],"tags":["storage","hdfs","config-validation","uri-parsing"],"backgroundTag":"conflicting-config-options","analyzedSha":"288d84d76e20a2f8f7173bda9691eb6ece301aa9","analyzedAt":"2026-09-11T11:29:36.208Z","contentChangedAt":"2026-09-11T11:29:36.208Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}