databendlabs / databend

𝗗𝗮𝘁𝗮, 𝗔𝗻𝗮𝗹𝘆𝘁𝗶𝗰𝘀 & 𝗔𝗜. Modern alternative to Snowflake. Cost-effective and simple for massive-scale analytics. https://databend.com
https://docs.databend.com
Other
7.88k stars 753 forks source link

bug: panic viewing clustering_information with a <8 character cluster key #16763

Closed nickb937 closed 2 weeks ago

nickb937 commented 3 weeks ago

Search before asking

Version

Databend: v1.2.615

What's Wrong?

Panic when viewing the clustering_information after setting the cluster key to a size less than 8 characters

panicked at src/query/expression/src/values.rs:1837:34:
internal error: entered unreachable code: unable to push NULL to String(StringColumnBuilder { need_estimated: true, data: [], offsets: [0, 0] })

e6435026-eb5a-4fe4-a42a-c645c861584c 2024-11-04T18:38:19.370271Z ERROR databend_common_tracing::panic_hook: panic_hook.rs:55 panicked at src/query/expression/src/values.rs:1837:34:
internal error: entered unreachable code: unable to push NULL to String(StringColumnBuilder { need_estimated: true, data: [], offsets: [0, 0] }) backtrace= panic.file=src/query/expression/src/values.rs panic.line=1837 panic.column=34
e6435026-eb5a-4fe4-a42a-c645c861584c 2024-11-04T18:38:19.440486Z ERROR databend_query::servers::mysql::writers::query_result_writer: query_result_writer.rs:223 result row write failed: PanicError. Code: 1104, Text = internal error: entered unreachable code: unable to push NULL to String(StringColumnBuilder { need_estimated: true, data: [], offsets: [0, 0] }).

<Backtrace disabled by default. Please use RUST_BACKTRACE=1 to enable> 

How to Reproduce?

I have a table that I'd like to improve the clustering on. The id field is a UUIDv7 value and looks like this:

> select id from hl7 limit 10;
+--------------------------------------+
| id                                   |
+--------------------------------------+
| 0190f655-2d1c-7490-9e98-642395ba9bb3 |
| 0190f655-2df5-7010-bc65-de7b42316d39 |
| 0190f655-2e10-7dc3-a9f5-7cd800734b0d |
| 0190f655-2e13-7ca0-be26-efd3db6e6955 |
| 0190f655-2e56-7913-920a-c8803a29801a |
| 0190f655-2e87-7183-b068-8f97bdab4afb |
| 0190f655-2ed9-75c3-9826-9cc384d4acad |
| 0190f655-2efb-7291-aaee-0916c2aef2ee |
| 0190f655-2f25-7293-8bec-241703f408a8 |
| 0190f655-2f45-7472-a93f-2422a8372bee |
+--------------------------------------+

The table definition is:

CREATE TABLE hl7 (
  hospital_id BIGINT NULL,
  recv_time TIMESTAMP NOT NULL,
  commit_time TIMESTAMP NULL,
  process_error VARCHAR NULL,
  msg VARCHAR NULL,
  id VARCHAR NOT NULL
) ENGINE=FUSE CLUSTER BY (SUBSTRING(id FROM 1 FOR 8))

If I reduce the id substring from 8 characters, then I receive the following panic:

MySQL [hospital_dev]> alter table hospital_dev.hl7 cluster by (substring(id, 2, 8));
Query OK, 0 rows affected (0.161 sec)

MySQL [hospital_dev]> select * from clustering_information('hospital_dev', 'hl7');
ERROR 1105 (HY000): PanicError. Code: 1104, Text = internal error: entered unreachable code: unable to push NULL to String(StringColumnBuilder { need_estimated: true, data: [], offsets: [0] }).

Are you willing to submit PR?

dantengsky commented 3 weeks ago

@zhyass please take a look