Skip to content

LOAD DATA: "LINES STARTING BY" does not work #963

Closed

Description

@anitajjx

Can be reproduced ?

Yes.

Steps:

CREATE TABLE pet (name VARCHAR(20), owner VARCHAR(20), species VARCHAR(20), sex CHAR(1), weight FLOAT, ages INT);
LOAD DATA INFILE '/Users/anixjj/Workspace/sql_workshop/import/pet_test.txt' INTO TABLE pet FIELDS TERMINATED BY ',' LINES STARTING BY 'xxx' IGNORE 1 lines ;
pet_test.txt

Expected behavior:

According to MySQL doc excerpted below:
"If all the input lines have a common prefix that you want to ignore, you can use LINES STARTING BY 'prefix_string' to skip the prefix and anything before it. If a line does not include the prefix, the entire line is skipped. "

Expected result:
mysql> LOAD DATA INFILE '/Users/anixjj/Workspace/sql_workshop/import/pet_test.txt' INTO TABLE pet FIELDS TERMINATED BY ',' LINES STARTING BY 'xxx' IGNORE 1 lines ;
Query OK, 2 rows affected (0.01 sec)
Records: 2 Deleted: 0 Skipped: 0 Warnings: 0

mysql> select * from pet; +-------+-------+---------+------+--------+------+
| name | owner | species | sex | weight | ages |
+-------+-------+---------+------+--------+------+
| Claws | Gwen | cat | m | 17 | 22 |
| Fang | Benny | dog | m | 7 | 24 |
+-------+-------+---------+------+--------+------+
2 rows in set (0.00 sec)

Actual behavior:

mysql> LOAD DATA INFILE '/Users/anixjj/Workspace/sql_workshop/import/pet_test.txt' INTO TABLE pet FIELDS TERMINATED BY ',' LINES STARTING BY 'xxx' IGNORE 1 lines ;
Query OK, 6 rows affected (0.05 sec)
Records: 6 Deleted: 0 Skipped: 0 Warnings: 0

mysql> select * from pet;
+------------------+--------+---------+------+---------+------+
| name | owner | species | sex | weight | ages |
+------------------+--------+---------+------+---------+------+
| Fluffy | Harold | cat | f | 4.0000 | 21 |
| xxxClaws | Gwen | cat | m | 17.0000 | 22 |
| Buffy | Harold | dog | f | 14.0000 | 23 |
| SomethingxxxFang | Benny | dog | m | 7.0000 | 24 |
| Bowser | Diane | dog | m | 31.0000 | 9 |
| Chirpy | Gwen | bird | f | 11.0000 | 25 |
+------------------+--------+---------+------+---------+------+
6 rows in set (0.01 sec)

Environment:

  • Version or commit-id (e.g. v0.1.0 or 8b23a93):
  • Hardware parameters:
  • OS type:
  • Others:

Configuration file:

Additional context:

  • Error message from client:
  • Server log:
  • Other information:

Activity

  1. added
    kind/bug
    priority/p2
    severity/s2
    on Oct 19, 2021
  2. added this to the v0.2.0 milestone on Oct 19, 2021
  3. daviszhen commented on Oct 19, 2021

    @daviszhen
    Contributor

    MO uses the simdcsv as the csv parser. the simdcsv does not support such prefix skip. The MO will not support it in the future also.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugpriority/p2severity/s2

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions