imay commented on a change in pull request #2083: Support sql mode
URL: https://github.com/apache/incubator-doris/pull/2083#discussion_r341440753
##########
File path: fe/src/main/java/org/apache/doris/analysis/SetVar.java
##########
@@ -111,8 +113,22 @@ public void analyze(Analyzer analyzer) throws
AnalysisException, UserException {
if (!(literalExpr instanceof LiteralExpr)) {
throw new AnalysisException("Set statement does't support
computing expr:" + literalExpr.toSql());
}
-
+
result = (LiteralExpr)literalExpr;
+
+ if (variable.equalsIgnoreCase(SessionVariable.SQL_MODE)) {
+ // For the case like "set sql_mode = PIPES_AS_CONCAT"
+ if (result instanceof StringLiteral) {
+ String sqlMode = result.getStringValue();
+ result = new
StringLiteral(SqlModeHelper.encode(sqlMode).toString());
+ }
+ // For the case like "set sql_mode = 3"
+ else if (result instanceof IntLiteral) {
+ String sqlMode = SqlModeHelper.decode(result.getLongValue());
+ result = new
IntLiteral(SqlModeHelper.encode(sqlMode).toString(), Type.BIGINT);
Review comment:
I think this is not needed. If decode execute successfully, you can just use
result.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]