datafuselabs / databend

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

bug: Column count doesn't match value count #7879

Open BohuTANG opened 1 year ago

BohuTANG commented 1 year ago

Summary

Table:

create table t7861(
    c1 VARCHAR NULL,
    c2 VARCHAR NULL,
    c3 VARCHAR NULL,
    c4 VARCHAR NULL,
    c5 VARCHAR NULL,
    c6 VARCHAR NULL,
    c7 VARCHAR NULL,
    c8 BIGINT UNSIGNED NULL,
    c9 BIGINT UNSIGNED NULL,
    c10 VARCHAR NULL,
    c11 VARCHAR NULL,
    c12 VARCHAR NULL,
    c13 VARCHAR NULL,
    c14 VARCHAR NULL,
    c15 VARCHAR NULL,
    c16 VARCHAR NULL,
    c17 VARCHAR NULL,
    c18 VARCHAR NULL,
    c19 VARCHAR NULL,
    c20 VARCHAR NULL,
    c21 VARCHAR NULL,
    c22 OBJECT NULL,
    c23 OBJECT NULL,
    c24 VARCHAR NULL,
    c25 VARCHAR NULL,
    c26 VARCHAR NULL
);

Desc:

mysql> desc t7861;
+-------+-----------------+------+---------+-------+
| Field | Type            | Null | Default | Extra |
+-------+-----------------+------+---------+-------+
| c1    | VARCHAR         | YES  | NULL    |       |
| c2    | VARCHAR         | YES  | NULL    |       |
| c3    | VARCHAR         | YES  | NULL    |       |
| c4    | VARCHAR         | YES  | NULL    |       |
| c5    | VARCHAR         | YES  | NULL    |       |
| c6    | VARCHAR         | YES  | NULL    |       |
| c7    | VARCHAR         | YES  | NULL    |       |
| c8    | BIGINT UNSIGNED | YES  | NULL    |       |
| c9    | BIGINT UNSIGNED | YES  | NULL    |       |
| c10   | VARCHAR         | YES  | NULL    |       |
| c11   | VARCHAR         | YES  | NULL    |       |
| c12   | VARCHAR         | YES  | NULL    |       |
| c13   | VARCHAR         | YES  | NULL    |       |
| c14   | VARCHAR         | YES  | NULL    |       |
| c15   | VARCHAR         | YES  | NULL    |       |
| c16   | VARCHAR         | YES  | NULL    |       |
| c17   | VARCHAR         | YES  | NULL    |       |
| c18   | VARCHAR         | YES  | NULL    |       |
| c19   | VARCHAR         | YES  | NULL    |       |
| c20   | VARCHAR         | YES  | NULL    |       |
| c21   | VARCHAR         | YES  | NULL    |       |
| c22   | OBJECT          | YES  | NULL    |       |
| c23   | OBJECT          | YES  | NULL    |       |
| c24   | VARCHAR         | YES  | NULL    |       |
| c25   | VARCHAR         | YES  | NULL    |       |
| c26   | VARCHAR         | YES  | NULL    |       |
+-------+-----------------+------+---------+-------+
26 rows in set (0.03 sec)

Insert:

INSERT INTO t7861
VALUES     (Rand() AS string, -- c1
            Rand() AS string, -- c2
            Rand() AS string, -- c3
            Rand() AS string, -- c4
            Rand() AS string, -- c5
            Rand() AS string, -- c6
            Rand() AS string, -- c7
            Rand(), -- c8
            Rand(), -- c9
            Rand() AS string, -- c10
            Rand() AS string, -- c11
            Rand() AS string, -- c12
            Rand() AS string, -- c13
            Rand() AS string, -- c14
            Rand() AS string, -- c15
            Rand() AS string, -- c16
            Rand() AS string, -- c17
            Rand() AS string, -- c18
            Rand() AS string, -- c19
            Rand() AS string, -- c20
            Rand() AS string, -- c21
            Parse_json('{"a":1,"b":{"c":2}}'), -- c22
            Parse_json('{"a":1,"b":{"c":2}}'), -- c23
            Rand() AS string, -- c24
            Rand() AS string, -- c25
            Rand() AS string  -- c26
           ); 

Error:

ERROR 1105 (HY000): Code: 1015, displayText = Column count doesn't match value count (while in processor thread 0).

But my column count is equal value count, 26.

sundy-li commented 1 year ago

use rand()::String instead

BohuTANG commented 1 year ago

use rand()::String instead

It works, the error hint is not right :)

sundy-li commented 2 weeks ago

@andylokandy

parse_fallback should parse the sql with allow_partial = false mode, and then need add error span in

 Err(ParseError(
                    transform_span(&rest[..1]),
                    "unable to parse rest of the sql".to_string(),
                ))