Skip to content

fix: #1419 UNWIND of a scalar property (undeclared type) wraps in array - #1565

Open
hari2353 wants to merge 1 commit into
genezhang:mainfrom
hari2353:fix/1419-unwind-scalar
Open

hari2353 wants to merge 1 commit into
genezhang:mainfrom
hari2353:fix/1419-unwind-scalar

Conversation

@hari2353

Copy link
Copy Markdown

list_only on ClickHouse now wraps a non-array value in an array instead of calling arrayConcat (which fails on strings). Fixes UNWIND of a property with undeclared type.

@genezhang genezhang left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking #1419. The generated SQL calls a function that ClickHouse does not have, so the query still fails.

Repro (db_standard, ClickHouse 26.7.1 and 25.8.33):

MATCH (u:User) UNWIND u.name AS x RETURN x ORDER BY x
-- main: Code 43  "Argument 0 for function arrayConcat must be an array but it has type String"
-- PR:   Code 46  "Function with name `isArray` does not exist"

SELECT isArray([1]) gives Code 46 on both versions. The same happens for UNWIND u.user_id. The lowering test was edited to expect the new SQL text, so it passes without the query ever being run.

Beyond the missing function

  • ClickHouse is statically typed, and if(cond, x, [x]) needs x and [x] to have a common type. Even with a real predicate, a column that is a String in one branch and an Array(String) in the other cannot be chosen between at run time. The decision has to come from what is known at lowering time. The typed path already does this: for a declared integer property the test above expects if(isNull(v0.age), [], [v0.age]).
  • The old comment on list_only says it is "an identity of arrays that refuses a map". The new spelling would wrap a map in a one-element list, which changes behaviour and is not discussed.
  • The column expression is repeated four times in the SQL, so a non-deterministic one such as rand() could take different values in each place.

A real fix probably needs the property's type from the schema's column_types (T1) rather than a runtime test. I'd suggest running the query against a ClickHouse container before updating a test expectation to match new SQL.

Happy to re-review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants