strongduanmu commented on code in PR #31226: URL: https://github.com/apache/shardingsphere/pull/31226#discussion_r1600952946
########## parser/sql/dialect/clickhouse/src/main/antlr4/imports/clickhouse/BaseRule.g4: ########## @@ -0,0 +1,322 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +grammar BaseRule; + +import LexerSymbol, LexerKeyword, LexerClickHouseKeyword, LexerLiterals; + + + +cluster: ON CLUSTER identifier; + + +parameterMarker + : QUESTION_ + ; + +literals + : stringLiterals + | numberLiterals + | dateTimeLiterals + | hexadecimalLiterals + | bitValueLiterals + | booleanLiterals + | nullValueLiterals + ; + +stringLiterals + : characterSetName? STRING_ collateClause? + ; + +numberLiterals + : (PLUS_ | MINUS_)? NUMBER_ + ; + +dateTimeLiterals + : (DATE | TIME | TIMESTAMP) STRING_ + | LBE_ identifier STRING_ RBE_ + ; + +hexadecimalLiterals + : characterSetName? HEX_DIGIT_ collateClause? + ; + +bitValueLiterals + : characterSetName? BIT_NUM_ collateClause? + ; + +booleanLiterals + : TRUE | FALSE + ; + +nullValueLiterals + : NULL + ; + +identifier + : IDENTIFIER_ + | unreservedWord + | interval + ; + +unreservedWord + : AFTER | ALIAS | ALL | ALTER | AND | ANTI | ANY | ARRAY | AS | ASCENDING | ASOF | AST | ASYNC | ATTACH | BETWEEN | BOTH | BY | CASE + | CAST | CHECK | CLEAR | CLUSTER | CODEC | COLLATE | COLUMN | COMMENT | CONSTRAINT | CREATE | CROSS | CUBE | CURRENT | DATABASE Review Comment: Please keep same indent with previous line. ########## parser/sql/dialect/clickhouse/src/main/antlr4/imports/clickhouse/BaseRule.g4: ########## @@ -0,0 +1,322 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +grammar BaseRule; + +import LexerSymbol, LexerKeyword, LexerClickHouseKeyword, LexerLiterals; + Review Comment: Please only keep one line here. ########## parser/sql/dialect/clickhouse/src/main/java/org/apache/shardingsphere/sql/parser/clickhouse/visitor/statement/type/ClickHouseRLStatementVisitor.java: ########## @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.shardingsphere.sql.parser.clickhouse.visitor.statement.type; + +import org.apache.shardingsphere.sql.parser.api.visitor.statement.type.RLStatementVisitor; +import org.apache.shardingsphere.sql.parser.clickhouse.visitor.statement.ClickHouseStatementVisitor; + +/** + * ClickHouse RL statement visitor. + */ +public class ClickHouseRLStatementVisitor extends ClickHouseStatementVisitor implements RLStatementVisitor { Review Comment: Please add final for this class. ########## parser/sql/dialect/clickhouse/src/main/java/org/apache/shardingsphere/sql/parser/clickhouse/visitor/statement/type/ClickHouseDDLStatementVisitor.java: ########## @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.shardingsphere.sql.parser.clickhouse.visitor.statement.type; + +import org.apache.shardingsphere.sql.parser.api.visitor.statement.type.DDLStatementVisitor; +import org.apache.shardingsphere.sql.parser.clickhouse.visitor.statement.ClickHouseStatementVisitor; + +/** + * ClickHouse DDL statement visitor. + */ +public class ClickHouseDDLStatementVisitor extends ClickHouseStatementVisitor implements DDLStatementVisitor { Review Comment: Please add final for this class. ########## parser/sql/dialect/clickhouse/src/main/java/org/apache/shardingsphere/sql/parser/clickhouse/visitor/statement/type/ClickHouseDCLStatementVisitor.java: ########## @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.shardingsphere.sql.parser.clickhouse.visitor.statement.type; + +import org.apache.shardingsphere.sql.parser.api.visitor.statement.type.DCLStatementVisitor; +import org.apache.shardingsphere.sql.parser.clickhouse.visitor.statement.ClickHouseStatementVisitor; + +/** + * ClickHouse DCL statement visitor. + */ +public class ClickHouseDCLStatementVisitor extends ClickHouseStatementVisitor implements DCLStatementVisitor { Review Comment: Please add final for this class. ########## parser/sql/dialect/clickhouse/src/main/java/org/apache/shardingsphere/sql/parser/clickhouse/visitor/statement/ClickHouseStatementVisitorFacade.java: ########## @@ -0,0 +1,73 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.shardingsphere.sql.parser.clickhouse.visitor.statement; + +import org.apache.shardingsphere.sql.parser.api.visitor.statement.type.DALStatementVisitor; +import org.apache.shardingsphere.sql.parser.api.visitor.statement.type.DCLStatementVisitor; +import org.apache.shardingsphere.sql.parser.api.visitor.statement.type.DDLStatementVisitor; +import org.apache.shardingsphere.sql.parser.api.visitor.statement.type.DMLStatementVisitor; +import org.apache.shardingsphere.sql.parser.api.visitor.statement.type.RLStatementVisitor; +import org.apache.shardingsphere.sql.parser.api.visitor.statement.type.TCLStatementVisitor; +import org.apache.shardingsphere.sql.parser.clickhouse.visitor.statement.type.ClickHouseDALStatementVisitor; +import org.apache.shardingsphere.sql.parser.clickhouse.visitor.statement.type.ClickHouseDCLStatementVisitor; +import org.apache.shardingsphere.sql.parser.clickhouse.visitor.statement.type.ClickHouseDDLStatementVisitor; +import org.apache.shardingsphere.sql.parser.clickhouse.visitor.statement.type.ClickHouseDMLStatementVisitor; +import org.apache.shardingsphere.sql.parser.clickhouse.visitor.statement.type.ClickHouseRLStatementVisitor; +import org.apache.shardingsphere.sql.parser.clickhouse.visitor.statement.type.ClickHouseTCLStatementVisitor; +import org.apache.shardingsphere.sql.parser.spi.SQLStatementVisitorFacade; + +/** + * Statement visitor facade for ClickHouse. + */ +public class ClickHouseStatementVisitorFacade implements SQLStatementVisitorFacade { Review Comment: Please add final for this class. ########## parser/sql/dialect/clickhouse/src/main/antlr4/imports/clickhouse/DMLStatement.g4: ########## @@ -0,0 +1,167 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +grammar DMLStatement; + +import BaseRule; + +insert + : INSERT INTO? tableName (insertValuesClause | insertSelectClause) + ; + +insertValuesClause + : columnNames? (VALUES ) assignmentValues (COMMA_ assignmentValues)* + ; + +insertSelectClause + : columnNames? select + ; + +assignmentValues + : LP_ assignmentValue (COMMA_ assignmentValue)* RP_ + | LP_ RP_ + ; + +update + : UPDATE tableReferences setAssignmentsClause whereClause? + ; + +setAssignmentsClause + : SET assignment (COMMA_ assignment)* + ; + +assignment + : columnName EQ_ VALUES? LP_? assignmentValue RP_? + ; + +assignmentValue + : expr | DEFAULT | blobValue + ; + +blobValue + : STRING_ + ; + +delete + : +// DELETE singleTableClause whereClause? Review Comment: Please remove useless sytax. ########## parser/sql/dialect/clickhouse/src/main/antlr4/imports/clickhouse/BaseRule.g4: ########## @@ -0,0 +1,322 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +grammar BaseRule; + +import LexerSymbol, LexerKeyword, LexerClickHouseKeyword, LexerLiterals; + + + +cluster: ON CLUSTER identifier; + + +parameterMarker + : QUESTION_ + ; + +literals + : stringLiterals + | numberLiterals + | dateTimeLiterals + | hexadecimalLiterals + | bitValueLiterals + | booleanLiterals + | nullValueLiterals + ; + +stringLiterals + : characterSetName? STRING_ collateClause? + ; + +numberLiterals + : (PLUS_ | MINUS_)? NUMBER_ + ; + +dateTimeLiterals + : (DATE | TIME | TIMESTAMP) STRING_ + | LBE_ identifier STRING_ RBE_ + ; + +hexadecimalLiterals + : characterSetName? HEX_DIGIT_ collateClause? + ; + +bitValueLiterals + : characterSetName? BIT_NUM_ collateClause? + ; + +booleanLiterals + : TRUE | FALSE + ; + +nullValueLiterals + : NULL + ; + +identifier + : IDENTIFIER_ + | unreservedWord + | interval + ; + +unreservedWord + : AFTER | ALIAS | ALL | ALTER | AND | ANTI | ANY | ARRAY | AS | ASCENDING | ASOF | AST | ASYNC | ATTACH | BETWEEN | BOTH | BY | CASE + | CAST | CHECK | CLEAR | CLUSTER | CODEC | COLLATE | COLUMN | COMMENT | CONSTRAINT | CREATE | CROSS | CUBE | CURRENT | DATABASE + | DATABASES | DATE | DEDUPLICATE | DEFAULT | DELAY | DELETE | DESCRIBE | DESC | DESCENDING | DETACH | DICTIONARIES | DICTIONARY | DISK + | DISTINCT | DISTRIBUTED | DROP | ELSE | END | ENGINE | EVENTS | EXISTS | EXPLAIN | EXPRESSION | EXTRACT | FETCHES | FINAL | FIRST + | FLUSH | FOR | FOLLOWING | FOR | FORMAT | FREEZE | FROM | FULL | FUNCTION | GLOBAL | GRANULARITY | GROUP | HAVING | HIERARCHICAL | ID + | IF | ILIKE | IN | INDEX | INJECTIVE | INNER | INSERT | INTERVAL | INTO | IS | IS_OBJECT_ID | JOIN | JSON_FALSE | JSON_TRUE | KEY + | KILL | LAST | LAYOUT | LEADING | LEFT | LIFETIME | LIKE | LIMIT | LIVE | LOCAL | LOGS | MATERIALIZE | MATERIALIZED | MAX | MERGES + | MIN | MODIFY | MOVE | MUTATION | NO | NOT | NULLS | OFFSET | ON | OPTIMIZE | OR | ORDER | OUTER | OUTFILE | OVER | PARTITION + | POPULATE | PRECEDING | PREWHERE | PRIMARY | RANGE | RELOAD | REMOVE | RENAME | REPLACE | REPLICA | REPLICATED | RIGHT | ROLLUP | ROW + | ROWS | SAMPLE | SELECT | SEMI | SENDS | SET | SETTINGS | SHOW | SOURCE | START | STOP | SUBSTRING | SYNC | SYNTAX | SYSTEM | TABLE + | TABLES | TEMPORARY | TEST | THEN | TIES | TIMEOUT | TIMESTAMP | TOTALS | TRAILING | TRIM | TRUNCATE | TO | TOP | TTL | TYPE + | UNBOUNDED | UNION | UPDATE | USE | USING | UUID | VALUES | VIEW | VOLUME | WATCH | WHEN | WHERE | WINDOW | WITH + ; +interval: SECOND | MINUTE | HOUR | DAY | WEEK | MONTH | QUARTER | YEAR; Review Comment: Please add new line before interval. ########## parser/sql/dialect/clickhouse/src/main/java/org/apache/shardingsphere/sql/parser/clickhouse/visitor/statement/type/ClickHouseDALStatementVisitor.java: ########## @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.shardingsphere.sql.parser.clickhouse.visitor.statement.type; + +import org.apache.shardingsphere.sql.parser.api.visitor.statement.type.DALStatementVisitor; +import org.apache.shardingsphere.sql.parser.clickhouse.visitor.statement.ClickHouseStatementVisitor; + +/** + * ClickHouse DAL statement visitor. + */ +public class ClickHouseDALStatementVisitor extends ClickHouseStatementVisitor implements DALStatementVisitor { Review Comment: Please add final for this class. ########## parser/sql/dialect/clickhouse/src/main/java/org/apache/shardingsphere/sql/parser/clickhouse/visitor/statement/type/ClickHouseTCLStatementVisitor.java: ########## @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.shardingsphere.sql.parser.clickhouse.visitor.statement.type; + +import org.apache.shardingsphere.sql.parser.api.visitor.statement.type.TCLStatementVisitor; +import org.apache.shardingsphere.sql.parser.clickhouse.visitor.statement.ClickHouseStatementVisitor; + +/** + * ClickHouse TCL statement visitor. + */ +public class ClickHouseTCLStatementVisitor extends ClickHouseStatementVisitor implements TCLStatementVisitor { Review Comment: Please add final for this class. -- 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]
