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/deployment statements #24

7 changes: 6 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ before_deploy:
deploy:
provider: releases
api_key:
secure: "bzUtqEZHFO7F9DV7P8PoTqZl+OF4FIT0KhxGxk1sRtr9ehVyjefmvREkroHjSoYKUp1oHOeDN6OQmWDk0Efeo7aCLL7Cc40rakSKLmzdH0gfFj3nH+R5wjegJskDsOp9tK7yi0F069T0R6hSOfHkgRqWHpdpm3qSp13YKBnzQ6JpeUgGotyqES1558yRqqNRfNBTHKT0I4T70HfC0spBkk30nuyBIaNAkoRq5XLCmM71OGjpNb6wo2m9laN4droLco7dfB5/EotD+kow4NjXqOf97Yhb6DGM2w7z5UP+b8Vf5WXgiue9JZ7K2Af0YGOapSXi6cfnMaQxVy/0N7be273+KY/g+V50ujBoJbC5+svy0QpY/4Op0zxysXRQ9pATcH67EtR3KENZunT7Ko5NAvyc516k7LSsAckICR0C56r0oNUBr14KaOQ2CR1ea7LHuthusK6eBm+VFJ94PJta6rVcwusrqoRnuO5PDw2lJXSD3kQfTVQUYCIrM3Q0ySidhJY69Ymc/zDq6O2zSOrTp6D1ZlGxsGaJvJbf3F4omfAeZIVp91IGvVCPk3nAygoSMCgtKAfpFbkssp5EDmhIoZI4YFMQOwSaiCGuSGakER0Ihj2Jp/B72bjDT/TrPJDHHEQzlgBrvtYL/1GdjIgS5VmN/rcPgzve5aeeUMMqkp8="
# steps to produce a encrypted key from GitHub
# 1. generate a personal access token at https://github.com/settings/tokens, select only repo:public_repo
# 2. generate && copy the token
# 3. install travis && run 'travis encrypt <token string> --com'
# 4. replace below line with the output
secure: "RmzUGAPO3Gi0mXtG/4mUlPGxLu6Fp21oD6NifJV5FnPPmAFIvLU62WU4xzd/Gyt0FKQThoopT1nQRYbOUtkCLRWgXh/qwRRAyymxJlvpoKOk1bCrKBL2Zr3J7YlS8zEYj9SiFEfkFgs+1laW9ddlyk8rU5OO4XvTU0R/zcoecTkiZqpYiHOZsvy+mnwBfacbZuzjS5VjP8Vbh3ut1+yJdYaERYY6EZJ4dQSQeNGTact7BeuNPD/HDxPkuHs1sdcby/N2r6yDaQp59wrzOuTmgVJJlxaU7nBhpT8rmkQKp782lEqTZnu/606aSj0/ArNvVOo5XXUz3ttl4xQleP65/g2OqDi74yc02gHRrN2srz/oUKJX2bqN3KxYvG2LbniHdsFtDa6Yc9jsyc2p9LjSgkAYcM61qPdokWDlEBUdV1wHYfC2oQ/Z8vuMcabynKsg0si9MdoMsu4qUrh/S0QnpxIqX7cSj1azIiHlY1AIttU7/e3DNi6cvOTJAHWCEH7JPAqcLuYh/8rk0oM0qxzc8ttT76XPUc8tOcGj9h0nu7BPQ7ZbzpKeCrNajLWRj3tELbmMw5IT1mJtoRSR1o+pDT1vyCZ9BeSHJvq75WSJphVq4EKpgsNodkEsKCdBsJQx9GdZLv79lcknbTnS8FgurpvVu6P90C1CTAQLtmdR8t8="
file_glob: true
file: libzetasql-*.tar.gz
skip_cleanup: true
Expand Down
1 change: 1 addition & 0 deletions zetasql/parser/ast_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ enum class SchemaObjectKind {
kTable,
kTableFunction,
kView,
kDeployment,
__SchemaObjectKind__switch_must_have_a_default__ = -1,
};

