Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LOAD DATA INFILE syntax error on different order of params 'starting by' and 'terminated by' #8706

Closed
uroborosq opened this issue Dec 29, 2024 · 5 comments
Labels
bug Something isn't working correctness We don't return the same result as MySQL customer issue good repro Easily reproducible bugs

Comments

@uroborosq
Copy link

Env:
Docker image - dolthub/dolt-sql-server:latest

root@c0ca5804a5c6:/var/lib/dolt# dolt version
dolt version 1.45.0

Host OS: arch linux, amd64


Steps:
create a csv file for import:

echo -e '1;"test1"\n2;"test2"' > example.csv

try to import data with firstly 'STARTING BY' then 'TERMINATED BY':

LOAD DATA LOCAL INFILE '/var/lib/dolt/example.csv' INTO TABLE `test_load_data` CHARACTER SET binary FIELDS TERMINATED BY '\t' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '\\' LINES STARTING BY '' TERMINATED BY '\n' (id,value);

Such query works perfectly.

Then, swap 'TERMINATED BY' and 'STARTING BY':

test/main*> LOAD DATA LOCAL INFILE '/var/lib/dolt/example.csv' INTO TABLE `test_load_data` CHARACTER SET binary FIELDS TERMINATED BY '\t' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (id,value);
Error parsing SQL: 
syntax error at position 208 near 'STARTING'
CLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (id,value)
                                                                ^

No problems with MySQL (9) when order is reversed.

Originally, problem was faced with usage of sqlc for Go, which uses such order from in external lib - https://github.com/hexon/mysqltsv/blob/main/mysqltsv.go#L17, so there is no visible way to override it.

@timsehn
Copy link
Contributor

timsehn commented Dec 30, 2024

Good bug and repro. @jycor will fix this tomorrow

@timsehn timsehn added bug Something isn't working good repro Easily reproducible bugs correctness We don't return the same result as MySQL labels Dec 30, 2024
@timsehn
Copy link
Contributor

timsehn commented Dec 31, 2024

@jycor was sick yesterday but I see this in our fork of Vitess

dolthub/vitess#393

@jycor
Copy link
Contributor

jycor commented Dec 31, 2024

Hey @uroborosq, thanks for filing this issue!
The fix for this has been merged to Vitess and is making its way to Dolt main.
We can have a release with the fix out later this week!

@jycor jycor closed this as completed Dec 31, 2024
@bpf120
Copy link

bpf120 commented Dec 31, 2024

@uroborosq , we'd love to learn about your Dolt use case too. Feel free to email me or swing by our Discord if you want to share.

@uroborosq
Copy link
Author

big thanks everyone for quick reaction, will be waiting for the fix become available!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctness We don't return the same result as MySQL customer issue good repro Easily reproducible bugs
Projects
None yet
Development

No branches or pull requests

5 participants