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

feat: add flush privileges support #59

Open
wants to merge 1 commit into
base: feat/hybridse-zetasql
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions zetasql/parser/bison_parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -920,6 +920,7 @@ using zetasql::ASTDropStatement;
%token KW_SECURITY "SECURITY"
%token KW_SESSION "SESSION"
%token KW_SHOW "SHOW"
%token KW_FLUSH "FLUSH"
%token KW_SIMPLE "SIMPLE"
%token KW_SOURCE "SOURCE"
%token KW_SQL "SQL"
Expand Down Expand Up @@ -1302,6 +1303,7 @@ using zetasql::ASTDropStatement;
%type <node> select_list
%type <node> select_list_prefix
%type <node> show_statement
%type <node> flush_statement
%type <node> target_name
%type <identifier> show_target
%type <identifier> show_with_name_target
Expand Down Expand Up @@ -1621,6 +1623,7 @@ sql_statement_body:
| show_statement
| drop_all_row_access_policies_statement
| drop_statement
| flush_statement
| call_statement
| import_statement
| module_statement
Expand Down Expand Up @@ -3721,6 +3724,14 @@ show_statement:
}
;

flush_statement:
"FLUSH" "PRIVILEGES"
{
$$ = MAKE_NODE(ASTFlushStatement, @$, {"PRIVILEGES"});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need add ASTFlushStatement yourself.

And its not necessary to pass a "privilege" string as constructor argument

}
;


show_target:
"MATERIALIZED" "VIEWS"
{
Expand Down
1 change: 1 addition & 0 deletions zetasql/parser/flex_tokenizer.l
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ fill { return BisonParserImpl::token::KW_FILL; }
filter { return BisonParserImpl::token::KW_FILTER; }
filter_fields { return BisonParserImpl::token::KW_FILTER_FIELDS; }
first { return BisonParserImpl::token::KW_FIRST; }
flush { return BisonParserImpl::token::KW_FLUSH; }
following { return BisonParserImpl::token::KW_FOLLOWING; }
for { return BisonParserImpl::token::KW_FOR; }
foreign { return BisonParserImpl::token::KW_FOREIGN; }
Expand Down
1 change: 1 addition & 0 deletions zetasql/parser/keywords.cc
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ constexpr KeywordInfoPOD kAllKeywords[] = {
{"filter_fields", KW_FILTER_FIELDS},
{"fill", KW_FILL},
{"first", KW_FIRST},
{"flush", KW_FLUSH},
{"following", KW_FOLLOWING, KeywordInfo::kReserved},
{"for", KW_FOR, KeywordInfo::kReserved},
{"foreign", KW_FOREIGN},
Expand Down
35 changes: 35 additions & 0 deletions zetasql/parser/testdata/flush_privileges.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
flush privileges;
--
FlushStatement [0-16]
Keyword(`PRIVILEGES`) [6-16]
--
FLUSH PRIVILEGES
==

flush privileges with extra;
--
ERROR: Syntax error: Expected end of input but got identifier "with" [at 1:19]
flush privileges with extra;
^
==

flush privileges like;
--
ERROR: Syntax error: Expected end of input but got identifier "like" [at 1:18]
flush privileges like;
^
==

flush;
--
ERROR: Syntax error: Expected "PRIVILEGES" but got ";" [at 1:6]
flush;
^
==

flush something else;
--
ERROR: Syntax error: Expected "PRIVILEGES" but got "something" [at 1:7]
flush something else;
^
==
Loading