starrocks icon indicating copy to clipboard operation
starrocks copied to clipboard

ARRAY<VARCHAR(n)> array elements have limits counter to what is defined

Open digitalpoetry opened this issue 1 year ago • 2 comments

Steps to reproduce the behavior (Required)

CREATE TABLE array_field (
    id BIGINT NOT NULL AUTO_INCREMENT,
    a ARRAY<VARCHAR(10)> COMMENT 'An array field of VARCHAR(10) elements'
);

INSERT INTO array_field (a) VALUES (["1234567890"]);
-- Query OK, as expected

INSERT INTO array_field (a) VALUES (["12345678901234"]);
-- Query OK, not expected because the string length is 14

INSERT INTO array_field (a) VALUES (["123456789012345"]);
-- ERROR 1064 (HY000): starrocks.svc.cluster.local: string length(15) > limit(14), string: 123456789012345

Expected behavior (Required)

I expect the elements of the array to be of type VARCHAR(10). An error is expected when elements of length >10 are attempted to be inserted.

Real behavior (Required)

Elements with lengths up to 14 can be inserted. The error message where strings of length >14 also seem to imply that the element limit is 14.

StarRocks version (Required)

3.2.3-a40e2f8

digitalpoetry avatar May 17 '24 06:05 digitalpoetry

Hi, what your mean is we should optimize this error message?

kangkaisen avatar May 17 '24 10:05 kangkaisen

The array element type is VARCHAR(10). I assume 10 is 10 bytes as per this do (https://docs.starrocks.io/docs/faq/Others/#is-the-length-of-string-defined-by-mysql-the-same-as-that-defined-by-starrocks). Can you please confirm the units here? I wouldn’t expect 10 bytes to fit 14 characters though.

digitalpoetry avatar May 18 '24 06:05 digitalpoetry

We have marked this issue as stale because it has been inactive for 6 months. If this issue is still relevant, removing the stale label or adding a comment will keep it active. Otherwise, we'll close it in 10 days to keep the issue queue tidy. Thank you for your contribution to StarRocks!

github-actions[bot] avatar Nov 18 '24 11:11 github-actions[bot]

This behaviour remains in SR 3.3.4.

For type VARCHAR(N), it is unclear to me what the units for N is.

digitalpoetry avatar Nov 19 '24 04:11 digitalpoetry