Expand Down
3 changes: 3 additions & 0 deletions zetasql/parser/ast_node_kind.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,9 @@ enum ASTNodeKind {
AST_WITH_GROUP_ROWS,
AST_WITH_OFFSET,
AST_WITH_PARTITION_COLUMNS_CLAUSE,
AST_SHOW_TARGET_EXPRESSION,
AST_DEPLOY_STATEMENT,
AST_LOAD_DATA_STATEMENT,
AST_WITH_WEIGHT,
kLastASTNodeKind = AST_WITH_WEIGHT
};
Expand Down
59 changes: 56 additions & 3 deletions zetasql/parser/bison_parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,8 @@ using zetasql::ASTDropStatement;
%token KW_DECLARE "DECLARE"
%token KW_DEFINER "DEFINER"
%token KW_DELETE "DELETE"
%token KW_DEPLOY "DEPLOY"
%token KW_DEPLOYMENT "DEPLOYMENT"
%token KW_DESCRIBE "DESCRIBE"
%token KW_DESCRIPTOR "DESCRIPTOR"
%token KW_DETERMINISTIC "DETERMINISTIC"
Expand All @@ -843,6 +845,7 @@ using zetasql::ASTDropStatement;
%token KW_IMMUTABLE "IMMUTABLE"
%token KW_IMPORT "IMPORT"
%token KW_INCLUDE "INCLUDE"
%token KW_INFILE "INFILE"
%token KW_INOUT "INOUT"
%token KW_INSERT "INSERT"
%token KW_INVOKER "INVOKER"
Expand All @@ -853,6 +856,7 @@ using zetasql::ASTDropStatement;
%token KW_LANGUAGE "LANGUAGE"
%token KW_LEAVE "LEAVE"
%token KW_LEVEL "LEVEL"
%token KW_LOAD "LOAD"
%token KW_LOOP "LOOP"
%token KW_MATCH "MATCH"
%token KW_MATCHED "MATCHED"
Expand Down Expand Up @@ -997,6 +1001,7 @@ using zetasql::ASTDropStatement;
%type <expression> date_or_time_literal
%type <node> define_table_statement
%type <node> delete_statement
%type <node> deploy_statement
%type <node> describe_info
%type <node> describe_statement
%type <node> dml_statement
Expand Down Expand Up @@ -1072,6 +1077,8 @@ using zetasql::ASTDropStatement;
%type <node> repeat_statement
%type <node> for_in_statement
%type <node> import_statement
%type <node> load_statement
%type <node> load_data_statement
%type <node> variable_declaration
%type <node> opt_default_expression
%type <node> identifier_list
Expand Down Expand Up @@ -1261,8 +1268,9 @@ using zetasql::ASTDropStatement;
%type <node> select_list
%type <node> select_list_prefix
%type <node> show_statement
%type <expression> show_target_expression
%type <identifier> show_target
%type <identifier> show_create_procedure_target
%type <identifier> show_with_name_target
%type <node> simple_column_schema_inner
%type <node> sql_function_body
%type <node> star_except_list
Expand Down Expand Up @@ -1577,6 +1585,8 @@ sql_statement_body:
| import_statement
| module_statement
| use_statement
| deploy_statement
| load_statement
;

query_statement:
Expand Down Expand Up @@ -1756,6 +1766,8 @@ schema_object_kind:
{ $$ = zetasql::SchemaObjectKind::kSchema; }
| "VIEW"
{ $$ = zetasql::SchemaObjectKind::kView; }
| "DEPLOYMENT"
{ $$ = zetasql::SchemaObjectKind::kDeployment; }
;

alter_statement:
Expand Down Expand Up @@ -3371,6 +3383,20 @@ import_statement:
}
;

load_statement:
load_data_statement
{
$$ = $1;
}
;

load_data_statement:
"LOAD" "DATA" "INFILE" string_literal "INTO" "TABLE" path_expression opt_options_list
{
$$ = MAKE_NODE(ASTLoadDataStatement, @$, {$4, $7, $8});
}
;

