You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "FlyingZC (via GitHub)" <gi...@apache.org> on 2023/07/13 06:28:43 UTC

[GitHub] [shardingsphere] FlyingZC opened a new issue, #27066: Support parsing Oracle CREATE OR sql

FlyingZC opened a new issue, #27066:
URL: https://github.com/apache/shardingsphere/issues/27066

   # Background
   Hi community,
   This issue is for #26878.
   
   ShardingSphere parser engine helps users parse a SQL to get the AST (Abstract Syntax Tree) and visit this tree to get SQLStatement (Java Object). Currently, we are planning to enhance the support for Oracle SQL parsing in ShardingSphere.
   
   More details:
   https://shardingsphere.apache.org/document/current/en/reference/sharding/parse/
   
   # Task
   This issue is to support more oracle sql parse, as follows:
   ```sql
   CREATE OR REPLACE PACKAGE BODY p IS
     FUNCTION f (
       n NUMBER
     ) RETURN NUMBER
     IS
     BEGIN
       java_sleep(n);
        RETURN n;
     END f;
   END p;
   ```
   
   ```sql
   CREATE OR REPLACE PRIVATE OUTLINE my_salaries
      FROM salaries;
   ```
   
   ```sql
   CREATE OR REPLACE PACKAGE aa_pkg IS
     TYPE aa_type IS TABLE OF INTEGER INDEX BY VARCHAR2(15);
   END;
   ```
   
   ```sql
   CREATE OR REPLACE TRIGGER Contacts_Fwd_Xed
     BEFORE INSERT OR UPDATE ON Contacts_Table
     FOR EACH ROW
     FORWARD CROSSEDITION
     DISABLE
   BEGIN
     Set_First_And_Last_Name(
       :NEW.Name_1,
       :NEW.First_Name_2,
       :NEW.Last_Name_2
     );
     Set_Country_Code_And_Phone_No(
       :NEW.Phone_Number_1,
       :NEW.Country_Code_2,
       :NEW.Phone_Number_2
     );
   END Contacts_Fwd_Xed;
   ```
   
   ```sql
   CREATE OR REPLACE TRIGGER Check_Employee_Salary_Raise
     FOR UPDATE OF Salary ON Employees
   COMPOUND TRIGGER
     Ten_Percent                 CONSTANT NUMBER := 0.1;
     TYPE Salaries_t             IS TABLE OF Employees.Salary%TYPE;
     Avg_Salaries                Salaries_t;
     TYPE Department_IDs_t       IS TABLE OF Employees.Department_ID%TYPE;
     Department_IDs              Department_IDs_t;
   
     -- Declare collection type and variable:
   
     TYPE Department_Salaries_t  IS TABLE OF Employees.Salary%TYPE
                                   INDEX BY VARCHAR2(80);
     Department_Avg_Salaries     Department_Salaries_t;
   
     BEFORE STATEMENT IS
     BEGIN
       SELECT               AVG(e.Salary), NVL(e.Department_ID, -1)
         BULK COLLECT INTO  Avg_Salaries, Department_IDs
         FROM               Employees e
         GROUP BY           e.Department_ID;
       FOR j IN 1..Department_IDs.COUNT() LOOP
         Department_Avg_Salaries(Department_IDs(j)) := Avg_Salaries(j);
       END LOOP;
     END BEFORE STATEMENT;
   
     AFTER EACH ROW IS
     BEGIN
       IF :NEW.Salary - :Old.Salary >
         Ten_Percent*Department_Avg_Salaries(:NEW.Department_ID)
       THEN
         Raise_Application_Error(-20000, 'Raise too big');
       END IF;
     END AFTER EACH ROW;
   END Check_Employee_Salary_Raise;
   ```
   
   # Process
   1. First confirm that this is a correct oracle sql syntax, if not please ignore;
   2. Compare SQL definitions in Oficial SQL Doc and ShardingSphere SQL Doc;
   3. If there is any difference in ShardingSphere SQL Doc, please correct them by referring to the Official SQL Doc;
   4. Run mvn install the current_file_module;
   5. Check whether there are any exceptions. If indeed, please fix them. (Especially xxxVisitor.class);
   6. Add new corresponding SQL case in SQL Cases and expected parsed result in Expected Statment XML;
   7. Run SQLParserParameterizedTest to make sure no exceptions.
   
   # Relevant Skills
   1. Master JAVA language
   2. Have a basic understanding of Antlr `g4` file
   3. Be familiar with Oracle SQLs


