Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add DEFAULT_SQL_DIALECT for start-cli #14519

Merged
merged 1 commit into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions iotdb-client/cli/src/assembly/resources/sbin/start-cli.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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%

Expand Down Expand Up @@ -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%)
Expand Down
17 changes: 16 additions & 1 deletion iotdb-client/cli/src/assembly/resources/sbin/start-cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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 <ip>] [-p <port>] [-u <username>] [-pw <password>] [-D <name=value>] [-c] [-e sql]"
exit 0
Expand All @@ -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
Expand Down
Loading