module_statement:
"MODULE" path_expression opt_options_list
{
Expand Down Expand Up @@ -3499,7 +3525,7 @@ show_statement:
{
$$ = MAKE_NODE(ASTShowStatement, @$, {$2, $3, $4});
}
| "SHOW" show_create_procedure_target path_expression
| "SHOW" show_with_name_target show_target_expression
{
$$ = MAKE_NODE(ASTShowStatement, @$, {$2, $3});
}
Expand All @@ -3520,11 +3546,22 @@ show_target:
}
;

show_create_procedure_target:
show_with_name_target:
"CREATE" "PROCEDURE"
{
$$ = parser->MakeIdentifier(@$, "CREATE PROCEDURE");
}
| "DEPLOYMENT"
{
$$ = parser->MakeIdentifier(@$, "DEPLOYMENT");
}
;

show_target_expression:
path_expression
{
$$ = MAKE_NODE(ASTShowTargetExpression, @$, {$1});
}
;

opt_like_string_literal:
Expand Down Expand Up @@ -7260,6 +7297,8 @@ keyword_as_identifier:
| "DECLARE"
| "DEFINER"
| "DELETE"
| "DEPLOY"
| "DEPLOYMENT"
| "DESCRIBE"
| "DETERMINISTIC"
| "DO"
Expand Down Expand Up @@ -7287,6 +7326,7 @@ keyword_as_identifier:
| "IMMUTABLE"
| "IMPORT"
| "INCLUDE"
| "INFILE"
| "INSERT"
| "INOUT"
| "INVOKER"
Expand All @@ -7297,6 +7337,7 @@ keyword_as_identifier:
| "LANGUAGE"
| "LEAVE"
| "LEVEL"
| "LOAD"
| "LOOP"
| "MATCH"
| "MATCHED"
Expand Down Expand Up @@ -8149,6 +8190,15 @@ on_path_expression:
}
;

deploy_statement:
"DEPLOY" opt_if_not_exists identifier unterminated_sql_statement
{
auto deploy_stmt = MAKE_NODE(ASTDeployStatement, @$, {$3, $4});
deploy_stmt->set_is_if_not_exists($2);
$$ = deploy_stmt;
}
;

