未验证 提交 6cbd3851 编写于 作者: H huolibo 提交者: GitHub

fix(driver): fix preparedStatement preprocessing error (#11620)

* <fix>(driver): fix preparedStatement preprocessing error
sql will cut out if there is "* is null"
TS-1432

* fix(driver): remove usless code
上级 9ebd82e4
......@@ -81,14 +81,6 @@ public class TSDBPreparedStatement extends TSDBStatement implements PreparedStat
*/
private void preprocessSql() {
/***For processing some of Spark SQLs*/
// should replace it first
this.rawSql = this.rawSql.replaceAll("or (.*) is null", "");
this.rawSql = this.rawSql.replaceAll(" where ", " WHERE ");
this.rawSql = this.rawSql.replaceAll(" or ", " OR ");
this.rawSql = this.rawSql.replaceAll(" and ", " AND ");
this.rawSql = this.rawSql.replaceAll(" is null", " IS NULL");
this.rawSql = this.rawSql.replaceAll(" is not null", " IS NOT NULL");
// SELECT * FROM db.tb WHERE 1=0
this.rawSql = this.rawSql.replaceAll("WHERE 1=0", "WHERE _c0=1");
this.rawSql = this.rawSql.replaceAll("WHERE 1=2", "WHERE _c0=1");
......@@ -96,24 +88,6 @@ public class TSDBPreparedStatement extends TSDBStatement implements PreparedStat
// SELECT "ts","val" FROM db.tb
this.rawSql = this.rawSql.replaceAll("\"", "");
// SELECT 1 FROM db.tb
this.rawSql = this.rawSql.replaceAll("SELECT 1 FROM", "SELECT * FROM");
// SELECT "ts","val" FROM db.tb WHERE ts < 33 or ts is null
this.rawSql = this.rawSql.replaceAll("OR (.*) IS NULL", "");
// SELECT "ts","val" FROM db.tb WHERE ts is null or ts < 33
this.rawSql = this.rawSql.replaceAll("(.*) IS NULL OR", "");
// SELECT 1 FROM db.tb WHERE (("val" IS NOT NULL) AND ("val" > 50)) AND (ts >= 66)
this.rawSql = this.rawSql.replaceAll("\\(\\((.*) IS NOT NULL\\) AND", "(");
// SELECT 1 FROM db.tb WHERE ("val" IS NOT NULL) AND ("val" > 50) AND (ts >= 66)
this.rawSql = this.rawSql.replaceAll("\\((.*) IS NOT NULL\\) AND", "");
// SELECT "ts","val" FROM db.tb WHERE (("val" IS NOT NULL)) AND (ts < 33 or ts is null)
this.rawSql = this.rawSql.replaceAll("\\(\\((.*) IS NOT NULL\\)\\) AND", "");
/***** For processing inner subqueries *****/
Pattern pattern = Pattern.compile("FROM\\s+((\\(.+\\))\\s+SUB_QRY)", Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(rawSql);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册