metabase-clickhouse-driver icon indicating copy to clipboard operation
metabase-clickhouse-driver copied to clipboard

Substring Broken (1-based versus 0-based)

Open enqueue opened this issue 4 years ago • 0 comments

The substring function does not work as expected for custom fields.

Screenshot_20201215_150412

In Metabase, the indices seem to be 0-based, whereas ClickHouse substring function expects indices to be 1-based:

Character indexing starts from one (as in standard SQL).

From clickhouse-server.err.log:

Indices in strings are 1-based: while executing 'FUNCTION substring(username :: 3, 0 :: 5, 10 :: 6) -> substring(username, 0, 10) String : 7'

Let‘s see what Metabase maintainers agree on in metabase/metabase#12445

enqueue avatar Dec 15 '20 14:12 enqueue