opt_drop_mode:
"RESTRICT" { $$ = zetasql::ASTDropStatement::DropMode::RESTRICT; }
| "CASCADE" { $$ = zetasql::ASTDropStatement::DropMode::CASCADE; }
Expand Down Expand Up @@ -8684,6 +8734,7 @@ next_statement_kind_without_hint:
| describe_keyword
{ $$ = zetasql::ASTDescribeStatement::kConcreteNodeKind; }
| "SHOW" { $$ = zetasql::ASTShowStatement::kConcreteNodeKind; }
| "DEPLOY" { $$ = zetasql::ASTDeployStatement::kConcreteNodeKind; }
| "DROP" "ALL" "ROW" opt_access "POLICIES"
{
$$ = zetasql::ASTDropAllRowAccessPoliciesStatement::kConcreteNodeKind;
Expand Down Expand Up @@ -8812,6 +8863,8 @@ next_statement_kind_without_hint:
{ $$ = zetasql::ASTReturnStatement::kConcreteNodeKind; }
| "IMPORT"
{ $$ = zetasql::ASTImportStatement::kConcreteNodeKind; }
| "LOAD" "DATA"
{ $$ = zetasql::ASTLoadDataStatement::kConcreteNodeKind; }
| "MODULE"
{ $$ = zetasql::ASTModuleStatement::kConcreteNodeKind; }
| "ANALYZE"
Expand Down
4 changes: 4 additions & 0 deletions zetasql/parser/flex_tokenizer.l
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,8 @@ default { return BisonParserImpl::token::KW_DEFAULT; }
define { return BisonParserImpl::token::KW_DEFINE; }
definer { return BisonParserImpl::token::KW_DEFINER; }
delete { return BisonParserImpl::token::KW_DELETE; }
deploy { return BisonParserImpl::token::KW_DEPLOY; }
deployment { return BisonParserImpl::token::KW_DEPLOYMENT; }
desc { return BisonParserImpl::token::KW_DESC; }
descriptor { return BisonParserImpl::token::KW_DESCRIPTOR; }
describe { return BisonParserImpl::token::KW_DESCRIBE; }
Expand Down Expand Up @@ -484,6 +486,7 @@ in { return BisonParserImpl::token::KW_IN; }
include { return BisonParserImpl::token::KW_INCLUDE; }
inout { return BisonParserImpl::token::KW_INOUT; }
index { return BisonParserImpl::token::KW_INDEX; }
infile { return BisonParserImpl::token::KW_INFILE; };
inner { return BisonParserImpl::token::KW_INNER; }
instance_not_in_window { return BisonParserImpl::token::KW_INSTANCE_NOT_IN_WINDOW; }
insert { return BisonParserImpl::token::KW_INSERT; }
Expand All @@ -505,6 +508,7 @@ left { return BisonParserImpl::token::KW_LEFT; }
level { return BisonParserImpl::token::KW_LEVEL; }
like { return BisonParserImpl::token::KW_LIKE; }
limit { return BisonParserImpl::token::KW_LIMIT; }
load { return BisonParserImpl::token::KW_LOAD; }
lookup { return BisonParserImpl::token::KW_LOOKUP; }
loop { return BisonParserImpl::token::KW_LOOP; }
match { return BisonParserImpl::token::KW_MATCH; }
Expand Down
4 changes: 4 additions & 0 deletions zetasql/parser/keywords.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ constexpr KeywordInfoPOD kAllKeywords[] = {
{"define", KW_DEFINE, KeywordInfo::kReserved},
{"definer", KW_DEFINER},
{"delete", KW_DELETE},
{"deploy", KW_DEPLOY},
{"deployment", KW_DEPLOYMENT},
{"desc", KW_DESC, KeywordInfo::kReserved},
{"describe", KW_DESCRIBE},
{"descriptor", KW_DESCRIPTOR},
Expand Down Expand Up @@ -161,6 +163,7 @@ constexpr KeywordInfoPOD kAllKeywords[] = {
{"include", KW_INCLUDE},
{"inout", KW_INOUT},
{"index", KW_INDEX, KeywordInfo::kReserved},
{"infile", KW_INFILE},
{"inner", KW_INNER, KeywordInfo::kReserved},
{"insert", KW_INSERT},
{"instance_not_in_window", KW_INSTANCE_NOT_IN_WINDOW, KeywordInfo::kReserved},
Expand All @@ -182,6 +185,7 @@ constexpr KeywordInfoPOD kAllKeywords[] = {
{"level", KW_LEVEL},
{"like", KW_LIKE, KeywordInfo::kReserved},
{"limit", KW_LIMIT, KeywordInfo::kReserved},
{"load", KW_LOAD},
{"lookup", KW_LOOKUP, KeywordInfo::kReserved},
{"loop", KW_LOOP},
{"match", KW_MATCH},
Expand Down
5 changes: 5 additions & 0 deletions zetasql/parser/parse_tree.cc
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,9 @@ static absl::flat_hash_map<ASTNodeKind, std::string> CreateNodeNamesMap() {
map[AST_WITH_CONNECTION_CLAUSE] = "WithConnectionClause";
map[AST_WITH_GROUP_ROWS] = "WithGroupRows";
map[AST_WITH_OFFSET] = "WithOffset";
map[AST_SHOW_TARGET_EXPRESSION] = "ShowTargetExpression";
map[AST_DEPLOY_STATEMENT] = "DeployStatement";
map[AST_LOAD_DATA_STATEMENT] = "LoadDataStatement";
map[AST_WITH_WEIGHT] = "WithWeight";
map[AST_WITH_PARTITION_COLUMNS_CLAUSE] = "WithPartitionColumnsClause";
for (int kind = kFirstASTNodeKind; kind <= kLastASTNodeKind;
Expand Down Expand Up @@ -1640,6 +1643,8 @@ absl::string_view SchemaObjectKindToName(SchemaObjectKind schema_object_kind) {
return "TABLE FUNCTION";
case SchemaObjectKind::kView:
return "VIEW";
case SchemaObjectKind::kDeployment:
return "DEPLOYMENT";
default:
return "<INVALID SCHEMA OBJECT KIND>";
}
Expand Down
Loading