sql-parser icon indicating copy to clipboard operation
sql-parser copied to clipboard

error

Open nIxedoahz opened this issue 1 year ago • 6 comments

CREATE TABLE students ( name TEXT, student_number INTEGER, city TEXT,grade DOUBLE, credits BIGINT )

nIxedoahz avatar Mar 03 '23 10:03 nIxedoahz

Can you provide some details of the error you get? Currently, I am able to parse the statement successfully.

dey4ss avatar Mar 03 '23 11:03 dey4ss

@dey4ss like this Sql is : CREATE TABLE XIAOZHAO.table1 (column1 CHAR(11),column2 VARCHAR(100),column3 VARCHAR(100));

Result is : Given string is not a valid SQL query. syntax error, unexpected TABLE, expecting SELECT or '(' (L0:0)

nIxedoahz avatar Mar 04 '23 01:03 nIxedoahz

Does your system use Windows-style line feeds (\r\n instead of \n)? This could be a problem, since we explicitly only allow space, tab, and linefeed (not carriage return) as whitespace in the lexer: https://github.com/hyrise/sql-parser/blob/5a5fd248496e8d415fd2a4b1787e7114d90e60de/src/parser/flex_lexer.l#L63

dey4ss avatar Mar 06 '23 14:03 dey4ss

@dey4ss My system use Linux is \n

nIxedoahz avatar Mar 07 '23 03:03 nIxedoahz

@dey4ss Will there be other effects if I change it to the following? [ \t\n]+ /* skip whitespace */ {yymore()};

nIxedoahz avatar Mar 07 '23 03:03 nIxedoahz

Unfortunately, I won't be able to look into this in the next three to four days. In the meanwhile, could you please also let us know how you invoke the parser (e.g., CLI, inside your code, ...) with a minimal example/snippet and provide some more information about your setup.

Will there be other effects if I change it to the following? [ \t\n]+ /* skip whitespace */ {yymore()};

Sorry, I cannot answer this right away but will come back on that in a couple of days. From what I quickly found (no guarantees) here:

yymore will cause the next token's yytext to include the current yytext

it should mess up the tokenization since the whitespaces are included in every following token.

dey4ss avatar Mar 07 '23 17:03 dey4ss