FlyingZC opened a new issue, #27799: URL: https://github.com/apache/shardingsphere/issues/27799
# Background Hi community, 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 openGauss SQL parsing in ShardingSphere. More details: https://shardingsphere.apache.org/document/current/en/reference/sharding/parse/ # Task This issue is to support more openGauss sql parse, as follows: ```sql db_ignore=# create table t_not_null(num int not null); CREATE TABLE -- 采用忽略策略 db_ignore=# set sql_ignore_strategy = 'ignore_null'; SET db_ignore=# insert /*+ ignore_error */ into t_not_null values(null), (1); WARNING: null value in column "num" violates not-null constraint DETAIL: Failing row contains (null). INSERT 0 1 db_ignore=# select * from t_not_null ; num ----- 1 (1 row) db_ignore=# update /*+ ignore_error */ t_not_null set num = null where num = 1; WARNING: null value in column "num" violates not-null constraint DETAIL: Failing row contains (null). UPDATE 0 db_ignore=# select * from t_not_null ; num ----- 1 (1 row) -- 采用覆写策略 db_ignore=# delete from t_not_null; db_ignore=# set sql_ignore_strategy = 'overwrite_null'; SET db_ignore=# insert /*+ ignore_error */ into t_not_null values(null), (1); WARNING: null value in column "num" violates not-null constraint DETAIL: Failing row contains (null). INSERT 0 2 db_ignore=# select * from t_not_null ; num ----- 0 1 (2 rows) db_ignore=# update /*+ ignore_error */ t_not_null set num = null where num = 1; WARNING: null value in column "num" violates not-null constraint DETAIL: Failing row contains (null). UPDATE 1 db_ignore=# select * from t_not_null ; ``` ```sql db_ignore=# create table t_unique(num int unique); NOTICE: CREATE TABLE / UNIQUE will create implicit index "t_unique_num_key" for table "t_unique" CREATE TABLE db_ignore=# insert into t_unique values(1); INSERT 0 1 db_ignore=# insert /*+ ignore_error */ into t_unique values(1),(2); WARNING: duplicate key value violates unique constraint in table "t_unique" INSERT 0 1 db_ignore=# select * from t_unique; num ----- 1 2 (2 rows) db_ignore=# update /*+ ignore_error */ t_unique set num = 1 where num = 2; WARNING: duplicate key value violates unique constraint in table "t_unique" UPDATE 0 db_ignore=# select * from t_unique ; ``` ```sql db_ignore=# CREATE TABLE t_ignore db_ignore-# ( db_ignore(# col1 integer NOT NULL, db_ignore(# col2 character varying(60) db_ignore(# ) WITH(segment = on) PARTITION BY RANGE (col1) db_ignore-# ( db_ignore(# PARTITION P1 VALUES LESS THAN(5000), db_ignore(# PARTITION P2 VALUES LESS THAN(10000), db_ignore(# PARTITION P3 VALUES LESS THAN(15000) db_ignore(# ); CREATE TABLE db_ignore=# insert /*+ ignore_error */ into t_ignore values(20000); WARNING: inserted partition key does not map to any table partition INSERT 0 0 db_ignore=# select * from t_ignore ; col1 | col2 ------+------ (0 rows) db_ignore=# insert into t_ignore values(3000); INSERT 0 1 db_ignore=# select * from t_ignore ; col1 | col2 ------+------ 3000 | (1 row) db_ignore=# update /*+ ignore_error */ t_ignore set col1 = 20000 where col1 = 3000; WARNING: fail to update partitioned table "t_ignore".new tuple does not map to any table partition. UPDATE 0 db_ignore=# select * from t_ignore ; ``` ```sql -- 当新值类型与列类型同为数值类型 db_ignore=# create table t_tinyint(num tinyint); CREATE TABLE db_ignore=# insert /*+ ignore_error */ into t_tinyint values(10000); WARNING: tinyint out of range CONTEXT: referenced column: num INSERT 0 1 db_ignore=# select * from t_tinyint; num ----- 255 (1 row) -- 当新值类型与列类型同为字符类型时 db_ignore=# create table t_varchar5(content varchar(5)); CREATE TABLE db_ignore=# insert /*+ ignore_error */ into t_varchar5 values('abcdefghi'); WARNING: value too long for type character varying(5) CONTEXT: referenced column: content INSERT 0 1 db_ignore=# select * from t_varchar5 ; ``` ```sql VACUUM [FULL | ANALYZE] [ table ]; ``` # Process 1. First confirm that this is a correct openGauss sql syntax, if not please leave a message under the issue and ignore it; 2. Compare SQL definitions in Official 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 Statement 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 openGauss 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
