Skip to content

Crash query with topK() on 25.3 Clickhouse version #250

@dbegunkov

Description

@dbegunkov

Hi! I have problem with use next query (for example):

from a in table_database.table_name,
        select: %{column: fragment("topK(?)(?.?)", ^limit, a, literal(^attribute.name))}

The error is

(Ch.Error) Code: 70. DB::Exception: Conversion from AggregateFunction(topK(50), Int32) to AggregateFunction(topK(50), Int32) is not supported: While executing Remote. (CANNOT_CONVERT_TYPE) (version 25.3.3.42 (official build))\n\n    (ecto_sql 3.12.1) lib/ecto/adapters/sql.ex:1096: Ecto.Adapters.SQL.raise_sql_call_error/1\n    (ecto_ch 0.6.1) lib/ecto/adapters/clickhouse.ex:323: Ecto.Adapters.ClickHouse.execute/5\n    (ecto 3.12.5) lib/ecto/repo/queryable.ex:232: Ecto.Repo.Queryable.execute/4\n    (ecto 3.12.5) lib/ecto/repo/queryable.ex:19: Ecto.Repo.Queryable.all/3...

With Clickhosuse version 24.3 and early this query worked sucessfull.

Important: the query without parameterized limit runs successful on all version Clickhouse, include 25.3.

from a in table_database.table_name,
        select: %{column: fragment("topK(50)(?.?)",  a, literal(^attribute.name))}

I think, the problem is that crashed query translates to follow sql

(select  topK({$0:Int64})(e0."field1")  FROM "table1" AS e0) [50]

and more specifically problem is in :Int64 type casting

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions