matrixorigin / matrixone

Hyperconverged cloud-edge native database
https://docs.matrixorigin.cn/en
Apache License 2.0
1.79k stars 276 forks source link

[Bug]: When using load data inline to import data, errors may occur if there are semicolons in the data #16790

Closed gaoy121 closed 1 month ago

gaoy121 commented 5 months ago

Is there an existing issue for the same bug?

Branch Name

v1.2.0

Commit ID

5522522

Other Environment Information

- Hardware parameters:
- OS type: Centos7
- Others:

Actual Behavior

执行如下load data 语句报错(数据部分 Shanxi;XiAn 带分号):

load data inline format='csv', data=$XXX$
zhangsan,26,Shanxi;XiAn $XXX$
into table user
fields terminated by ','
lines terminated by '\r\n'
(name,age,city)

报错信息如下: image

Expected Behavior

No response

Steps to Reproduce

1.创建数据库
create database test;

2.创建数据表
use test;

CREATE TABLE `user` (
`name` VARCHAR(255) DEFAULT null,
`age` INT DEFAULT null,
`city` VARCHAR(255) DEFAULT null
)

3.执行load data语句
load data inline format='csv', data=$XXX$
zhangsan,26,Shanxi;XiAn $XXX$
into table user
fields terminated by ','
lines terminated by '\r\n'
(name,age,city)

Additional information

No response

aronchanisme commented 5 months ago

Solution: consider pre-processing the data by adding enclosed character(like " by default, as illustrated here) Currently stuck by this issue: https://github.com/matrixorigin/matrixone/issues/16794

jensenojs commented 2 months ago

not working ont it

huby2358 commented 2 months ago
image
huby2358 commented 2 months ago
企业微信截图_f783f079-4170-45d8-9a95-b7cc45f2c4ac
huby2358 commented 2 months ago

如上面截图所示,回退到issue的commit,按照issue中的步骤,是可以成功插入的,结果也是符合预期的,这种语法错误应该是必现的,怀疑是不是当时使用错误导致报错。

aronchanisme commented 2 months ago

请用linux的环境复现(最新main和1.2-dev均能复现) szpc

企业微信截图_b00c9add-1e37-4de9-af4f-83cb348010d3

129

企业微信截图_3fd816d8-2198-4400-af66-bb3058db9b8e

aron开发机

企业微信截图_66a44f88-0b0d-4ae8-960e-9f9d70e3235c
huby2358 commented 2 months ago

这个issue报错原因就是由于mysql客户端用分号作为切割,issue里面的load,会当成两条sql发到服务端,所以报语法错误。今天在8.0和8.3的mysql客户端都试了,8.3的客户端发到服务端的是一条sql,没有做切割(所以load成功,如我上面贴的load成功的图就是在8.3的客户端测试的。所以解决这个问题,建议升级到8.3看看

huby2358 commented 2 months ago

@gaoy121用8.3.0的客户端试了,满足要求,issue关了

aronchanisme commented 1 month ago

closing it