From 8ec3c966929c35a961a4ddc58afa4a45763c8d12 Mon Sep 17 00:00:00 2001 From: CritasWang Date: Mon, 23 Dec 2024 11:44:54 +0800 Subject: [PATCH] feat: add DEFAULT_SQL_DIALECT for start-cli --- .../src/assembly/resources/sbin/start-cli.bat | 10 ++++++++++ .../src/assembly/resources/sbin/start-cli.sh | 17 ++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/iotdb-client/cli/src/assembly/resources/sbin/start-cli.bat b/iotdb-client/cli/src/assembly/resources/sbin/start-cli.bat index d854965b4ec4..d00c6e65d964 100644 --- a/iotdb-client/cli/src/assembly/resources/sbin/start-cli.bat +++ b/iotdb-client/cli/src/assembly/resources/sbin/start-cli.bat @@ -19,6 +19,11 @@ @echo off +@REM DEFAULT_SQL_DIALECT is used to set the default SQL dialect for the CLI. +@REM empty value means using "tree". +@REM Optional values: "table" or "tree" +set DEFAULT_SQL_DIALECT=tree + @REM You can put your env variable here @REM set JAVA_HOME=%JAVA_HOME% @@ -73,13 +78,18 @@ set PARAMETERS=%* @REM if "%PARAMETERS%" == "" set PARAMETERS=-h 127.0.0.1 -p 6667 -u root -pw root +@REF if DEFAULT_SQL_DIALECT is empty, set it to "tree" +if "%DEFAULT_SQL_DIALECT%" == "" set DEFAULT_SQL_DIALECT=tree + @REM set default parameters set pw_parameter=-pw root set u_parameter=-u root set p_parameter=-p 6667 set h_parameter=-h 127.0.0.1 +set sql_dialect__parameter=-sql_dialect %DEFAULT_SQL_DIALECT% @REM Added parameters when default parameters are missing +echo %PARAMETERS% | findstr /c:"-sql_dialect ">nul && (set PARAMETERS=%PARAMETERS%) || (set PARAMETERS=%sql_dialect__parameter% %PARAMETERS%) echo %PARAMETERS% | findstr /c:"-pw ">nul && (set PARAMETERS=%PARAMETERS%) || (set PARAMETERS=%pw_parameter% %PARAMETERS%) echo %PARAMETERS% | findstr /c:"-u ">nul && (set PARAMETERS=%PARAMETERS%) || (set PARAMETERS=%u_parameter% %PARAMETERS%) echo %PARAMETERS% | findstr /c:"-p ">nul && (set PARAMETERS=%PARAMETERS%) || (set PARAMETERS=%p_parameter% %PARAMETERS%) diff --git a/iotdb-client/cli/src/assembly/resources/sbin/start-cli.sh b/iotdb-client/cli/src/assembly/resources/sbin/start-cli.sh index 0e5f7d92c880..1bb6a64375df 100755 --- a/iotdb-client/cli/src/assembly/resources/sbin/start-cli.sh +++ b/iotdb-client/cli/src/assembly/resources/sbin/start-cli.sh @@ -18,6 +18,11 @@ # under the License. # +# DEFAULT_SQL_DIALECT is used to set the default SQL dialect for the CLI. +# empty value means using "tree". +# Optional values: "table" or "tree" +DEFAULT_SQL_DIALECT= + # You can put your env variable here # export JAVA_HOME=$JAVA_HOME @@ -49,11 +54,17 @@ PARAMETERS="" # PARAMETERS="-h 127.0.0.1 -p 6667 -u root -pw root" # fi +# if DEFAULT_SQL_DIALECT is empty, set it to "tree" +if [ -z "$DEFAULT_SQL_DIALECT" ]; then + DEFAULT_SQL_DIALECT="tree" +fi + # Added parameters when default parameters are missing user_param="-u root" passwd_param="-pw root" host_param="-h 127.0.0.1" port_param="-p 6667" +sql_dialect_param="-sql_dialect $DEFAULT_SQL_DIALECT" while true; do case "$1" in @@ -77,6 +88,10 @@ while true; do checkEnvVariables $2 shift 2 ;; + -sql_dialect) + sql_dialect_param="-sql_dialect $2" + shift 2 + ;; --help) echo "Usage: $0 [-h ] [-p ] [-u ] [-pw ] [-D ] [-c] [-e sql]" exit 0 @@ -93,7 +108,7 @@ while true; do esac done -PARAMETERS="$host_param $port_param $user_param $passwd_param $PARAMETERS" +PARAMETERS="$host_param $port_param $user_param $passwd_param $sql_dialect_param $PARAMETERS" if [ -z "${IOTDB_INCLUDE}" ]; then #do nothing