From 19f5e3a79108c3cde53cc9306f5c765f447319e0 Mon Sep 17 00:00:00 2001 From: hari2353 <125888547+hari2353@users.noreply.github.com> Date: Wed, 11 Nov 2026 00:52:56 +0530 Subject: [PATCH 1/5] fix: #1419 UNWIND of a scalar property (undeclared type) wraps in array --- src/bound_plan/lower/tests.rs | 2 +- src/sql_generator/function_mapper/clickhouse.rs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/bound_plan/lower/tests.rs b/src/bound_plan/lower/tests.rs index 934f33860..ee3ba60c2 100644 --- a/src/bound_plan/lower/tests.rs +++ b/src/bound_plan/lower/tests.rs @@ -5442,7 +5442,7 @@ fn an_unwind_of_what_is_not_a_list() { ); has( "MATCH (a:User) UNWIND a.name AS x RETURN x", - &["ARRAY JOIN arrayConcat(v0.full_name) AS __cg_element"], + &["ARRAY JOIN if(isArray(v0.full_name), v0.full_name, if(isNull(v0.full_name), [], [v0.full_name])) AS __cg_element"], ); let schema = GraphSchemaConfig::from_yaml_str( r#" diff --git a/src/sql_generator/function_mapper/clickhouse.rs b/src/sql_generator/function_mapper/clickhouse.rs index b21aa0689..d9b02852f 100644 --- a/src/sql_generator/function_mapper/clickhouse.rs +++ b/src/sql_generator/function_mapper/clickhouse.rs @@ -275,7 +275,9 @@ impl FunctionMapper for ClickhouseFunctionMapper { one_row: "system.one", // An identity of arrays that refuses a map, which `ARRAY JOIN` // reads as a list of its entries. - list_only: |list| format!("arrayConcat({list})"), + list_only: |list| { + format!("if(isArray({list}), {list}, if(isNull({list}), [], [{list}]))") + }, row_number: |keys| format!("row_number() OVER (ORDER BY {keys})"), any_row_number: "row_number() OVER ()", is_null: |v| format!("isNull({v})"), From f0633220fbf5ab2fe481e02d6b275934a361711c Mon Sep 17 00:00:00 2001 From: hari2353 <125888547+hari2353@users.noreply.github.com> Date: Sun, 15 Nov 2026 10:20:54 +0530 Subject: [PATCH 2/5] fix: #1419 UNWIND of an undeclared scalar property wraps in a one-element list (schema-driven, T1) --- src/bound_plan/lower/tests.rs | 41 ++++++++++++++++++++++++++++++++++ src/bound_plan/lower/unwind.rs | 17 ++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/src/bound_plan/lower/tests.rs b/src/bound_plan/lower/tests.rs index ee3ba60c2..7207c1d58 100644 --- a/src/bound_plan/lower/tests.rs +++ b/src/bound_plan/lower/tests.rs @@ -5366,6 +5366,47 @@ fn an_unwind_repeats_each_row_per_element() { ); } +#[test] +fn an_undeclared_scalar_property_unwinds_as_a_one_element_list_1419() { + // #1419: an undeclared property (no `property_types`) whose column is a + // known scalar must not be read as a list (arrayConcat fails on a scalar). + // It is wrapped in a one-element list instead, matching Neo4j's "UNWIND of + // a non-list value gives one row of itself". The column type is supplied + // via `column_types` (T1), since unit tests have no live database. + let schema = GraphSchemaConfig::from_yaml_str( + r#" +name: t +graph_schema: + nodes: + - label: User + database: db + table: users + node_id: user_id + property_mappings: { user_id: user_id, name: full_name } + column_types: { user_id: UInt64, full_name: String } + edges: [] +"#, + ) + .unwrap() + .to_graph_schema() + .unwrap(); + let got = translate_bound_plan( + "MATCH (u:User) UNWIND u.name AS x RETURN x", + &schema, + &ReadOptions::default(), + ) + .unwrap() + .sql; + assert!( + got.contains("if(isNull(v0.full_name), [], [v0.full_name])"), + "expected value_list wrap, got: {got}" + ); + assert!( + !got.contains("arrayConcat"), + "must not use arrayConcat, got: {got}" + ); +} + /// S7c: rows in an order keep it, each row's elements after it in list /// order: the rows are numbered first. #[test] diff --git a/src/bound_plan/lower/unwind.rs b/src/bound_plan/lower/unwind.rs index 56ac16351..973657f1a 100644 --- a/src/bound_plan/lower/unwind.rs +++ b/src/bound_plan/lower/unwind.rs @@ -483,6 +483,23 @@ impl<'s> Lowerer<'s> { fn property_kind(&self, v: VarId, p: &str) -> Kind { match self.declared_types(v, p).as_slice() { [] => Kind::Unknown, + ts if ts.iter().all(Option::is_none) => { + let list = self.column_list_kind(v, p); + if matches!(list, Kind::List(_)) { + return list; + } + if self.no_column_kinds.get() { + return Kind::Unknown; + } + let columns = self.property_columns(v, p); + if !columns.is_empty() + && columns.iter().all(Option::is_some) + && columns.iter().all(|c| c.unwrap().array_element().is_none()) + { + return Kind::Scalar; + } + Kind::Unknown + } ts if ts.iter().all(|t| t == &Some(&SchemaType::Boolean)) => Kind::Boolean, ts if ts.iter().all(Option::is_some) => Kind::Scalar, _ => self.column_list_kind(v, p), From 28e5c4c9a66376ecf8ac2a31d3034fee2ff921bb Mon Sep 17 00:00:00 2001 From: hari2353 <125888547+hari2353@users.noreply.github.com> Date: Sun, 15 Nov 2026 10:21:35 +0530 Subject: [PATCH 3/5] test: revert UNWIND assertion to arrayConcat (schema-driven fix no longer emits isArray) --- src/bound_plan/lower/tests.rs | 2 +- src/sql_generator/function_mapper/clickhouse.rs | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/bound_plan/lower/tests.rs b/src/bound_plan/lower/tests.rs index 7207c1d58..49dc11f67 100644 --- a/src/bound_plan/lower/tests.rs +++ b/src/bound_plan/lower/tests.rs @@ -5483,7 +5483,7 @@ fn an_unwind_of_what_is_not_a_list() { ); has( "MATCH (a:User) UNWIND a.name AS x RETURN x", - &["ARRAY JOIN if(isArray(v0.full_name), v0.full_name, if(isNull(v0.full_name), [], [v0.full_name])) AS __cg_element"], + &["ARRAY JOIN arrayConcat(v0.full_name) AS __cg_element"], ); let schema = GraphSchemaConfig::from_yaml_str( r#" diff --git a/src/sql_generator/function_mapper/clickhouse.rs b/src/sql_generator/function_mapper/clickhouse.rs index d9b02852f..b21aa0689 100644 --- a/src/sql_generator/function_mapper/clickhouse.rs +++ b/src/sql_generator/function_mapper/clickhouse.rs @@ -275,9 +275,7 @@ impl FunctionMapper for ClickhouseFunctionMapper { one_row: "system.one", // An identity of arrays that refuses a map, which `ARRAY JOIN` // reads as a list of its entries. - list_only: |list| { - format!("if(isArray({list}), {list}, if(isNull({list}), [], [{list}]))") - }, + list_only: |list| format!("arrayConcat({list})"), row_number: |keys| format!("row_number() OVER (ORDER BY {keys})"), any_row_number: "row_number() OVER ()", is_null: |v| format!("isNull({v})"), From 10f3cd7f1c1ccaf71773c97453c35aa85fb9e25c Mon Sep 17 00:00:00 2001 From: hari2353 <125888547+hari2353@users.noreply.github.com> Date: Sun, 15 Nov 2026 11:40:02 +0530 Subject: [PATCH 4/5] chore: bump quinn-udp/rustix (RUSTSEC-2026-0538/-0486), drop stale osv ignore --- Cargo.lock | 26 +++++++++++++------------- osv-scanner.toml | 4 ---- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fdb729d2f..c6388522f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1035,7 +1035,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.61.2", + "windows-sys 0.59.0", ] [[package]] @@ -1583,7 +1583,7 @@ dependencies = [ "libc", "percent-encoding", "pin-project-lite", - "socket2 0.6.5", + "socket2 0.5.10", "tokio", "tower-service", "tracing", @@ -1898,9 +1898,9 @@ checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" [[package]] name = "linux-raw-sys" -version = "0.11.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" [[package]] name = "litemap" @@ -2378,7 +2378,7 @@ dependencies = [ "quinn-udp", "rustc-hash 2.1.1", "rustls", - "socket2 0.6.5", + "socket2 0.5.10", "thiserror 2.0.17", "tokio", "tracing", @@ -2409,14 +2409,14 @@ dependencies = [ [[package]] name = "quinn-udp" -version = "0.5.14" +version = "0.5.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "addec6a0dcad8a8d96a771f815f0eaf55f9d1805756410b39f5fa81332574cbd" +checksum = "af66907df18639dcf4db56ca65490cabc4b27a97dbadd96f2926cca73298f016" dependencies = [ "cfg_aliases", "libc", "once_cell", - "socket2 0.6.5", + "socket2 0.5.10", "tracing", "windows-sys 0.59.0", ] @@ -2704,15 +2704,15 @@ checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" [[package]] name = "rustix" -version = "1.1.2" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd15f8a2c5551a84d56efdc1cd049089e409ac19a3072d5037a17fd70719ff3e" +checksum = "e5e76742e5294153d4dde1207dbec5bdd81eef6fabdc0d2118babadabfd858aa" dependencies = [ "bitflags 2.10.0", "errno", "libc", "linux-raw-sys", - "windows-sys 0.61.2", + "windows-sys 0.59.0", ] [[package]] @@ -3263,7 +3263,7 @@ dependencies = [ "getrandom 0.3.4", "once_cell", "rustix", - "windows-sys 0.61.2", + "windows-sys 0.59.0", ] [[package]] @@ -4061,7 +4061,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.61.2", + "windows-sys 0.48.0", ] [[package]] diff --git a/osv-scanner.toml b/osv-scanner.toml index 3425a3fc9..d41952e19 100644 --- a/osv-scanner.toml +++ b/osv-scanner.toml @@ -5,10 +5,6 @@ # `h2` row is the one "fixable" version the scanner sees: the fix is the # `chdb-rust` 2.0.0 slice (its own follow-up, API-compat work), not a pin # this branch can take. -[[IgnoredVulns]] -id = "GHSA-qwgh-2vcv-g2f7" -reason = "block-buffer 0.10.4 (Medium 6.3): no fixed version is published; consumers are sha2 (compile-time digests) and the SHA-1 inside tokio-tungstenite 0.21's wire paths. Revisit the row when a fix lands upstream." - [[IgnoredVulns]] id = "RUSTSEC-2026-0374" reason = "basic-toml 0.1.10 is unmaintained: compile-time-only, pulled by askama_derive (template codegen); no runtime artifact, not a security vulnerability. Retires with askama's own upgrade." From 8a5b27cc6e5ca53cc8fadbd6fef542fc773c95b6 Mon Sep 17 00:00:00 2001 From: genezhang Date: Sun, 15 Nov 2026 10:14:04 -0800 Subject: [PATCH 5/5] fix: #1419 read a column's plain-value kind in UNWIND only, from column_kind Maintainer follow-up on the contributor's change. Reading every non-Array column as `Kind::Scalar` in `property_kind` had two defects, found live on ClickHouse 26.7 / 25.8: - A `SimpleAggregateFunction(anyLast, Array(Int64))` column unwound element by element on main; it was wrapped (one row holding the whole list). A `Variant(Array(..), ..)` / `Dynamic` column that can hold a list would be wrapped the same way (main: a loud error). - `property_kind` feeds `kind()` for every consumer (`+` of a list and a value, `is_never_boolean`, ...); `column_list_kind` documents that a scalar column's kind elsewhere is a later slice's. Now `property_kind` is as on main, and `UNWIND` alone asks `unwind_kind`: the kind from `column_kind`'s `Scalar` / `Boolean` (the existing whitelist of known plain types) when the property's column in every label / type is one. Map, Tuple, Dynamic, Variant, JSON and aggregate-function columns stay `Unknown`. Tests: one per side (plain columns are wrapped, columns that can hold a list are not) and a property that is a list in one label. The first fails on the contributor's head. Co-Authored-By: Claude Sonnet 5.5 Fleet-Machine: bronco Fleet-Agent: cca-09ce867920932e58 --- src/bound_plan/lower/tests.rs | 105 +++++++++++++++++++++++++++++++++ src/bound_plan/lower/unwind.rs | 62 +++++++++++++------ 2 files changed, 149 insertions(+), 18 deletions(-) diff --git a/src/bound_plan/lower/tests.rs b/src/bound_plan/lower/tests.rs index 49dc11f67..c16605633 100644 --- a/src/bound_plan/lower/tests.rs +++ b/src/bound_plan/lower/tests.rs @@ -5407,6 +5407,111 @@ graph_schema: ); } +/// #1419: `UNWIND` of an undeclared property spreads a column that can hold +/// a list (`Array`, `SimpleAggregateFunction(…, Array(…))`, `Dynamic`, +/// `Variant`) as it did, and wraps only a column known to be a plain value. +/// A wrapped list would be one row holding the list, not its elements. +#[test] +fn an_unwind_wraps_only_a_column_known_to_be_a_plain_value_1419() { + // `UNWIND t.v` over one label whose `v` is a column of type `ty`. + let unwind_of = |ty: &str| { + let yaml = format!( + r#" +name: t +graph_schema: + nodes: + - label: T + database: db + table: t + node_id: id + property_mappings: {{ id: id, v: v }} + column_types: {{ id: UInt64, v: "{ty}" }} + edges: [] +"# + ); + let schema = GraphSchemaConfig::from_yaml_str(&yaml) + .unwrap() + .to_graph_schema() + .unwrap(); + squash( + &translate_bound_plan( + "MATCH (t:T) UNWIND t.v AS x RETURN x", + &schema, + &ReadOptions::default(), + ) + .unwrap() + .sql, + ) + }; + // A plain value: one row of itself (none for NULL). + for ty in [ + "String", + "UInt64", + "Nullable(Int32)", + "Date", + "LowCardinality(String)", + ] { + let got = unwind_of(ty); + assert!(got.contains("if(isNull(v0.v), [], [v0.v])"), "{ty}: {got}"); + assert!(!got.contains("arrayConcat"), "{ty}: {got}"); + } + // A list: spread element by element. + let got = unwind_of("Array(String)"); + assert!(got.contains("ARRAY JOIN v0.v AS __cg_element"), "{got}"); + assert!(!got.contains("if(isNull("), "{got}"); + // A column that can hold a list, not known to be a value: as before. + for ty in [ + "SimpleAggregateFunction(anyLast, Array(Int64))", + "Dynamic", + "Variant(Array(Int64), String)", + "Map(String, Int64)", + ] { + let got = unwind_of(ty); + assert!(got.contains("arrayConcat(v0.v)"), "{ty}: {got}"); + assert!(!got.contains("[v0.v])"), "{ty}: {got}"); + } +} + +/// #1419: a property held as a list by one label and as a value by another +/// is not known to be a value: `UNWIND` spreads it as before. +#[test] +fn an_unwind_of_a_property_that_is_a_list_in_one_label_is_not_wrapped_1419() { + let schema = GraphSchemaConfig::from_yaml_str( + r#" +name: t +graph_schema: + nodes: + - label: A + database: db + table: a + node_id: id + property_mappings: { id: id, v: v } + column_types: { id: UInt64, v: String } + - label: B + database: db + table: b + node_id: id + property_mappings: { id: id, v: v } + column_types: { id: UInt64, v: "Array(String)" } + edges: [] +"#, + ) + .unwrap() + .to_graph_schema() + .unwrap(); + let got = squash( + &translate_bound_plan( + "MATCH (n) UNWIND n.v AS x RETURN x", + &schema, + &ReadOptions::default(), + ) + .unwrap() + .sql, + ); + assert!(got.contains("arrayConcat("), "{got}"); + assert!(!got.contains("if(isNull("), "{got}"); +} + /// S7c: rows in an order keep it, each row's elements after it in list /// order: the rows are numbered first. #[test] diff --git a/src/bound_plan/lower/unwind.rs b/src/bound_plan/lower/unwind.rs index 973657f1a..7007a3941 100644 --- a/src/bound_plan/lower/unwind.rs +++ b/src/bound_plan/lower/unwind.rs @@ -483,29 +483,55 @@ impl<'s> Lowerer<'s> { fn property_kind(&self, v: VarId, p: &str) -> Kind { match self.declared_types(v, p).as_slice() { [] => Kind::Unknown, - ts if ts.iter().all(Option::is_none) => { - let list = self.column_list_kind(v, p); - if matches!(list, Kind::List(_)) { - return list; - } - if self.no_column_kinds.get() { - return Kind::Unknown; - } - let columns = self.property_columns(v, p); - if !columns.is_empty() - && columns.iter().all(Option::is_some) - && columns.iter().all(|c| c.unwrap().array_element().is_none()) - { - return Kind::Scalar; - } - Kind::Unknown - } ts if ts.iter().all(|t| t == &Some(&SchemaType::Boolean)) => Kind::Boolean, ts if ts.iter().all(Option::is_some) => Kind::Scalar, _ => self.column_list_kind(v, p), } } + /// What `UNWIND e` spreads (#1419): `kind(e)`, and, where that is `Unknown`, + /// the kind of a property whose column is a plain value in every label / + /// type (`plain_column_kind`). Read by `UNWIND` only: a scalar column's + /// kind anywhere else is a later slice's (`column_list_kind`). + fn unwind_kind(&self, e: &LogicalExpr) -> Kind { + match self.kind(e) { + Kind::Unknown => self.plain_column_kind(e).unwrap_or(Kind::Unknown), + k => k, + } + } + + /// A property not declared typed (so its kind is read from its columns) + /// whose column in every label / type is a value of one plain type (a + /// number, text, date, `Bool`...: `column_kind`'s `Scalar` / `Boolean`): + /// that kind. `None` for anything `column_kind` does not know to be one + /// (an `Array`, and a `Dynamic` / `Variant` / `JSON` / aggregate-function + /// column, which can hold one), or when a column type is not known. + fn plain_column_kind(&self, e: &LogicalExpr) -> Option { + if self.no_column_kinds.get() { + return None; + } + let LogicalExpr::PropertyAccessExp(pa) = e else { + return None; + }; + let PropertyValue::Column(p) = &pa.column else { + return None; + }; + let v = parse_var(&pa.table_alias.0)?; + let kinds: Vec = self + .property_columns(v, p) + .into_iter() + .map(|t| t.map(column_kind)) + .collect::>()?; + if kinds.is_empty() + || !kinds + .iter() + .all(|k| matches!(k, Kind::Scalar | Kind::Boolean)) + { + return None; + } + kinds.into_iter().reduce(Kind::either) + } + /// The kind of `e` with properties' column types left unread: what a /// check written before they were read (T2a) decides on. pub(super) fn kind_before_column_types(&self, e: &LogicalExpr) -> Kind { @@ -739,7 +765,7 @@ impl<'s> Lowerer<'s> { let Some(spelling) = current_function_mapper().unwind() else { return unsupported("UNWIND in this SQL dialect"); }; - let kind = self.kind(expr); + let kind = self.unwind_kind(expr); let before = self.kind_before_column_types(expr).element(); self.set_kind(var, kind.element(), before); // A list of no elements, or NULL: no rows.