-- 
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: notifications-unsubscribe@shardingsphere.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Support parsing Oracle CREATE OR sql [shardingsphere]

Posted by "zzzk1 (via GitHub)" <gi...@apache.org>.
zzzk1 commented on issue #27066:
URL: https://github.com/apache/shardingsphere/issues/27066#issuecomment-1962847956

   Hi, @strongduanmu pls assign this issue to me.


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Support parsing Oracle CREATE OR sql [shardingsphere]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #27066:
URL: https://github.com/apache/shardingsphere/issues/27066#issuecomment-2021368122

   There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] github-actions[bot] commented on issue #27066: Support parsing Oracle CREATE OR sql

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #27066:
URL: https://github.com/apache/shardingsphere/issues/27066#issuecomment-1676080897

   There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Support parsing Oracle CREATE OR sql [shardingsphere]

Posted by "terrymanu (via GitHub)" <gi...@apache.org>.
terrymanu commented on issue #27066:
URL: https://github.com/apache/shardingsphere/issues/27066#issuecomment-5328951462

   Hi @FlyingZC, thanks for reporting this.
   
   All five `CREATE OR REPLACE` statements listed in this issue are now supported by the Oracle parser on the current master:
   
   - `CREATE OR REPLACE PACKAGE BODY` with function definitions;
   - `CREATE OR REPLACE PRIVATE OUTLINE ... FROM ...` (#31283, with a covered SQL case in `create-outline.xml`);
   - `CREATE OR REPLACE PACKAGE` with `TYPE ... IS TABLE OF ... INDEX BY ...`;
   - `CREATE OR REPLACE TRIGGER ... FORWARD CROSSEDITION` (#39286);
   - `CREATE OR REPLACE TRIGGER ... COMPOUND TRIGGER` (#39286).
   
   We verified each sample SQL from this issue parses successfully with the generated Oracle parser on master. Since the parsing capability has landed, we are closing this issue. Adding SQL cases for cross-edition and compound triggers is still welcome as follow-up contributions.


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Support parsing Oracle CREATE OR sql [shardingsphere]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #27066:
URL: https://github.com/apache/shardingsphere/issues/27066#issuecomment-1784213271

   There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Support parsing Oracle CREATE OR sql [shardingsphere]

Posted by "terrymanu (via GitHub)" <gi...@apache.org>.
terrymanu closed issue #27066: Support parsing Oracle CREATE OR sql
URL: https://github.com/apache/shardingsphere/issues/27066


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Support parsing Oracle CREATE OR sql [shardingsphere]

Posted by "zzzk1 (via GitHub)" <gi...@apache.org>.
zzzk1 commented on issue #27066:
URL: https://github.com/apache/shardingsphere/issues/27066#issuecomment-1962861764

   > @zzzk1 Good job, I will assign it to you. Besides, can you send your wechat number to me? I might be able to help you more.
   sure, pls add my wechat at1742694934


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Support parsing Oracle CREATE OR sql [shardingsphere]

Posted by "strongduanmu (via GitHub)" <gi...@apache.org>.
strongduanmu commented on issue #27066:
URL: https://github.com/apache/shardingsphere/issues/27066#issuecomment-1962855292

   @zzzk1 Good job, I will assign it to you. Besides, can you send your wechat number to me? I might be able to help you more.
   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org