From bf3228e852a92d3a48c0b2031c5dfb530bb36122 Mon Sep 17 00:00:00 2001 From: Yuya Ebihara Date: Sat, 21 Sep 2024 07:01:09 +0900 Subject: [PATCH] Reuse sessionProperty in SET SESSION grammer --- .../src/main/antlr4/io/trino/grammar/sql/SqlBase.g4 | 2 +- .../src/main/java/io/trino/sql/parser/AstBuilder.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/core/trino-grammar/src/main/antlr4/io/trino/grammar/sql/SqlBase.g4 b/core/trino-grammar/src/main/antlr4/io/trino/grammar/sql/SqlBase.g4 index abba5a8ee01f39..3b2d6cf53fe97f 100644 --- a/core/trino-grammar/src/main/antlr4/io/trino/grammar/sql/SqlBase.g4 +++ b/core/trino-grammar/src/main/antlr4/io/trino/grammar/sql/SqlBase.g4 @@ -178,7 +178,7 @@ statement (LIKE pattern=string (ESCAPE escape=string)?)? #showSession | SET SESSION AUTHORIZATION authorizationUser #setSessionAuthorization | RESET SESSION AUTHORIZATION #resetSessionAuthorization - | SET SESSION qualifiedName EQ expression #setSession + | SET SESSION sessionProperty #setSession | RESET SESSION qualifiedName #resetSession | START TRANSACTION (transactionMode (',' transactionMode)*)? #startTransaction | COMMIT WORK? #commit diff --git a/core/trino-parser/src/main/java/io/trino/sql/parser/AstBuilder.java b/core/trino-parser/src/main/java/io/trino/sql/parser/AstBuilder.java index ef1a00bdd3cf89..0b64cd8ba62642 100644 --- a/core/trino-parser/src/main/java/io/trino/sql/parser/AstBuilder.java +++ b/core/trino-parser/src/main/java/io/trino/sql/parser/AstBuilder.java @@ -1529,7 +1529,8 @@ public Node visitShowSession(SqlBaseParser.ShowSessionContext context) @Override public Node visitSetSession(SqlBaseParser.SetSessionContext context) { - return new SetSession(getLocation(context), getQualifiedName(context.qualifiedName()), (Expression) visit(context.expression())); + SessionProperty sessionProperty = (SessionProperty) visit(context.sessionProperty()); + return new SetSession(getLocation(context), sessionProperty.getName(), sessionProperty.getValue()); } @Override