From 65b6ea4ce44633f4742c992a32091470219aed8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AB=98=E9=93=81?= Date: Sat, 12 Dec 2020 22:12:39 +0800 Subject: [PATCH] improved oracle sql parser. --- .../oracle/parser/OracleExprParser.java | 10 +++ .../sql/visitor/SQLASTOutputVisitor.java | 4 + .../druid/sql/visitor/SchemaStatVisitor.java | 4 + .../oracle/visitor/OracleResourceTest.java | 85 ++++++++++++++----- src/test/resources/bvt/parser/oracle-0.txt | 8 +- src/test/resources/bvt/parser/oracle-1.txt | 6 +- src/test/resources/bvt/parser/oracle-10.txt | 2 +- src/test/resources/bvt/parser/oracle-11.txt | 2 +- src/test/resources/bvt/parser/oracle-13.txt | 7 +- src/test/resources/bvt/parser/oracle-14.txt | 11 ++- src/test/resources/bvt/parser/oracle-15.txt | 29 ++++--- src/test/resources/bvt/parser/oracle-16.txt | 12 +-- src/test/resources/bvt/parser/oracle-17.txt | 29 ++++--- src/test/resources/bvt/parser/oracle-18.txt | 9 +- src/test/resources/bvt/parser/oracle-19.txt | 15 ++-- src/test/resources/bvt/parser/oracle-2.txt | 7 +- src/test/resources/bvt/parser/oracle-20.txt | 7 +- src/test/resources/bvt/parser/oracle-21.txt | 20 +++-- src/test/resources/bvt/parser/oracle-22.txt | 28 +++--- src/test/resources/bvt/parser/oracle-23.txt | 13 ++- src/test/resources/bvt/parser/oracle-24.txt | 19 +++-- src/test/resources/bvt/parser/oracle-25.txt | 35 +++++--- src/test/resources/bvt/parser/oracle-26.txt | 15 ++-- src/test/resources/bvt/parser/oracle-27.txt | 9 +- src/test/resources/bvt/parser/oracle-28.txt | 8 +- src/test/resources/bvt/parser/oracle-29.txt | 14 ++- src/test/resources/bvt/parser/oracle-3.txt | 5 +- src/test/resources/bvt/parser/oracle-30.txt | 13 ++- src/test/resources/bvt/parser/oracle-31.txt | 8 +- src/test/resources/bvt/parser/oracle-32.txt | 2 +- src/test/resources/bvt/parser/oracle-33.txt | 4 +- src/test/resources/bvt/parser/oracle-35.txt | 3 +- src/test/resources/bvt/parser/oracle-41.txt | 4 +- src/test/resources/bvt/parser/oracle-46.txt | 2 +- src/test/resources/bvt/parser/oracle-47.txt | 6 +- src/test/resources/bvt/parser/oracle-49.txt | 2 +- src/test/resources/bvt/parser/oracle-5.txt | 8 +- src/test/resources/bvt/parser/oracle-50.txt | 3 +- src/test/resources/bvt/parser/oracle-51.txt | 3 +- src/test/resources/bvt/parser/oracle-53.txt | 6 +- src/test/resources/bvt/parser/oracle-54.txt | 42 ++++++--- src/test/resources/bvt/parser/oracle-56.txt | 19 ++--- src/test/resources/bvt/parser/oracle-60.txt | 10 +++ 43 files changed, 364 insertions(+), 184 deletions(-) create mode 100644 src/test/resources/bvt/parser/oracle-60.txt diff --git a/src/main/java/com/alibaba/druid/sql/dialect/oracle/parser/OracleExprParser.java b/src/main/java/com/alibaba/druid/sql/dialect/oracle/parser/OracleExprParser.java index 26eef11bb9..99caf0da02 100644 --- a/src/main/java/com/alibaba/druid/sql/dialect/oracle/parser/OracleExprParser.java +++ b/src/main/java/com/alibaba/druid/sql/dialect/oracle/parser/OracleExprParser.java @@ -797,6 +797,16 @@ public class OracleExprParser extends SQLExprParser { } accept(Token.RPAREN); + + if (lexer.stringVal().equalsIgnoreCase("IGNORE")) { + lexer.nextToken(); + acceptIdentifier("NULLS"); + aggregateExpr.setIgnoreNulls(true); + } else if (lexer.identifierEquals(FnvHash.Constants.RESPECT)) { + lexer.nextToken(); + acceptIdentifier("NULLS"); + aggregateExpr.setIgnoreNulls(false); + } if (lexer.identifierEquals(FnvHash.Constants.WITHIN)) { lexer.nextToken(); diff --git a/src/main/java/com/alibaba/druid/sql/visitor/SQLASTOutputVisitor.java b/src/main/java/com/alibaba/druid/sql/visitor/SQLASTOutputVisitor.java index d134b9cad7..d6c62747e3 100644 --- a/src/main/java/com/alibaba/druid/sql/visitor/SQLASTOutputVisitor.java +++ b/src/main/java/com/alibaba/druid/sql/visitor/SQLASTOutputVisitor.java @@ -2058,6 +2058,10 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet print(')'); + if (x.isIgnoreNulls()) { + print0(ucase ? " IGNORE NULLS" : " ignore nulls"); + } + SQLKeep keep = x.getKeep(); if (keep != null) { print(' '); diff --git a/src/main/java/com/alibaba/druid/sql/visitor/SchemaStatVisitor.java b/src/main/java/com/alibaba/druid/sql/visitor/SchemaStatVisitor.java index b9ea581cda..498819ca09 100644 --- a/src/main/java/com/alibaba/druid/sql/visitor/SchemaStatVisitor.java +++ b/src/main/java/com/alibaba/druid/sql/visitor/SchemaStatVisitor.java @@ -2819,6 +2819,10 @@ public class SchemaStatVisitor extends SQLASTVisitorAdapter { } protected final void statExpr(SQLExpr x) { + if (x == null) { + return; + } + Class clazz = x.getClass(); if (clazz == SQLIdentifierExpr.class) { visit((SQLIdentifierExpr) x); diff --git a/src/test/java/com/alibaba/druid/bvt/sql/oracle/visitor/OracleResourceTest.java b/src/test/java/com/alibaba/druid/bvt/sql/oracle/visitor/OracleResourceTest.java index 790f34c79f..7b0535c43e 100644 --- a/src/test/java/com/alibaba/druid/bvt/sql/oracle/visitor/OracleResourceTest.java +++ b/src/test/java/com/alibaba/druid/bvt/sql/oracle/visitor/OracleResourceTest.java @@ -20,6 +20,8 @@ import java.io.InputStreamReader; import java.io.Reader; import java.util.List; +import com.alibaba.druid.DbType; +import com.alibaba.druid.sql.SQLUtils; import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlOutputVisitor; import org.junit.Assert; @@ -33,11 +35,45 @@ import com.alibaba.druid.util.JdbcUtils; public class OracleResourceTest extends OracleTest { - public void test_0() throws Exception { - // 13 -// exec_test("bvt/parser/oracle-56.txt"); - for (int i = 0; i <= 57; ++i) { // 57 + public void test_0_9() throws Exception { + for (int i = 0; i <= 9; ++i) { // 57 exec_test("bvt/parser/oracle-" + i + ".txt"); + System.out.println(); + } + } + + public void test_10_19() throws Exception { + for (int i = 10; i <= 19; ++i) { // 57 + exec_test("bvt/parser/oracle-" + i + ".txt"); + System.out.println(); + } + } + + public void test_20_29() throws Exception { + for (int i = 20; i <= 29; ++i) { // 57 + exec_test("bvt/parser/oracle-" + i + ".txt"); + System.out.println(); + } + } + + public void test_30_39() throws Exception { + for (int i = 30; i <= 39; ++i) { // 57 + exec_test("bvt/parser/oracle-" + i + ".txt"); + System.out.println(); + } + } + + public void test_40_49() throws Exception { + for (int i = 40; i <= 49; ++i) { // 57 + exec_test("bvt/parser/oracle-" + i + ".txt"); + System.out.println(); + } + } + + public void test_50_57() throws Exception { + for (int i = 50; i <= 57; ++i) { // 57 + exec_test("bvt/parser/oracle-" + i + ".txt"); + System.out.println(); } } @@ -45,6 +81,14 @@ public class OracleResourceTest extends OracleTest { exec_test("bvt/parser/oracle-58.txt"); } + public void test_59() throws Exception { + exec_test("bvt/parser/oracle-59.txt"); + } + + public void test_60() throws Exception { + exec_test("bvt/parser/oracle-60.txt"); + } + public void exec_test(String resource) throws Exception { System.out.println(resource); InputStream is = null; @@ -55,7 +99,12 @@ public class OracleResourceTest extends OracleTest { JdbcUtils.close(reader); String[] items = input.split("---------------------------"); String sql = items[0].trim(); - String expect = items[1].trim(); + String expect = null; + if (items.length > 1) { + expect = items[1]; + expect = expect.trim(); + expect = expect.replaceAll("\\r\\n", "\n"); + } OracleStatementParser parser = new OracleStatementParser(sql); List statementList = parser.parseStatementList(); @@ -78,23 +127,17 @@ public class OracleResourceTest extends OracleTest { System.out.println(); System.out.println(); - } - void mergValidate(String sql, String expect) { - - MySqlStatementParser parser = new MySqlStatementParser(sql); - List statementList = parser.parseStatementList(); - SQLStatement statemen = statementList.get(0); - - Assert.assertEquals(1, statementList.size()); - - StringBuilder out = new StringBuilder(); - MySqlOutputVisitor visitor = new MySqlOutputVisitor(out, true); - statemen.accept(visitor); - - System.out.println(out.toString()); - - Assert.assertEquals(expect, out.toString()); + if (statementList.size() == 1) { + SQLStatement stmt = statementList.get(0); + if (expect != null && !expect.isEmpty()) { + assertEquals(expect, stmt.toString()); + } + } else { + if (expect != null && !expect.isEmpty()) { + assertEquals(expect, SQLUtils.toSQLString(statementList, DbType.oracle)); + } + } } } diff --git a/src/test/resources/bvt/parser/oracle-0.txt b/src/test/resources/bvt/parser/oracle-0.txt index a44ed20973..71b951ebcf 100644 --- a/src/test/resources/bvt/parser/oracle-0.txt +++ b/src/test/resources/bvt/parser/oracle-0.txt @@ -15,5 +15,11 @@ ORDER BY id   ; --------------------------- SELECT ID AS id, to_char(GMT_MODIFIED, 'yyyymmdd hh24:mi:ss') AS gmtModified, COL5 AS col5 FROM ABC_ABC -WHERE IS_DELETED = 'n' AND end_time IS NULL AND deadline_time < sysdate AND approval_time IS NULL AND id > :1 AND (col2 IN (:2, :3, :4, :5, :6, :7, :8, :9, :10, :11, :12, :13, :14, :15, :16, :17, :18, :19, :20, :21, :22, :23, :24, :25, :26, :27, :28, :29, :30, :31, :32, :33) AND rownum < :34) +WHERE IS_DELETED = 'n' + AND end_time IS NULL + AND deadline_time < SYSDATE + AND approval_time IS NULL + AND id > :1 + AND col2 IN (:2, :3, :4, :5, :6, :7, :8, :9, :10, :11, :12, :13, :14, :15, :16, :17, :18, :19, :20, :21, :22, :23, :24, :25, :26, :27, :28, :29, :30, :31, :32, :33) + AND rownum < :34 ORDER BY id; \ No newline at end of file diff --git a/src/test/resources/bvt/parser/oracle-1.txt b/src/test/resources/bvt/parser/oracle-1.txt index 733ff90891..5d364163c4 100644 --- a/src/test/resources/bvt/parser/oracle-1.txt +++ b/src/test/resources/bvt/parser/oracle-1.txt @@ -68,14 +68,16 @@ SELECT ID, GMT_MODIFIED, MODIFIER, GMT_CREATE, CREATOR , CATEGORY_ID, REMARK, MEMBER_ID, SALES_OWNER_ID, ACCOUNT_ID , IS_DELETED, CUST_GRADE FROM APOLLO_ZEUS.GLOBAL_ACCOUNT -WHERE ACCOUNT_ID = :B2 AND DOMAIN = :B1 +WHERE ACCOUNT_ID = :B2 + AND DOMAIN = :B1 UNION ALL SELECT ID, GMT_MODIFIED, MODIFIER, GMT_CREATE, CREATOR , DOMAIN, EMPLOYEE_NUMBER, COMPANY_NAME, HOMEPAGE_URL, BACKGROUND , CATEGORY_ID, REMARK, MEMBER_ID, SALES_OWNER_ID, ACCOUNT_ID , IS_DELETED, CUST_GRADE FROM APOLLO_NIR.GLOBAL_ACCOUNT -WHERE ACCOUNT_ID = :B2 AND DOMAIN = :B1; +WHERE ACCOUNT_ID = :B2 + AND DOMAIN = :B1 diff --git a/src/test/resources/bvt/parser/oracle-10.txt b/src/test/resources/bvt/parser/oracle-10.txt index c363b4e0e1..b3beb0fd7c 100644 --- a/src/test/resources/bvt/parser/oracle-10.txt +++ b/src/test/resources/bvt/parser/oracle-10.txt @@ -6,5 +6,5 @@ SELECT salary FROM employees --------------------------- SELECT salary FROM employees -VERSIONS BETWEEN TIMESTAMP SYSTIMESTAMP - INTERVAL '10' MINUTE AND SYSTIMESTAMP - INTERVAL '1' MINUTE +VERSIONS BETWEEN TIMESTAMP (SYSTIMESTAMP - INTERVAL '10' MINUTE) AND SYSTIMESTAMP - INTERVAL '1' MINUTE WHERE last_name = 'Chung'; \ No newline at end of file diff --git a/src/test/resources/bvt/parser/oracle-11.txt b/src/test/resources/bvt/parser/oracle-11.txt index 1a5e0a3fa3..4d14f8774a 100644 --- a/src/test/resources/bvt/parser/oracle-11.txt +++ b/src/test/resources/bvt/parser/oracle-11.txt @@ -10,5 +10,5 @@ SET salary = ( FROM employees AS OF TIMESTAMP (SYSTIMESTAMP - INTERVAL '2' MINUTE) WHERE last_name = 'Chung' - ) +) WHERE last_name = 'Chung'; \ No newline at end of file diff --git a/src/test/resources/bvt/parser/oracle-13.txt b/src/test/resources/bvt/parser/oracle-13.txt index 30b5c15212..e0afa5fe6b 100644 --- a/src/test/resources/bvt/parser/oracle-13.txt +++ b/src/test/resources/bvt/parser/oracle-13.txt @@ -7,9 +7,12 @@ SELECT DECODE(GROUPING(department_name), 1, 'All Departments', GROUP BY CUBE (department_name, job_id) ORDER BY department_name, job_id; --------------------------- -SELECT DECODE(GROUPING(department_name), 1, 'All Departments', department_name) AS department_name, DECODE(GROUPING(job_id), 1, 'All Jobs', job_id) AS job_id, COUNT(*) AS "Total Empl", AVG(salary) * 12 AS "Average Sal" +SELECT DECODE(GROUPING(department_name), 1, 'All Departments', department_name) AS department_name + , DECODE(GROUPING(job_id), 1, 'All Jobs', job_id) AS job_id + , COUNT(*) AS "Total Empl" + , AVG(salary) * 12 AS "Average Sal" FROM employees e, departments d WHERE d.department_id = e.department_id -GROUP BY CUBE(department_name, job_id) +GROUP BY CUBE (department_name, job_id) ORDER BY department_name, job_id; diff --git a/src/test/resources/bvt/parser/oracle-14.txt b/src/test/resources/bvt/parser/oracle-14.txt index 1ff4306f08..1cc567748c 100644 --- a/src/test/resources/bvt/parser/oracle-14.txt +++ b/src/test/resources/bvt/parser/oracle-14.txt @@ -13,9 +13,16 @@ SELECT channel_desc, calendar_month_desc, co.country_id, (channel_desc, co.country_id), (calendar_month_desc, co.country_id) ); --------------------------- -SELECT channel_desc, calendar_month_desc, co.country_id, TO_CHAR(sum(amount_sold), '9,999,999,999') AS SALES$ +SELECT channel_desc, calendar_month_desc, co.country_id + , TO_CHAR(sum(amount_sold), '9,999,999,999') AS SALES$ FROM xxxx, bbb, times, ccc, ddd co -WHERE xxxx.time_id = times.time_id AND xxxx.cust_id = bbb.cust_id AND xxxx.channel_id = ccc.channel_id AND bbb.country_id = co.country_id AND (ccc.channel_desc IN ('Direct Sales', 'Internet') AND (times.calendar_month_desc IN ('2000-09', '2000-10') AND co.country_iso_code IN ('UK', 'US'))) +WHERE xxxx.time_id = times.time_id + AND xxxx.cust_id = bbb.cust_id + AND xxxx.channel_id = ccc.channel_id + AND bbb.country_id = co.country_id + AND ccc.channel_desc IN ('Direct Sales', 'Internet') + AND times.calendar_month_desc IN ('2000-09', '2000-10') + AND co.country_iso_code IN ('UK', 'US') GROUP BY GROUPING SETS ((channel_desc, calendar_month_desc, co.country_id), (channel_desc, co.country_id), (calendar_month_desc, co.country_id)); diff --git a/src/test/resources/bvt/parser/oracle-15.txt b/src/test/resources/bvt/parser/oracle-15.txt index 89b70b44f5..db7d54d964 100644 --- a/src/test/resources/bvt/parser/oracle-15.txt +++ b/src/test/resources/bvt/parser/oracle-15.txt @@ -20,24 +20,33 @@ FROM (SELECT A.*, rownum cnt WHERE ROWNUM < ?) WHERE CNT > ? --------------------------- SELECT * -FROM (SELECT A.*, rownum AS cnt - FROM (SELECT A.CUSTID, A.PAYCOUNT, A.MEMBERID, A.ACCREDITSTATUS, C.CUSTNAME +FROM ( + SELECT A.*, rownum AS cnt + FROM ( + SELECT A.CUSTID, A.PAYCOUNT, A.MEMBERID, A.ACCREDITSTATUS, C.CUSTNAME , C.CONTNAME, C.CONTPHONECITYCODE, C.CONTPHONE, C.CONTMOBPHONE, C.CONTFAXCITYCODE , C.CONTFAX, C.CONTEMAIL, C.CUSTAREA AS AREANAME, C.CUSTADDR, C.ORGINDUSTRY AS ORGINDUSTRYNAME , E.DESCRIPTION AS CUSTSTATNAME, F.DESCRIPTION AS ATYPENAME, NULL AS FNAME, G.DESCRIPTION AS B2BVALIDFLAGNAME, A.VALIDFLAG - FROM Q_CUSTOMERS A, Q_CUSTINFO C, (SELECT * + FROM Q_CUSTOMERS A, Q_CUSTINFO C, ( + SELECT * FROM F_A_DE WHERE DOMAINCD = 'CUSTOMERS_CUSTSTAT' - ) E, (SELECT * + ) E, ( + SELECT * FROM F_A_DE WHERE DOMAINCD = 'CUSTOMERS_ATYPE' - ) F, (SELECT * + ) F, ( + SELECT * FROM F_A_DE WHERE DOMAINCD = 'CUSTOMERS_B2BVALIDFLAG' - ) G - WHERE A.CUSTID = C.CUSTID AND A.CUSTSTAT = CODE(+) AND A.ATYPE = CODE(+) AND A.b2bValidFlag = CODE(+) AND A.MEMBERID = ? + ) G + WHERE A.CUSTID = C.CUSTID + AND A.CUSTSTAT = E.CODE(+) + AND A.ATYPE = F.CODE(+) + AND A.b2bValidFlag = G.CODE(+) + AND A.MEMBERID = ? ORDER BY A.CUSTID DESC - ) A + ) A WHERE ROWNUM < ? - ) -WHERE CNT > ?; +) +WHERE CNT > ? diff --git a/src/test/resources/bvt/parser/oracle-16.txt b/src/test/resources/bvt/parser/oracle-16.txt index 89505ba3ce..8b33d83fd8 100644 --- a/src/test/resources/bvt/parser/oracle-16.txt +++ b/src/test/resources/bvt/parser/oracle-16.txt @@ -10,12 +10,14 @@ WHERE CNT > ? --------------------------- SELECT ID, CLASSTYPE, KEY, VALUE -FROM (SELECT A.*, ROWNUM AS CNT - FROM (SELECT ID, CLASSTYPE, KEY, VALUE +FROM ( + SELECT A.*, ROWNUM AS CNT + FROM ( + SELECT ID, CLASSTYPE, KEY, VALUE FROM F_XXX WHERE CLASSTYPE = ? ORDER BY ID DESC - ) A + ) A WHERE ROWNUM < ? - ) -WHERE CNT > ?; \ No newline at end of file +) +WHERE CNT > ? \ No newline at end of file diff --git a/src/test/resources/bvt/parser/oracle-17.txt b/src/test/resources/bvt/parser/oracle-17.txt index 452f90f9ae..631c33ea93 100644 --- a/src/test/resources/bvt/parser/oracle-17.txt +++ b/src/test/resources/bvt/parser/oracle-17.txt @@ -21,19 +21,28 @@ WHERE k.cnt > ? ORDER BY memberid ASC, createtime DESC --------------------------- -SELECT custid, memberid, to_char(createtime, 'yyyy-mm-dd hh24:mi:ss') AS createtime, planid, auditstate - , to_char(modifytime, 'yyyy-mm-dd hh24:mi:ss') AS modifytime, createid, to_char(custappdate, 'yyyy-mm-dd hh24:mi:ss') AS custappdate, executeState, gmtcreate - , custname, planbatchid -FROM (SELECT custid, memberid, createtime, planid, auditstate +SELECT custid, memberid, to_char(createtime, 'yyyy-mm-dd hh24:mi:ss') AS createtime + , planid, auditstate, to_char(modifytime, 'yyyy-mm-dd hh24:mi:ss') AS modifytime + , createid, to_char(custappdate, 'yyyy-mm-dd hh24:mi:ss') AS custappdate, executeState + , gmtcreate, custname, planbatchid +FROM ( + SELECT custid, memberid, createtime, planid, auditstate , createid, custappdate, executeState, custname, gmtcreate , cnt, planbatchid, modifytime - FROM (SELECT p.custid, p.memberid, p.createtime, p.planid, p.auditstate + FROM ( + SELECT p.custid, p.memberid, p.createtime, p.planid, p.auditstate , p.createid, p.custappdate, p.modifytime, p.gmtcreate, p.executeState - , c.custname, row_number() OVER ( ORDER BY p.memberid ASC, p.createtime DESC) AS cnt, p.planbatchid + , c.custname, row_number() OVER (ORDER BY p.memberid ASC, p.createtime DESC) AS cnt, p.planbatchid FROM x_plp_f_u_c_k p, x_xcde c - WHERE p.custid = c.custid AND p.applytype = 0 AND p.createtime BETWEEN to_date(?, 'yyyy-mm-dd') AND to_date(?, 'yyyy-mm-dd hh24:mi:ss') AND (p.auditstate = ? AND p.executestate = 1) AND auditstate != 3 AND p.memberid IN (?) - ) t + WHERE p.custid = c.custid + AND p.applytype = 0 + AND p.createtime BETWEEN to_date(?, 'yyyy-mm-dd') AND to_date(?, 'yyyy-mm-dd hh24:mi:ss') + AND (p.auditstate = ? + AND p.executestate = 1) + AND auditstate != 3 + AND p.memberid IN (?) + ) t WHERE t.cnt < ? - ) k +) k WHERE k.cnt > ? -ORDER BY memberid ASC, createtime DESC; \ No newline at end of file +ORDER BY memberid ASC, createtime DESC \ No newline at end of file diff --git a/src/test/resources/bvt/parser/oracle-18.txt b/src/test/resources/bvt/parser/oracle-18.txt index 0147401b23..b20259737d 100644 --- a/src/test/resources/bvt/parser/oracle-18.txt +++ b/src/test/resources/bvt/parser/oracle-18.txt @@ -8,7 +8,10 @@ ORDER BY e.word_alias,a.createtime DESC --------------------------- -SELECT /*+use_hash(a b e) index(e)*/ Count(*) +SELECT /*+ use_hash(a b e) index(e)*/ Count(*) FROM bbbb a, aaaa b, q_keyword e, CCCC f -WHERE a.offerid = b.offerid AND a.keywordid = e.keywordid AND a.offerid = f.offerid AND a.issuspect = '1' -ORDER BY e.word_alias, a.createtime DESC; \ No newline at end of file +WHERE a.offerid = b.offerid + AND a.keywordid = e.keywordid + AND a.offerid = f.offerid + AND a.issuspect = '1' +ORDER BY e.word_alias, a.createtime DESC \ No newline at end of file diff --git a/src/test/resources/bvt/parser/oracle-19.txt b/src/test/resources/bvt/parser/oracle-19.txt index 9ae32e0fb8..d7fe5986f3 100644 --- a/src/test/resources/bvt/parser/oracle-19.txt +++ b/src/test/resources/bvt/parser/oracle-19.txt @@ -11,12 +11,15 @@ where rownum < ? ) where rnm >= ? --------------------------- SELECT * -FROM (SELECT rownum AS rnm, z.* - FROM (SELECT name AS value, value AS KEY +FROM ( + SELECT rownum AS rnm, z.* + FROM ( + SELECT name AS value, value AS key FROM a_b_c - WHERE is_deleted = 'n' AND type = 'fuse' + WHERE is_deleted = 'n' + AND type = 'fuse' ORDER BY ordering - ) z + ) z WHERE rownum < ? - ) -WHERE rnm >= ?; +) +WHERE rnm >= ? diff --git a/src/test/resources/bvt/parser/oracle-2.txt b/src/test/resources/bvt/parser/oracle-2.txt index 3393afb4fe..6c8ed1633c 100644 --- a/src/test/resources/bvt/parser/oracle-2.txt +++ b/src/test/resources/bvt/parser/oracle-2.txt @@ -2,7 +2,8 @@ SELECT employee_id FROM (SELECT employee_id+1 AS employee_id FROM employees) FOR UPDATE; --------------------------- SELECT employee_id -FROM (SELECT employee_id + 1 AS employee_id +FROM ( + SELECT employee_id + 1 AS employee_id FROM employees - ) -FOR UPDATE; +) +FOR UPDATE; \ No newline at end of file diff --git a/src/test/resources/bvt/parser/oracle-20.txt b/src/test/resources/bvt/parser/oracle-20.txt index bc457e53bc..975b2d6f88 100644 --- a/src/test/resources/bvt/parser/oracle-20.txt +++ b/src/test/resources/bvt/parser/oracle-20.txt @@ -12,5 +12,8 @@ ORDER BY EE_2.NAME,AA_2.id NULLS LAST --------------------------- SELECT A_B_C.*, EE_2.NAME AS TRUNK_NAME FROM AA_2, A_B_C, EE_2 -WHERE AA_2.is_deleted = 'n' AND AA_2.TRUNK_ID = EE_2.ID AND AA_2.ID = A_B_C.CLOT_ID AND A_B_C.GMT_MODIFIED >= ? -ORDER BY EE_2.NAME, AA_2.id NULLS LAST; +WHERE AA_2.is_deleted = 'n' + AND AA_2.TRUNK_ID = EE_2.ID + AND AA_2.ID = A_B_C.CLOT_ID + AND A_B_C.GMT_MODIFIED >= ? +ORDER BY EE_2.NAME, AA_2.id NULLS LAST \ No newline at end of file diff --git a/src/test/resources/bvt/parser/oracle-21.txt b/src/test/resources/bvt/parser/oracle-21.txt index dad5b2c2a6..3b9bcf07dc 100644 --- a/src/test/resources/bvt/parser/oracle-21.txt +++ b/src/test/resources/bvt/parser/oracle-21.txt @@ -17,16 +17,20 @@ select * from ( --------------------------- SELECT * -FROM (SELECT rownum AS rnm, z.* - FROM (SELECT DISTINCT tt.id AS use_less_id, tt.* - FROM (SELECT t.*, rct.parent_id, RCT.NAME AS trunk_name +FROM ( + SELECT rownum AS rnm, z.* + FROM ( + SELECT DISTINCT tt.id AS use_less_id, tt.* + FROM ( + SELECT t.*, rct.parent_id, RCT.NAME AS trunk_name FROM x_1_2 t, k_2_3 rct - WHERE t.is_deleted = 'n' AND t.trunk_id = rct.id - ) tt + WHERE t.is_deleted = 'n' + AND t.trunk_id = rct.id + ) tt START WITH trunk_name = 'rc.mf.Caesar' CONNECT BY PRIOR parent_id = trunk_id ORDER BY load_order NULLS LAST - ) z + ) z WHERE rownum < ? - ) -WHERE rnm >= ?; \ No newline at end of file +) +WHERE rnm >= ? \ No newline at end of file diff --git a/src/test/resources/bvt/parser/oracle-22.txt b/src/test/resources/bvt/parser/oracle-22.txt index 0e6b19a3a9..576465932b 100644 --- a/src/test/resources/bvt/parser/oracle-22.txt +++ b/src/test/resources/bvt/parser/oracle-22.txt @@ -24,20 +24,26 @@ where rnm >= ? --------------------------- SELECT * -FROM (SELECT rownum AS rnm, z.* - FROM (SELECT * - FROM (SELECT DISTINCT * - FROM (SELECT lower(a.role_name) || '#' || a.permission_id AS KEY, 'y' AS value +FROM ( + SELECT rownum AS rnm, z.* + FROM ( + SELECT * + FROM ( + SELECT DISTINCT * + FROM ( + SELECT lower(a.role_name) || '#' || a.permission_id AS key, 'y' AS value FROM f_p_23 A WHERE a.is_deleted = 'n' UNION ALL SELECT lower(b.role_name) || '#' || a.permission_id, 'y' FROM f_p_23 A, app_role_base_role B - WHERE a.is_deleted = 'n' AND b.is_deleted = 'n' AND a.role_name = b.base_role_name - ) - ) c - ORDER BY c.KEY - ) z + WHERE a.is_deleted = 'n' + AND b.is_deleted = 'n' + AND a.role_name = b.base_role_name + ) + ) c + ORDER BY c.key + ) z WHERE rownum < ? - ) -WHERE rnm >= ?; \ No newline at end of file +) +WHERE rnm >= ? \ No newline at end of file diff --git a/src/test/resources/bvt/parser/oracle-23.txt b/src/test/resources/bvt/parser/oracle-23.txt index 7ff221f5a3..5be2164c7a 100644 --- a/src/test/resources/bvt/parser/oracle-23.txt +++ b/src/test/resources/bvt/parser/oracle-23.txt @@ -10,9 +10,14 @@ from ( --------------------------- SELECT nodeId, nodeName, taskflowName, taskflowVersion -FROM (SELECT /*+use_hash(n f) ordered*/ n.ID AS nodeId, n.name AS nodeName, f.name AS taskflowName, f.version AS taskflowVersion +FROM ( + SELECT /*+ use_hash(n f) ordered */ n.ID AS nodeId, n.name AS nodeName, f.name AS taskflowName, f.version AS taskflowVersion FROM "AB" n, "BC_3" f - WHERE n.owner = ? AND (n.STATUS IN (?) AND n.GMT_MODIFIED < ? AND n.IS_AUTO = 'Y' AND n.task_flow_id = f.id) + WHERE n.owner = ? + AND n.STATUS IN (?) + AND n.GMT_MODIFIED < ? + AND n.IS_AUTO = 'Y' + AND n.task_flow_id = f.id ORDER BY f.priority DESC NULLS LAST, f.gmt_create ASC - ) -WHERE rownum < ?; \ No newline at end of file +) +WHERE rownum < ? \ No newline at end of file diff --git a/src/test/resources/bvt/parser/oracle-24.txt b/src/test/resources/bvt/parser/oracle-24.txt index ea7b5f7396..aee502b200 100644 --- a/src/test/resources/bvt/parser/oracle-24.txt +++ b/src/test/resources/bvt/parser/oracle-24.txt @@ -15,10 +15,17 @@ where xh=1 --------------------------- -SELECT INDUSTRY_ID, sale_type, service_type, RISK_TYPE, to_char(gmt_create, 'yyyy-mm-dd hh24:mi:ss') AS gmt_create -FROM (SELECT /*+use_hash(a b c) ordered*/ b.service_type, b.RISK_TYPE, b.sale_type, b.INDUSTRY_ID, b.GMT_CREATE - , row_number() OVER (PARTITION BY (b.service_type, b.RISK_TYPE, b.sale_type, b.INDUSTRY_ID) ORDER BY b.GMT_CREATE) AS xh +SELECT INDUSTRY_ID, sale_type, service_type, RISK_TYPE + , to_char(gmt_create, 'yyyy-mm-dd hh24:mi:ss') AS gmt_create +FROM ( + SELECT /*+ use_hash(a b c) ordered */ b.service_type, b.RISK_TYPE, b.sale_type, b.INDUSTRY_ID, b.GMT_CREATE + , row_number() OVER (PARTITION BY b.service_type, b.RISK_TYPE, b.sale_type, b.INDUSTRY_ID ORDER BY b.GMT_CREATE) AS xh FROM "AAAAA" a, "F" b, "BBBBB" c - WHERE a.id = b.task_flow_id AND a.id = c.task_flow_id AND c.status = 'waiting' AND c.IS_AUTO = 'N' AND a.status = 'running' AND c.name IN (?) - ) -WHERE xh = 1; + WHERE a.id = b.task_flow_id + AND a.id = c.task_flow_id + AND c.status = 'waiting' + AND c.IS_AUTO = 'N' + AND a.status = 'running' + AND c.name IN (?) +) +WHERE xh = 1 diff --git a/src/test/resources/bvt/parser/oracle-25.txt b/src/test/resources/bvt/parser/oracle-25.txt index a714f086aa..66da59ced1 100644 --- a/src/test/resources/bvt/parser/oracle-25.txt +++ b/src/test/resources/bvt/parser/oracle-25.txt @@ -46,26 +46,37 @@ where rownum_ >= ? --------------------------- SELECT * -FROM (SELECT row_.*, rownum AS rownum_ - FROM (SELECT * - FROM (SELECT results.*, row_number() OVER (PARTITION BY (results.object_id) ORDER BY results.gmt_modified DESC) AS rn - FROM (SELECT sus.ID AS ID, sus.GMT_CREATE AS GMT_CREATE, sus.GMT_MODIFIED AS GMT_MODIFIED, sus.COMPANY_ID AS COMPANY_ID, sus.OBJECT_ID AS OBJECT_ID +FROM ( + SELECT row_.*, rownum AS rownum_ + FROM ( + SELECT * + FROM ( + SELECT results.*, row_number() OVER (PARTITION BY results.object_id ORDER BY results.gmt_modified DESC) AS rn + FROM ( + SELECT sus.ID AS ID, sus.GMT_CREATE AS GMT_CREATE, sus.GMT_MODIFIED AS GMT_MODIFIED, sus.COMPANY_ID AS COMPANY_ID, sus.OBJECT_ID AS OBJECT_ID , sus.OBJECT_TYPE AS OBJECT_TYPE, sus.CONFIRM_TYPE AS CONFIRM_TYPE, sus.OPERATOR AS OPERATOR, sus.FILTER_TYPE AS FILTER_TYPE, sus.MEMBER_ID AS MEMBER_ID , sus.MEMBER_FUC_Q AS MEMBER_FUC_Q, sus.RISK_TYPE AS RISK_TYPE, 'Y' AS IS_DRAFT FROM f_U_c_ sus, a_b_c_draft p, member m - WHERE 1 = 1 AND p.company_id = m.company_id AND m.login_id = ? AND (p.sale_type IN (?) AND p.id = sus.object_id) + WHERE 1 = 1 + AND p.company_id = m.company_id + AND m.login_id = ? + AND p.sale_type IN (?) + AND p.id = sus.object_id UNION SELECT sus.ID AS ID, sus.GMT_CREATE AS GMT_CREATE, sus.GMT_MODIFIED AS GMT_MODIFIED, sus.COMPANY_ID AS COMPANY_ID, sus.OBJECT_ID AS OBJECT_ID , sus.OBJECT_TYPE AS OBJECT_TYPE, sus.CONFIRM_TYPE AS CONFIRM_TYPE, sus.OPERATOR AS OPERATOR, sus.FILTER_TYPE AS FILTER_TYPE, sus.MEMBER_ID AS MEMBER_ID , sus.MEMBER_FUC_Q AS MEMBER_FUC_Q, sus.RISK_TYPE AS RISK_TYPE, 'N' AS IS_DRAFT FROM f_U_c_ sus, a_b_c p, member m - WHERE 1 = 1 AND p.company_id = m.company_id AND m.login_id = ? AND (p.sale_type IN (?) AND p.id = sus.object_id) - ) results - ) + WHERE 1 = 1 + AND p.company_id = m.company_id + AND m.login_id = ? + AND p.sale_type IN (?) + AND p.id = sus.object_id + ) results + ) WHERE rn = 1 ORDER BY gmt_modified DESC - ) row_ + ) row_ WHERE rownum <= ? - ) -WHERE rownum_ >= ?; - +) +WHERE rownum_ >= ? diff --git a/src/test/resources/bvt/parser/oracle-26.txt b/src/test/resources/bvt/parser/oracle-26.txt index e783a6772c..0e44171322 100644 --- a/src/test/resources/bvt/parser/oracle-26.txt +++ b/src/test/resources/bvt/parser/oracle-26.txt @@ -12,12 +12,15 @@ from ( --------------------------- SELECT * -FROM (SELECT rownum AS rnm, z.* - FROM (SELECT name AS KEY, value +FROM ( + SELECT rownum AS rnm, z.* + FROM ( + SELECT name AS KEY, value FROM ccccc t - WHERE t.type = 'VODKA._CTPCLEAN_NIRVANA_URL' AND is_deleted = 'n' + WHERE t.type = 'VODKA._CTPCLEAN_NIRVANA_URL' + AND is_deleted = 'n' ORDER BY id - ) z + ) z WHERE rownum < ? - ) -WHERE rnm >= ?; +) +WHERE rnm >= ? \ No newline at end of file diff --git a/src/test/resources/bvt/parser/oracle-27.txt b/src/test/resources/bvt/parser/oracle-27.txt index 268e2bff30..405e671eea 100644 --- a/src/test/resources/bvt/parser/oracle-27.txt +++ b/src/test/resources/bvt/parser/oracle-27.txt @@ -7,8 +7,9 @@ group by bk.attr_id; --------------------------- -SELECT bk.attr_id AS attrId, group_concat(DISTINCT(bk.value_id)) AS attrValueStr, group_concat(DISTINCT(pt.name)) AS themeNameStr -FROM a_c_ pt LEFT JOIN cde_f bk ON pt.spu_id = bk.spu_id -WHERE pt.status = 'action' AND pt.category_id = ? +SELECT bk.attr_id AS attrId, group_concat(DISTINCT bk.value_id) AS attrValueStr, group_concat(DISTINCT pt.name) AS themeNameStr +FROM a_c_ pt + LEFT JOIN cde_f bk ON pt.spu_id = bk.spu_id +WHERE pt.status = 'action' + AND pt.category_id = ? GROUP BY bk.attr_id; - diff --git a/src/test/resources/bvt/parser/oracle-28.txt b/src/test/resources/bvt/parser/oracle-28.txt index 9bf3fb709d..66b9309058 100644 --- a/src/test/resources/bvt/parser/oracle-28.txt +++ b/src/test/resources/bvt/parser/oracle-28.txt @@ -11,6 +11,12 @@ OR operator = ? --------------------------- SELECT count(*) FROM CREDIT_CMT_APPLY, A_B_C -WHERE 1 = 2 OR operator = ? AND CREDIT_CMT_APPLY.GMT_CREATE >= ? AND CREDIT_CMT_APPLY.GMT_CREATE <= ? AND CREDIT_CMT_APPLY.ID = A_B_C.cmt_apply_id AND Type = 'denounce' AND SHEET_STATUS = 'assigned_unresolved'; +WHERE 1 = 2 + OR operator = ? + AND CREDIT_CMT_APPLY.GMT_CREATE >= ? + AND CREDIT_CMT_APPLY.GMT_CREATE <= ? + AND CREDIT_CMT_APPLY.ID = A_B_C.cmt_apply_id + AND Type = 'denounce' + AND SHEET_STATUS = 'assigned_unresolved' diff --git a/src/test/resources/bvt/parser/oracle-29.txt b/src/test/resources/bvt/parser/oracle-29.txt index 5ebf385a5d..3e3870c30f 100644 --- a/src/test/resources/bvt/parser/oracle-29.txt +++ b/src/test/resources/bvt/parser/oracle-29.txt @@ -18,21 +18,19 @@ ORDER BY order1; --------------------------- -WITH - org_chart (eid, emp_last, mgr_id, reportLevel, salary, job_id) - AS - ( +WITH org_chart (eid, emp_last, mgr_id, reportLevel, salary, job_id) AS ( SELECT employee_id, last_name, manager_id, 0 AS reportLevel, salary , job_id FROM employees WHERE manager_id IS NULL UNION ALL - SELECT e.employee_id, e.last_name, e.manager_id, r.reportLevel + 1 AS reportLevel, e.salary - , e.job_id + SELECT e.employee_id, e.last_name, e.manager_id, r.reportLevel + 1 AS reportLevel + , e.salary, e.job_id FROM org_chart r, employees e WHERE r.eid = e.manager_id ) SEARCH DEPTH FIRST BY emp_last SET order1 -SELECT lpad(' ', 2 * reportLevel) || emp_last AS emp_name, eid, mgr_id, salary, job_id +SELECT lpad(' ', 2 * reportLevel) || emp_last AS emp_name + , eid, mgr_id, salary, job_id FROM org_chart -ORDER BY order1; +ORDER BY order1; \ No newline at end of file diff --git a/src/test/resources/bvt/parser/oracle-3.txt b/src/test/resources/bvt/parser/oracle-3.txt index 3393afb4fe..6cc1179418 100644 --- a/src/test/resources/bvt/parser/oracle-3.txt +++ b/src/test/resources/bvt/parser/oracle-3.txt @@ -2,7 +2,8 @@ SELECT employee_id FROM (SELECT employee_id+1 AS employee_id FROM employees) FOR UPDATE; --------------------------- SELECT employee_id -FROM (SELECT employee_id + 1 AS employee_id +FROM ( + SELECT employee_id + 1 AS employee_id FROM employees - ) +) FOR UPDATE; diff --git a/src/test/resources/bvt/parser/oracle-30.txt b/src/test/resources/bvt/parser/oracle-30.txt index 4b48571049..9525c88b08 100644 --- a/src/test/resources/bvt/parser/oracle-30.txt +++ b/src/test/resources/bvt/parser/oracle-30.txt @@ -19,23 +19,20 @@ ORDER BY order1; --------------------------- -WITH - dup_hiredate (eid, emp_last, mgr_id, reportLevel, hire_date, job_id) - AS - ( +WITH dup_hiredate (eid, emp_last, mgr_id, reportLevel, hire_date, job_id) AS ( SELECT employee_id, last_name, manager_id, 0 AS reportLevel, hire_date , job_id FROM employees WHERE manager_id IS NULL UNION ALL - SELECT e.employee_id, e.last_name, e.manager_id, r.reportLevel + 1 AS reportLevel, e.hire_date - , e.job_id + SELECT e.employee_id, e.last_name, e.manager_id, r.reportLevel + 1 AS reportLevel + , e.hire_date, e.job_id FROM dup_hiredate r, employees e WHERE r.eid = e.manager_id ) SEARCH DEPTH FIRST BY hire_date SET order1 CYCLE hire_date SET is_cycle TO 'Y' DEFAULT 'N' -SELECT lpad(' ', 2 * reportLevel) || emp_last AS emp_name, eid, mgr_id, hire_date, job_id - , is_cycle +SELECT lpad(' ', 2 * reportLevel) || emp_last AS emp_name + , eid, mgr_id, hire_date, job_id, is_cycle FROM dup_hiredate ORDER BY order1; diff --git a/src/test/resources/bvt/parser/oracle-31.txt b/src/test/resources/bvt/parser/oracle-31.txt index 684c597ff5..f8877fe8b1 100644 --- a/src/test/resources/bvt/parser/oracle-31.txt +++ b/src/test/resources/bvt/parser/oracle-31.txt @@ -6,8 +6,8 @@ PIVOT --------------------------- SELECT * -FROM (SELECT EXTRACT(YEAR FROM order_date) AS year, order_mode, order_total +FROM ( + SELECT EXTRACT(YEAR FROM order_date) AS year, order_mode, order_total FROM orders - ) - PIVOT (SUM(order_total) FOR order_mode IN ('direct' AS Store, 'online' AS Internet)); - +) +PIVOT (SUM(order_total) FOR order_mode IN ('direct' AS Store, 'online' AS Internet)); diff --git a/src/test/resources/bvt/parser/oracle-32.txt b/src/test/resources/bvt/parser/oracle-32.txt index d65b788fc8..efcd34423b 100644 --- a/src/test/resources/bvt/parser/oracle-32.txt +++ b/src/test/resources/bvt/parser/oracle-32.txt @@ -7,6 +7,6 @@ SELECT * FROM pivot_table --------------------------- SELECT * FROM pivot_table - UNPIVOT (yearly_total FOR order_mode IN (store AS 'direct', internet AS 'online')) +UNPIVOT (yearly_total FOR order_mode IN (store AS "direct", internet AS "online")) ORDER BY year, order_mode; diff --git a/src/test/resources/bvt/parser/oracle-33.txt b/src/test/resources/bvt/parser/oracle-33.txt index 98f3ab41fa..cae817269d 100644 --- a/src/test/resources/bvt/parser/oracle-33.txt +++ b/src/test/resources/bvt/parser/oracle-33.txt @@ -7,5 +7,5 @@ SELECT * FROM pivot_table --------------------------- SELECT * FROM pivot_table - UNPIVOT INCLUDE NULLS (yearly_total FOR order_mode IN (store AS 'direct', internet AS 'online')) -ORDER BY year, order_mode; +UNPIVOT INCLUDE NULLS (yearly_total FOR order_mode IN (store AS "direct", internet AS "online")) +ORDER BY year, order_mode; \ No newline at end of file diff --git a/src/test/resources/bvt/parser/oracle-35.txt b/src/test/resources/bvt/parser/oracle-35.txt index cf99965faa..22c01c101b 100644 --- a/src/test/resources/bvt/parser/oracle-35.txt +++ b/src/test/resources/bvt/parser/oracle-35.txt @@ -8,5 +8,6 @@ SELECT last_name, job_id, departments.department_id, department_name --------------------------- SELECT last_name, job_id, departments.department_id, department_name FROM employees, departments -WHERE employees.department_id = departments.department_id AND job_id = 'SA_MAN' +WHERE employees.department_id = departments.department_id + AND job_id = 'SA_MAN' ORDER BY last_name; diff --git a/src/test/resources/bvt/parser/oracle-41.txt b/src/test/resources/bvt/parser/oracle-41.txt index 45c261a804..bbcd9086cf 100644 --- a/src/test/resources/bvt/parser/oracle-41.txt +++ b/src/test/resources/bvt/parser/oracle-41.txt @@ -1,6 +1,6 @@ SELECT 25, +6.34, 0.5, 25e-03, -1, 25f, +6.34F, 0.5d, -1D FROM DUAL --------------------------- -SELECT 25, 6.34, 0.5, 0.025, -1 +SELECT 25, 6.34, 0.5, 25e-03, -1 , 25.0F, 6.34F, 0.5D, -1.0D -FROM DUAL; \ No newline at end of file +FROM DUAL \ No newline at end of file diff --git a/src/test/resources/bvt/parser/oracle-46.txt b/src/test/resources/bvt/parser/oracle-46.txt index ce1dd80de9..4a5ed2a4ac 100644 --- a/src/test/resources/bvt/parser/oracle-46.txt +++ b/src/test/resources/bvt/parser/oracle-46.txt @@ -4,4 +4,4 @@ SELECT employee_id, manager_id --------------------------- SELECT employee_id, manager_id FROM employees -WHERE manager_id(+) = employees.employee_id; \ No newline at end of file +WHERE employees.manager_id(+) = employees.employee_id; \ No newline at end of file diff --git a/src/test/resources/bvt/parser/oracle-47.txt b/src/test/resources/bvt/parser/oracle-47.txt index ec4a13aeca..3f053eb318 100644 --- a/src/test/resources/bvt/parser/oracle-47.txt +++ b/src/test/resources/bvt/parser/oracle-47.txt @@ -6,7 +6,9 @@ SELECT * FROM employees --------------------------- SELECT * FROM employees -WHERE department_id NOT IN (SELECT department_id +WHERE department_id NOT IN ( + SELECT department_id FROM departments - WHERE location_id = 1700) + WHERE location_id = 1700 +) ORDER BY last_name; \ No newline at end of file diff --git a/src/test/resources/bvt/parser/oracle-49.txt b/src/test/resources/bvt/parser/oracle-49.txt index 54358c9ea4..e5e605dfae 100644 --- a/src/test/resources/bvt/parser/oracle-49.txt +++ b/src/test/resources/bvt/parser/oracle-49.txt @@ -10,4 +10,4 @@ FROM hr_info t1, TABLE(CAST(MULTISET(( SELECT t3.last_name, t3.department_id, t3.salary FROM people t3 WHERE t3.department_id = t1.department_id - )) AS people_tab_typ)) t2; \ No newline at end of file +)) AS people_tab_typ)) t2; \ No newline at end of file diff --git a/src/test/resources/bvt/parser/oracle-5.txt b/src/test/resources/bvt/parser/oracle-5.txt index e401387aaf..1598437bbe 100644 --- a/src/test/resources/bvt/parser/oracle-5.txt +++ b/src/test/resources/bvt/parser/oracle-5.txt @@ -10,10 +10,12 @@ FROM ORDER BY a.department_id; --------------------------- SELECT a.department_id AS "Department", a.num_emp / b.total_count AS "%_Employees", a.sal_sum / b.total_sal AS "%_Salary" -FROM (SELECT department_id, COUNT(*) AS num_emp, SUM(salary) AS sal_sum +FROM ( + SELECT department_id, COUNT(*) AS num_emp, SUM(salary) AS sal_sum FROM employees GROUP BY department_id - ) a, (SELECT COUNT(*) AS total_count, SUM(salary) AS total_sal +) a, ( + SELECT COUNT(*) AS total_count, SUM(salary) AS total_sal FROM employees - ) b +) b ORDER BY a.department_id; \ No newline at end of file diff --git a/src/test/resources/bvt/parser/oracle-50.txt b/src/test/resources/bvt/parser/oracle-50.txt index e083377a82..4272f0d7a0 100644 --- a/src/test/resources/bvt/parser/oracle-50.txt +++ b/src/test/resources/bvt/parser/oracle-50.txt @@ -4,7 +4,8 @@ SELECT LPAD(' ',2*(LEVEL-1)) || last_name org_chart, START WITH job_id = 'AD_VP' CONNECT BY PRIOR employee_id = manager_id; --------------------------- -SELECT LPAD(' ', 2 * (LEVEL - 1)) || last_name AS org_chart, employee_id, manager_id, job_id +SELECT LPAD(' ', 2 * (LEVEL - 1)) || last_name AS org_chart + , employee_id, manager_id, job_id FROM employees START WITH job_id = 'AD_VP' CONNECT BY PRIOR employee_id = manager_id; \ No newline at end of file diff --git a/src/test/resources/bvt/parser/oracle-51.txt b/src/test/resources/bvt/parser/oracle-51.txt index 22bc762c8e..db95a2bac1 100644 --- a/src/test/resources/bvt/parser/oracle-51.txt +++ b/src/test/resources/bvt/parser/oracle-51.txt @@ -5,7 +5,8 @@ SELECT LPAD(' ',2*(LEVEL-1)) || last_name org_chart, START WITH job_id = 'AD_VP' CONNECT BY PRIOR employee_id = manager_id; --------------------------- -SELECT LPAD(' ', 2 * (LEVEL - 1)) || last_name AS org_chart, employee_id, manager_id, job_id +SELECT LPAD(' ', 2 * (LEVEL - 1)) || last_name AS org_chart + , employee_id, manager_id, job_id FROM employees WHERE job_id != 'FI_MGR' START WITH job_id = 'AD_VP' diff --git a/src/test/resources/bvt/parser/oracle-53.txt b/src/test/resources/bvt/parser/oracle-53.txt index 782435b8e4..a3b012aea2 100644 --- a/src/test/resources/bvt/parser/oracle-53.txt +++ b/src/test/resources/bvt/parser/oracle-53.txt @@ -7,9 +7,9 @@ SELECT e1.last_name FROM employees e1 --------------------------- SELECT e1.last_name FROM employees e1 -WHERE f(CURSOR(( +WHERE f(CURSOR( SELECT e2.hire_date FROM employees e2 WHERE e1.employee_id = e2.manager_id - )), e1.hire_date) = 1 -ORDER BY last_name; +), e1.hire_date) = 1 +ORDER BY last_name; \ No newline at end of file diff --git a/src/test/resources/bvt/parser/oracle-54.txt b/src/test/resources/bvt/parser/oracle-54.txt index a1c20af7b2..eadebb63be 100644 --- a/src/test/resources/bvt/parser/oracle-54.txt +++ b/src/test/resources/bvt/parser/oracle-54.txt @@ -1,25 +1,40 @@ select b.* from ( select * from (select row_.*, rownum rownum_ from ( select * from ( select '1' is_draft,a.IS_DISPLAY,a.score,a.type,a.repository_type,a.GMT_MODIFIED,ID from product_draft a where 1=1 and a.COMPANY_ID = ? and a.REPOSITORY_TYPE in ( ? , ? ) and upper(a.SUBJECT) like upper(?) and a.OWNER_MEMBER_ID in ( ? , ? , ? , ? , ? , ? , ? , ? , ? , ? ) and a.STATUS in ( ? , ? , ? , ? , ? , ? ) union all select '0' is_draft,a.IS_DISPLAY,a.score,a.type,a.repository_type,a.GMT_MODIFIED,ID from product a where a.draft_status = 'no_status' and a.COMPANY_ID = ? and a.REPOSITORY_TYPE in ( ? , ? ) and upper(a.SUBJECT) like upper(?) and a.OWNER_MEMBER_ID in ( ? , ? , ? , ? , ? , ? , ? , ? , ? , ? ) and a.STATUS in ( ? , ? , ? , ? , ? , ? ) ) order by type asc , "GMT_MODIFIED" desc , "ID" desc )row_ where rownum <= ? ) where rownum_ >= ? ) a, (select '1' as is_draft, id, m.ACTION_TRACE,m.TYPE,m.IMAGE_REPOSITORY_IDS,m.SUBJECT,m.MEMBER_ID,m.MEMBER_SEQ, m.REPOSITORY_TYPE,m.STATUS,m.GROUP_ID, m.GROUP_ID2,m.GROUP_ID3,m.GMT_MODIFIED,m.GMT_CREATE,m.COMPANY_ID, m.OWNER_MEMBER_ID,m.OWNER_MEMBER_SEQ,m.IND_BY_ALL,m.IND_BY_GROUP, m.IND_BY_GROUP2,m.IND_BY_GROUP3,m.HAVE_IMAGE,m.IMAGE_COUNT,m.IS_DISPLAY,m.RED_MODEL,m.KEYWORDS,m.EXPORT_TYPE, m.IMAGE_VERSION, m.SCORE from product_draft m union all select '0' as is_draft, id, NULL AS ACTION_TRACE,n.TYPE,n.IMAGE_REPOSITORY_IDS,n.SUBJECT,n.MEMBER_ID,n.MEMBER_SEQ,n.REPOSITORY_TYPE, n.STATUS,n.GROUP_ID,n.GROUP_ID2,n.GROUP_ID3,n.GMT_MODIFIED,n.GMT_CREATE,n.COMPANY_ID,n.OWNER_MEMBER_ID,n.OWNER_MEMBER_SEQ, n.IND_BY_ALL,n.IND_BY_GROUP,n.IND_BY_GROUP2,n.IND_BY_GROUP3,n.HAVE_IMAGE,n.IMAGE_COUNT,n.IS_DISPLAY,n.RED_MODEL,n.KEYWORDS, n.EXPORT_TYPE, n.IMAGE_VERSION, n.SCORE from product n) b where a.is_draft=b.is_draft and a.id=b.id order by b.type asc , b."GMT_MODIFIED" desc , b."ID" desc --------------------------- SELECT b.* -FROM (SELECT * - FROM (SELECT row_.*, rownum AS rownum_ - FROM (SELECT * - FROM (SELECT '1' AS is_draft, a.IS_DISPLAY, a.score, a.type, a.repository_type +FROM ( + SELECT * + FROM ( + SELECT row_.*, rownum AS rownum_ + FROM ( + SELECT * + FROM ( + SELECT '1' AS is_draft, a.IS_DISPLAY, a.score, a.type, a.repository_type , a.GMT_MODIFIED, ID FROM product_draft a - WHERE 1 = 1 AND a.COMPANY_ID = ? AND (a.REPOSITORY_TYPE IN (?, ?) AND upper(a.SUBJECT) LIKE upper(?) AND (a.OWNER_MEMBER_ID IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) AND a.STATUS IN (?, ?, ?, ?, ?, ?))) + WHERE 1 = 1 + AND a.COMPANY_ID = ? + AND a.REPOSITORY_TYPE IN (?, ?) + AND upper(a.SUBJECT) LIKE upper(?) + AND a.OWNER_MEMBER_ID IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) + AND a.STATUS IN (?, ?, ?, ?, ?, ?) UNION ALL SELECT '0' AS is_draft, a.IS_DISPLAY, a.score, a.type, a.repository_type , a.GMT_MODIFIED, ID FROM product a - WHERE a.draft_status = 'no_status' AND a.COMPANY_ID = ? AND (a.REPOSITORY_TYPE IN (?, ?) AND upper(a.SUBJECT) LIKE upper(?) AND (a.OWNER_MEMBER_ID IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) AND a.STATUS IN (?, ?, ?, ?, ?, ?))) - ) + WHERE a.draft_status = 'no_status' + AND a.COMPANY_ID = ? + AND a.REPOSITORY_TYPE IN (?, ?) + AND upper(a.SUBJECT) LIKE upper(?) + AND a.OWNER_MEMBER_ID IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) + AND a.STATUS IN (?, ?, ?, ?, ?, ?) + ) ORDER BY type ASC, "GMT_MODIFIED" DESC, "ID" DESC - ) row_ + ) row_ WHERE rownum <= ? - ) + ) WHERE rownum_ >= ? - ) a, (SELECT '1' AS is_draft, id, m.ACTION_TRACE, m.TYPE, m.IMAGE_REPOSITORY_IDS +) a, ( + SELECT '1' AS is_draft, id, m.ACTION_TRACE, m.TYPE, m.IMAGE_REPOSITORY_IDS , m.SUBJECT, m.MEMBER_ID, m.MEMBER_SEQ, m.REPOSITORY_TYPE, m.STATUS , m.GROUP_ID, m.GROUP_ID2, m.GROUP_ID3, m.GMT_MODIFIED, m.GMT_CREATE , m.COMPANY_ID, m.OWNER_MEMBER_ID, m.OWNER_MEMBER_SEQ, m.IND_BY_ALL, m.IND_BY_GROUP @@ -34,6 +49,7 @@ FROM (SELECT * , n.IND_BY_GROUP2, n.IND_BY_GROUP3, n.HAVE_IMAGE, n.IMAGE_COUNT, n.IS_DISPLAY , n.RED_MODEL, n.KEYWORDS, n.EXPORT_TYPE, n.IMAGE_VERSION, n.SCORE FROM product n - ) b -WHERE a.is_draft = b.is_draft AND a.id = b.id -ORDER BY b.type ASC, b."GMT_MODIFIED" DESC, b."ID" DESC; \ No newline at end of file +) b +WHERE a.is_draft = b.is_draft + AND a.id = b.id +ORDER BY b.type ASC, b."GMT_MODIFIED" DESC, b."ID" DESC \ No newline at end of file diff --git a/src/test/resources/bvt/parser/oracle-56.txt b/src/test/resources/bvt/parser/oracle-56.txt index 72c26c1b1d..80f9ac6c9a 100644 --- a/src/test/resources/bvt/parser/oracle-56.txt +++ b/src/test/resources/bvt/parser/oracle-56.txt @@ -61,21 +61,20 @@ END; --------------------------- DROP TABLE employees_temp; CREATE TABLE employees_temp - AS - SELECT employee_id, first_name, last_name - FROM employees; +AS +SELECT employee_id, first_name, last_name +FROM employees; DROP TABLE employees_temp2; CREATE TABLE employees_temp2 - AS - SELECT employee_id, first_name, last_name - FROM employees; +AS +SELECT employee_id, first_name, last_name +FROM employees; DECLARE - seq_value NUMBER + seq_value NUMBER; BEGIN seq_value := employees_seq.NEXTVAL; DBMS_OUTPUT.PUT_LINE('Initial sequence value: ' || TO_CHAR(seq_value)); - INSERT INTO employees_temp - (employee_id, first_name, last_name) + INSERT INTO employees_temp (employee_id, first_name, last_name) VALUES (employees_seq.NEXTVAL, 'Lynette', 'Smith'); INSERT INTO employees_temp2 VALUES (employees_seq.CURRVAL, 'Morgan', 'Smith'); @@ -85,7 +84,7 @@ BEGIN UPDATE employees_temp SET employee_id = employees_seq.NEXTVAL WHERE first_name = 'Lynette' - AND last_name = 'Smith'; + AND last_name = 'Smith'; seq_value := employees_seq.CURRVAL; DBMS_OUTPUT.PUT_LINE('Ending sequence value: ' || TO_CHAR(seq_value)); END; diff --git a/src/test/resources/bvt/parser/oracle-60.txt b/src/test/resources/bvt/parser/oracle-60.txt new file mode 100644 index 0000000000..0c1c62380a --- /dev/null +++ b/src/test/resources/bvt/parser/oracle-60.txt @@ -0,0 +1,10 @@ +SELECT empno, + deptno, + sal, + FIRST_VALUE(sal) IGNORE NULLS + OVER (PARTITION BY deptno ORDER BY sal) AS lowest_in_dept +FROM emp; +--------------------------- +SELECT empno, deptno, sal + , FIRST_VALUE(sal) IGNORE NULLS OVER (PARTITION BY deptno ORDER BY sal) AS lowest_in_dept +FROM emp; \ No newline at end of file