Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty arrays in parameterized views #63563

Open
dkarelov opened this issue May 9, 2024 · 3 comments
Open

Empty arrays in parameterized views #63563

dkarelov opened this issue May 9, 2024 · 3 comments

Comments

@dkarelov
Copy link

dkarelov commented May 9, 2024

Cannot pass empty arrays to parameterized views in an obvious way:

CREATE OR REPLACE VIEW test.pview AS SELECT {a:Array(Int32)} = []

SELECT * FROM test.pview(a=[])
produces error:
Code: 456. DB::Exception: Substitution a is not set. (UNKNOWN_QUERY_PARAMETER) (version 23.10.4.25 (official build))

BUT this works as expected:
SELECT * FROM test.pview(a='[]')

@den-crane
Copy link
Contributor

Clickhouse is unable to deduce a type of an empty array. You need to use explicit cast []::Array(Int32)

CREATE OR REPLACE VIEW  pview 
  AS  SELECT {a:Array(Int32)} = []::Array(Int32);

SELECT * FROM  pview(a=[]::Array(Int32))

https://fiddle.clickhouse.com/4940c9a2-3d46-4fcb-b98b-545d2e9ec3ec

23.10 is out of support.

@dkarelov
Copy link
Author

dkarelov commented May 9, 2024

Thanks, it is clear that the issue is with casting - the point is: this is very unobvious and difficult to fix.
Should either be reflected in the docs or implicitly tried to be type-casted to the expected type.

Understood re support - will use fiddle next time, thanks.

@dkarelov dkarelov closed this as completed May 9, 2024
@den-crane
Copy link
Contributor

You can leave it open. It can be improved.

@dkarelov dkarelov reopened this May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants