Support parsing Oracle CREATE TABLE sql
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:
CREATE TABLE part_sales_by_time (time_id, prod_id, amount_sold,
quantity_sold)
PARTITION BY RANGE (time_id)
(
PARTITION old_data
VALUES LESS THAN (TO_DATE('01-01-1999', 'DD-MM-YYYY'))
PCTFREE 0
STORAGE (INITIAL 8M),
PARTITION quarter1
VALUES LESS THAN (TO_DATE('01-04-1999', 'DD-MM-YYYY'))
PCTFREE 0
STORAGE (INITIAL 8M),
PARTITION quarter2
VALUES LESS THAN (TO_DATE('01-07-1999', 'DD-MM-YYYY'))
PCTFREE 0
STORAGE (INITIAL 8M),
PARTITION quarter3
VALUES LESS THAN (TO_DATE('01-10-1999', 'DD-MM-YYYY'))
PCTFREE 0
STORAGE (INITIAL 8M),
PARTITION quarter4
VALUES LESS THAN (TO_DATE('01-01-2000', 'DD-MM-YYYY'))
PCTFREE 0
STORAGE (INITIAL 8M),
PARTITION max_partition
VALUES LESS THAN (MAXVALUE)
PCTFREE 0
STORAGE (INITIAL 8M)
)
AS
SELECT s.time_id, s.prod_id, s.amount_sold, s.quantity_sold
FROM sales s;
CREATE TABLE page_history
( id NUMBER NOT NULL
, url VARCHAR2(300) NOT NULL
, view_date DATE NOT NULL
, client_ip VARCHAR2(23) NOT NULL
, from_url VARCHAR2(300)
, to_url VARCHAR2(300)
, timing_in_seconds NUMBER
) PARTITION BY RANGE(view_date) INTERVAL (NUMTODSINTERVAL(1,'DAY'))
SUBPARTITION BY HASH(client_ip)
SUBPARTITIONS 32
(PARTITION p0 VALUES LESS THAN (TO_DATE('01-JAN-2006','dd-MON-yyyy')))
PARALLEL 32 COMPRESS;
CREATE TABLE oe.customers_sub (
customer_id NUMBER(6) PRIMARY KEY,
cust_first_name VARCHAR2(20),
cust_last_name VARCHAR2(20),
cust_address oe.cust_address_typ);
CREATE TABLE product_par_list
(prod_id, prod_name, prod_category,
prod_subcategory, prod_list_price)
PARTITION BY LIST (prod_category)
(PARTITION prod_cat1
VALUES ('Boys', 'Men'),
PARTITION prod_cat2
VALUES ('Girls', 'Women'))
AS
SELECT prod_id, prod_name, prod_category,
prod_subcategory, prod_list_price
FROM products;
CREATE TABLE people_reltab2 (
id NUMBER(4) CONSTRAINT pk_people_reltab2 PRIMARY KEY,
name_obj name_objtyp,
address_ref REF address_objtyp SCOPE IS address_objtab,
phones_ntab phone_ntabtyp)
NESTED TABLE phones_ntab STORE AS phone_store_ntab2 ;
CREATE INDEX address_ref_idx ON people_reltab2 (address_ref) ;
Process
- First confirm that this is a correct oracle sql syntax, if not please ignore;
- Compare SQL definitions in Oficial SQL Doc and ShardingSphere SQL Doc;
- If there is any difference in ShardingSphere SQL Doc, please correct them by referring to the Official SQL Doc;
- Run mvn install the current_file_module;
- Check whether there are any exceptions. If indeed, please fix them. (Especially xxxVisitor.class);
- Add new corresponding SQL case in SQL Cases and expected parsed result in Expected Statment XML;
- Run SQLParserParameterizedTest to make sure no exceptions.
Relevant Skills
- Master JAVA language
- Have a basic understanding of Antlr
g4file - Be familiar with Oracle SQLs
There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.
There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.