FlyingZC opened a new issue, #27821: URL: https://github.com/apache/shardingsphere/issues/27821
# 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 INSERT INTO customer_t1 DEFAULT VALUES; ``` ```sql SELECT nullif(TRUE::BOOLEAN,'2012-12-24'::DATE); ERROR: operator does not exist: boolean = timestamp without time zone LINE 1: SELECT nullif(TRUE::BOOLEAN,'2012-12-24'::DATE) FROM sys_dummy; ``` ```sql SELECT * SELECT * FROM join_a a JOIN join_b b ON a.b = b.b where a.b IS NOT NULL; ``` ```sql #!/bin/bash #set -ex #取消该行注释可帮助调试脚本 #资源名称 resName=sharding #资源binpath shardingPath=/home/test/home/apache-shardingsphere-5.1.1-shardingsphere-proxy-bin/bin #用于过滤资源实例的命令关键词 cmdKey=org.apache.shardingsphere.proxy.Bootstrap #用于保存首次检测到资源僵死时间的文件 phony_dead_time_file=.sharding_phony_dead_time #最长僵死时间,单位为s PHONY_MAX_TIME=20 function exec_start { #资源启动命令 sh ${shardingPath}/start.sh; exit $? } function exec_stop { #资源停止命令 sh ${shardingPath}/stop.sh; exit $? } function exec_check { #查询资源实例pid pid=`ps x | grep "$cmdKey" | grep -v grep | awk '{print $1}'` if [ "${pid}" == "" ]; then echo "$resName is not running." exit 1 fi #查询资源实例进程状态 state=`cat /proc/$pid/status | grep "State" | awk '{print $2}'` if [ "$state" == "T" ]; then #僵死检查和处理 if [ ! -f $phony_dead_time_file ]; then touch ./${phony_dead_time_file} echo "export firstphonytime=''" > ./${phony_dead_time_file} fi source ./$phony_dead_time_file; curtime=$(date +%s); if [ "$firstphonytime" == "" ]; then #首次检测到资源僵死,将首次检测到僵死的时间写入僵死时间存储文件 #firstphonytime为用于保存当前资源实例僵死时间的变量名称, #若当前节点存在多个自定义资源实例,该名称需要指定为不同的名称 echo "export firstphonytime=$curtime" > ./$phony_dead_time_file; exit 0; fi dead_time=$(( $curtime - $firstphonytime )); #若僵死时间大于等于用户设定的最大僵死时间,则立即杀死资源实例,否则不做处理正常退出 if [ $dead_time -ge $PHONY_MAX_TIME ]; then echo "$resName is detected in a state of phony dead(T) and will be forcibly killed!" kill -9 $pid rm ./${phony_dead_time_file} -f sh ${shardingPath}/start.sh; exit $? else exit 0 fi elif [ "$state" == "S" ]; then #未处于僵死状态清理环境后正常退出 rm ./${phony_dead_time_file} -f exit 0 fi } #以下为固定接口无需更改,必须实现 if [ $1 == '-start' ]; then exec_start $2 elif [ $1 == '-stop' ]; then exec_stop $2 elif [ $1 == '-check' ]; then exec_check $2 elif [ $1 == '-clean' ]; then exec_stop $2 elif [ $1 == '-reg' ]; then exit 0 elif [ $1 == '-unreg' ]; then exit 0 elif [ $1 == '-isreg' ]; ``` ```sql #!/bin/bash #set -ex #资源名称 resName=CM-RestAPI #资源binpath cmrestapiPath=/home/cmrestapi/cmrestapi-3.1.0-RELEASE.jar #资源启动命令关键词 cmdKey=cmrestapi-3.1.0-RELEASE.jar #用于保存首次检测到资源假死时间的文件 phony_dead_time_file=.cmrestapi_phony_dead_time #最长假死时间,单位为s PHONY_MAX_TIME=20 envFile=/home/cmrestapi/envfile #appWhiteListFile=/home/cmrestapi/appWhiteListFile source $envFile function exec_start { nohup java -jar -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=56m -Xms128m -Xmx128m -Xmn32m -Xss328k -XX:SurvivorRatio=8 -XX:+UseConcMarkSweepGC -Dserver.port=8080 $cmrestapiPath -e $envFile >> $GAUSSLOG/cm/cmrestapi/cmrestapi.log 2>&1 & exit $? } function exec_stop { ps x | grep "$cmdKey" | grep -v grep | awk '{print $1}' | xargs kill -9; exit $? } function exec_check { pid=`ps x | grep "$cmdKey" | grep -v grep | awk '{print $1}'` if [ "${pid}" == "" ]; then echo "$resName is not running." exit 1 fi state=`cat /proc/$pid/status | grep "State" | awk '{print $2}'` if [ "$state" == "T" ]; then if [ ! -f $phony_dead_time_file ]; then touch ./${phony_dead_time_file} echo "export firstphonytime=''" > ./${phony_dead_time_file} fi source ./$phony_dead_time_file; curtime=$(date +%s); if [ "$firstphonytime" == "" ]; then echo "export firstphonytime=$curtime" > ./$phony_dead_time_file; exit 0; fi dead_time=$(( $curtime - $firstphonytime )); if [ $dead_time -ge $PHONY_MAX_TIME ]; then echo "$resName is detected in a state of phony dead(T) and will be forcibly killed!" kill -9 $pid rm ./${phony_dead_time_file} -f exec_start else exit 0 fi elif [ "$state" == "S" ]; then rm ./${phony_dead_time_file} -f echo "$resName is running normally." exit 0 fi } if [ $1 == '-start' ]; then exec_start $2 elif [ $1 == '-stop' ]; then exec_stop $2 elif [ $1 == '-check' ]; then exec_check $2 elif [ $1 == '-clean' ]; then exec_stop $2 elif [ $1 == '-reg' ]; then exit 0 elif [ $1 == '-unreg' ]; then exit 0 elif [ $1 == '-isreg' ]; ``` # 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]
