morningman commented on code in PR #55566:
URL: https://github.com/apache/doris/pull/55566#discussion_r2326565795
##########
fe/fe-core/src/main/java/org/apache/doris/qe/ConnectProcessor.java:
##########
@@ -304,17 +304,23 @@ public void executeQuery(String originStmt) throws
Exception {
try {
Review Comment:
We should write unit test to test case.
I suggest you extract this part of method, and write unit test to make sure
this logic works
##########
fe/fe-core/src/main/java/org/apache/doris/qe/ConnectProcessor.java:
##########
@@ -459,6 +465,27 @@ private List<StatementBase> parseFromSqlCache(String
originStmt) {
return null;
}
+ /**
+ * Try to retry SQL parsing with original SQL when conversion fails
+ */
+ private List<StatementBase> tryRetryOriginalSql(String originStmt, String
convertedStmt,
+ SessionVariable sessionVariable) {
+ // Try to retry with original SQL if enabled and convertedStmt is
different from originStmt
+ if (sessionVariable.isEnableSqlConverterRetryOriginal()
+ && !convertedStmt.equals(originStmt)) {
+ try {
+ List<StatementBase> stmts = new
NereidsParser().parseSQL(originStmt, sessionVariable);
+ // Update sqlHash to use original statement hash when retry
succeeds
+ String originalSqlHash = DigestUtils.md5Hex(originStmt);
+ ctx.setSqlHash(originalSqlHash);
+ return stmts;
+ } catch (Exception e) {
+ // Retry failed, return null
Review Comment:
we should at least print a log here, or it is hard to debug
##########
fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java:
##########
@@ -565,6 +565,8 @@ public class SessionVariable implements Serializable,
Writable {
public static final String SQL_DIALECT = "sql_dialect";
+ public static final String ENABLE_SQL_CONVERTER_RETRY_ORIGINAL =
"enable_sql_converter_retry_original";
Review Comment:
retry_origin_sql_on_convert_fail
##########
fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java:
##########
@@ -2180,6 +2182,10 @@ public boolean isEnableHboNonStrictMatchingMode() {
description = {"解析sql使用的方言", "The dialect used to parse sql."})
public String sqlDialect = "doris";
+ @VariableMgr.VarAttr(name = ENABLE_SQL_CONVERTER_RETRY_ORIGINAL,
needForward = true,
+ description = {"开启SQL转换器重试原始SQL功能", "Enable SQL converter retry
original SQL feature."})
Review Comment:
"但转换后的sql解析失败是,是否重试原始sql"
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]