Skip to content

Commit

Permalink
add whitespace check between interval literal and alias (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
aceforeverd authored Feb 17, 2022
1 parent b08253b commit 3963378
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions zetasql/parser/flex_tokenizer.l
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,12 @@ zone { return BisonParserImpl::token::KW_ZONE; }
10s can be regarded as second interval literals which is equal to INTERVAL 10 SECOND. */
{decimal_digits}[SMHD] {
return BisonParserImpl::token::INTERVAL_LITERAL;
}
{decimal_digits}[SMHD][A-Z_] {
yylloc->begin.column += YYLeng() - 1;
SetOverrideError(
*yylloc, "Syntax error: Missing whitespace between literal and alias");
yyterminate();
}
/* Error rules for a number followed by an identifier without white space in
between. We don't want to parse the identifier as accidental alias. For
Expand Down
14 changes: 14 additions & 0 deletions zetasql/parser/testdata/literals.test
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,20 @@ SELECT
1d
==

select 100ss
--
ERROR: Syntax error: Missing whitespace between literal and alias [at 1:12]
select 100ss
^
==

select 100DD
--
ERROR: Syntax error: Missing whitespace between literal and alias [at 1:12]
select 100DD
^
==

select 1e10, .1e10, 0.1e10, 1.e10, 1e+10, .1e-10, 0.1e+10, 1.e-10;
--
QueryStatement [0-65]
Expand Down

0 comments on commit 3963378

Please sign in to comment.