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

[improvement][feature](nereids) Support date functions #44932 #45531

Conversation

cat-with-cat
Copy link
Contributor

What problem does this PR solve?

Issue Number: #44932

@Thearas
Copy link
Contributor

Thearas commented Dec 17, 2024

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

Copy link
Contributor

sh-checker report

To get the full details, please check in the job output.

shellcheck errors

'shellcheck ' returned error 1 finding the following syntactical issues:

----------

In create-clickbench-table.sh line 27:
  cd "$ROOT"
      ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
  cd "${ROOT}"


In create-clickbench-table.sh line 43:
  -n $0 \
     ^-- SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
  -n "$0" \


In create-clickbench-table.sh line 47:
eval set -- "$OPTS"
             ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
eval set -- "${OPTS}"


In create-clickbench-table.sh line 50:
if [ $# == 0 ]; then
   ^---------^ SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.

Did you mean: 
if [[ $# == 0 ]]; then


In create-clickbench-table.sh line 73:
  exit
  ^--^ SC2317 (info): Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


In create-clickbench-table.sh line 79:
  if ! $CMD; then
       ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
  if ! ${CMD}; then


In create-clickbench-table.sh line 80:
    echo "$NAME is missing. This script depends on mysql to create tables in Doris."
          ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    echo "${NAME} is missing. This script depends on mysql to create tables in Doris."


In create-clickbench-table.sh line 87:
source $CURDIR/conf/doris-cluster.conf
       ^-----------------------------^ SC1091 (info): Not following: ./conf/doris-cluster.conf: openBinaryFile: does not exist (No such file or directory)
       ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
       ^-----^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
source "${CURDIR}"/conf/doris-cluster.conf


In create-clickbench-table.sh line 88:
echo "FE_HOST: $FE_HOST"
               ^------^ SC2154 (warning): FE_HOST is referenced but not assigned.
               ^------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
echo "FE_HOST: ${FE_HOST}"


In create-clickbench-table.sh line 89:
echo "FE_QUERY_PORT: $FE_QUERY_PORT"
                     ^------------^ SC2154 (warning): FE_QUERY_PORT is referenced but not assigned.
                     ^------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
echo "FE_QUERY_PORT: ${FE_QUERY_PORT}"


In create-clickbench-table.sh line 90:
echo "USER: $USER"
            ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
echo "USER: ${USER}"


In create-clickbench-table.sh line 91:
echo "PASSWORD: $PASSWORD"
                ^-------^ SC2154 (warning): PASSWORD is referenced but not assigned.
                ^-------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
echo "PASSWORD: ${PASSWORD}"


In create-clickbench-table.sh line 92:
echo "DB: $DB"
          ^-^ SC2154 (warning): DB is referenced but not assigned.
          ^-^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
echo "DB: ${DB}"


In create-clickbench-table.sh line 94:
OUTPUT=$(mysql -h$FE_HOST -u$USER -P$FE_QUERY_PORT -e "CREATE DATABASE IF NOT EXISTS $DB")
                 ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                 ^------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                            ^---^ SC2086 (info): Double quote to prevent globbing and word splitting.
                            ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                    ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                    ^------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                                                                     ^-^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
OUTPUT=$(mysql -h"${FE_HOST}" -u"${USER}" -P"${FE_QUERY_PORT}" -e "CREATE DATABASE IF NOT EXISTS ${DB}")


In create-clickbench-table.sh line 95:
if [[ $? -ne 0 ]]; then
      ^-- SC2181 (style): Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?.


In create-clickbench-table.sh line 96:
  echo "Error: Failed to create database: $DB"
                                          ^-^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
  echo "Error: Failed to create database: ${DB}"


In create-clickbench-table.sh line 97:
  echo "mysql error message: $OUTPUT"
                             ^-----^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
  echo "mysql error message: ${OUTPUT}"


In create-clickbench-table.sh line 100:
OUTPUT=$(mysql -h$FE_HOST -u$USER -P$FE_QUERY_PORT -D$DB <$CURDIR/sql/create-clickbench-table.sql)
                 ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                 ^------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                            ^---^ SC2086 (info): Double quote to prevent globbing and word splitting.
                            ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                    ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                    ^------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                                     ^-^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                     ^-^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                                          ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                          ^-----^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
OUTPUT=$(mysql -h"${FE_HOST}" -u"${USER}" -P"${FE_QUERY_PORT}" -D"${DB}" <"${CURDIR}"/sql/create-clickbench-table.sql)


In create-clickbench-table.sh line 101:
if [[ $? -ne 0 ]]; then
      ^-- SC2181 (style): Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?.


In create-clickbench-table.sh line 103:
  echo "mysql error message: $OUTPUT"
                             ^-----^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
  echo "mysql error message: ${OUTPUT}"


In create-clickbench-table.sh line 106:
OUTPUT=$(mysql -h$FE_HOST -u$USER -P$FE_QUERY_PORT -D$DB -e "show create table hits;")
                 ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                 ^------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                            ^---^ SC2086 (info): Double quote to prevent globbing and word splitting.
                            ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                    ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                    ^------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                                     ^-^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                     ^-^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
OUTPUT=$(mysql -h"${FE_HOST}" -u"${USER}" -P"${FE_QUERY_PORT}" -D"${DB}" -e "show create table hits;")


In create-clickbench-table.sh line 107:
if [[ $? -ne 0 ]]; then
      ^-- SC2181 (style): Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?.


In create-clickbench-table.sh line 108:
  echo "Error:  Failed to execute 'show create table hits;' in database $DB."
                                                                        ^-^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
  echo "Error:  Failed to execute 'show create table hits;' in database ${DB}."


In create-clickbench-table.sh line 109:
  echo "mysql error message: $OUTPUT"
                             ^-----^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
  echo "mysql error message: ${OUTPUT}"


In load-clickbench-data.sh line 27:
    cd "$ROOT"
        ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    cd "${ROOT}"


In load-clickbench-data.sh line 32:
DATA_DIR=$CURDIR/
         ^-----^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
DATA_DIR=${CURDIR}/


In load-clickbench-data.sh line 50:
    -n $0 \
       ^-- SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    -n "$0" \


In load-clickbench-data.sh line 54:
eval set -- "$OPTS"
             ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
eval set -- "${OPTS}"


In load-clickbench-data.sh line 87:
    if ! $CMD; then
         ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    if ! ${CMD}; then


In load-clickbench-data.sh line 88:
        echo "$NAME is missing. This script depends on cURL to load data to Doris."
              ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
        echo "${NAME} is missing. This script depends on cURL to load data to Doris."


In load-clickbench-data.sh line 97:
source $CURDIR/conf/doris-cluster.conf
       ^-----------------------------^ SC1091 (info): Not following: ./conf/doris-cluster.conf: openBinaryFile: does not exist (No such file or directory)
       ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
       ^-----^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
source "${CURDIR}"/conf/doris-cluster.conf


In load-clickbench-data.sh line 101:
echo "FE_HOST: $FE_HOST"
               ^------^ SC2154 (warning): FE_HOST is referenced but not assigned.
               ^------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
echo "FE_HOST: ${FE_HOST}"


In load-clickbench-data.sh line 102:
echo "FE_HTTP_PORT: $FE_HTTP_PORT"
                    ^-----------^ SC2154 (warning): FE_HTTP_PORT is referenced but not assigned.
                    ^-----------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
echo "FE_HTTP_PORT: ${FE_HTTP_PORT}"


In load-clickbench-data.sh line 103:
echo "USER: $USER"
            ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
echo "USER: ${USER}"


In load-clickbench-data.sh line 104:
echo "PASSWORD: $PASSWORD"
                ^-------^ SC2154 (warning): PASSWORD is referenced but not assigned.
                ^-------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
echo "PASSWORD: ${PASSWORD}"


In load-clickbench-data.sh line 105:
echo "DB: $DB"
          ^-^ SC2154 (warning): DB is referenced but not assigned.
          ^-^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
echo "DB: ${DB}"


In load-clickbench-data.sh line 108:
    cv=$(mysql -h$FE_HOST -P$FE_QUERY_PORT -u$USER -e 'admin show frontend config' | grep 'stream_load_default_timeout_second' | awk '{print $2}')
                 ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                 ^------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                            ^------------^ SC2154 (warning): FE_QUERY_PORT is referenced but not assigned.
                            ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                            ^------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                             ^---^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                             ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    cv=$(mysql -h"${FE_HOST}" -P"${FE_QUERY_PORT}" -u"${USER}" -e 'admin show frontend config' | grep 'stream_load_default_timeout_second' | awk '{print $2}')


In load-clickbench-data.sh line 125:
    if (($cv < 3600)); then
         ^-^ SC2004 (style): $/${} is unnecessary on arithmetic variables.
         ^-^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    if ((${cv} < 3600)); then


In load-clickbench-data.sh line 129:
    cv=$(curl "${BE_HOST}:${BE_WEBSERVER_PORT}/varz" 2>/dev/null | grep 'streaming_load_max_mb' | awk -F'=' '{print $2}')
               ^--------^ SC2154 (warning): BE_HOST is referenced but not assigned.
                          ^------------------^ SC2154 (warning): BE_WEBSERVER_PORT is referenced but not assigned.


In load-clickbench-data.sh line 146:
    if (($cv < 16000)); then
         ^-^ SC2004 (style): $/${} is unnecessary on arithmetic variables.
         ^-^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    if ((${cv} < 16000)); then


In load-clickbench-data.sh line 153:
    need_download=false
    ^-----------^ SC2034 (warning): need_download appears unused. Verify use (or export if used externally).


In load-clickbench-data.sh line 154:
    cd $DATA_DIR
       ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
       ^-------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    cd "${DATA_DIR}"


In load-clickbench-data.sh line 156:
        if [ ! -f "$DATA_DIR/hits_split${i}" ]; then
           ^-- SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
                   ^-------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
        if [[ ! -f "${DATA_DIR}/hits_split${i}" ]]; then


In load-clickbench-data.sh line 157:
            echo "will download hits_split${i} to $DATA_DIR"
                                                  ^-------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
            echo "will download hits_split${i} to ${DATA_DIR}"


In load-clickbench-data.sh line 160:
            wget_pids[${#wget_pids[@]}]=$PID
                                        ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
            wget_pids[${#wget_pids[@]}]=${PID}


In load-clickbench-data.sh line 168:
    echo "(2/2) load clickbench data file $DATA_DIR/hits_split[0-9] into Doris"
                                          ^-------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    echo "(2/2) load clickbench data file ${DATA_DIR}/hits_split[0-9] into Doris"


In load-clickbench-data.sh line 174:
                -u $USER:$PASSWORD \
                   ^---^ SC2086 (info): Double quote to prevent globbing and word splitting.
                   ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                         ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                         ^-------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
                -u "${USER}":"${PASSWORD}" \


In load-clickbench-data.sh line 175:
                -T "$DATA_DIR/hits_split${i}" \
                    ^-------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
                -T "${DATA_DIR}/hits_split${i}" \


In load-clickbench-data.sh line 177:
                http://$FE_HOST:$FE_HTTP_PORT/api/$DB/hits/_stream_load
                       ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                       ^------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                ^-----------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                ^-----------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                                  ^-^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                  ^-^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
                http://"${FE_HOST}":"${FE_HTTP_PORT}"/api/"${DB}"/hits/_stream_load


In load-clickbench-data.sh line 180:
                -u $USER:$PASSWORD \
                   ^---^ SC2086 (info): Double quote to prevent globbing and word splitting.
                   ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                         ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                         ^-------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
                -u "${USER}":"${PASSWORD}" \


In load-clickbench-data.sh line 181:
                -T "$DATA_DIR/hits_split${i}" \
                    ^-------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
                -T "${DATA_DIR}/hits_split${i}" \


In load-clickbench-data.sh line 184:
                http://$FE_HOST:$FE_HTTP_PORT/api/$DB/hits/_stream_load
                       ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                       ^------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                ^-----------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                ^-----------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                                  ^-^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                  ^-^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
                http://"${FE_HOST}":"${FE_HTTP_PORT}"/api/"${DB}"/hits/_stream_load


In load-clickbench-data.sh line 191:
    for PID in ${wget_pids[@]}; do
               ^-------------^ SC2068 (error): Double quote array expansions to avoid re-splitting elements.


In load-clickbench-data.sh line 192:
        kill -9 $PID
                ^--^ SC2086 (info): Double quote to prevent globbing and word splitting.
                ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
        kill -9 "${PID}"


In load-clickbench-data.sh line 206:
  echo $@
       ^-- SC2068 (error): Double quote array expansions to avoid re-splitting elements.


In load-clickbench-data.sh line 207:
  OUTPUT=$(mysql -h$FE_HOST -u$USER -P$FE_QUERY_PORT -D$DB -e "$@")
                   ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                   ^------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                              ^---^ SC2086 (info): Double quote to prevent globbing and word splitting.
                              ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                      ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                      ^------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                                       ^-^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                       ^-^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
  OUTPUT=$(mysql -h"${FE_HOST}" -u"${USER}" -P"${FE_QUERY_PORT}" -D"${DB}" -e "$@")


In load-clickbench-data.sh line 208:
  if [[ $? -ne 0 ]]; then
        ^-- SC2181 (style): Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?.


In load-clickbench-data.sh line 210:
    echo "mysql error message: $OUTPUT"
                               ^-----^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    echo "mysql error message: ${OUTPUT}"


In run-clickbench-queries.sh line 27:
  cd "$ROOT"
      ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
  cd "${ROOT}"


In run-clickbench-queries.sh line 32:
QUERIES_FILE=$CURDIR/sql/queries.sql
             ^-----^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
QUERIES_FILE=${CURDIR}/sql/queries.sql


In run-clickbench-queries.sh line 44:
  -n $0 \
     ^-- SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
  -n "$0" \


In run-clickbench-queries.sh line 49:
eval set -- "$OPTS"
             ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
eval set -- "${OPTS}"


In run-clickbench-queries.sh line 52:
if [ $# == 0 ]; then
   ^---------^ SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.

Did you mean: 
if [[ $# == 0 ]]; then


In run-clickbench-queries.sh line 75:
  exit
  ^--^ SC2317 (info): Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


In run-clickbench-queries.sh line 81:
  if ! $CMD; then
       ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
  if ! ${CMD}; then


In run-clickbench-queries.sh line 82:
    echo "$NAME is missing. This script depends on mysql to create tables in Doris."
          ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    echo "${NAME} is missing. This script depends on mysql to create tables in Doris."


In run-clickbench-queries.sh line 90:
source $CURDIR/conf/doris-cluster.conf
       ^-----------------------------^ SC1091 (info): Not following: ./conf/doris-cluster.conf: openBinaryFile: does not exist (No such file or directory)
       ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
       ^-----^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
source "${CURDIR}"/conf/doris-cluster.conf


In run-clickbench-queries.sh line 91:
export MYSQL_PWD=$PASSWORD
                 ^-------^ SC2154 (warning): PASSWORD is referenced but not assigned.
                 ^-------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
export MYSQL_PWD=${PASSWORD}


In run-clickbench-queries.sh line 93:
echo "FE_HOST: $FE_HOST"
               ^------^ SC2154 (warning): FE_HOST is referenced but not assigned.
               ^------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
echo "FE_HOST: ${FE_HOST}"


In run-clickbench-queries.sh line 94:
echo "FE_QUERY_PORT: $FE_QUERY_PORT"
                     ^------------^ SC2154 (warning): FE_QUERY_PORT is referenced but not assigned.
                     ^------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
echo "FE_QUERY_PORT: ${FE_QUERY_PORT}"


In run-clickbench-queries.sh line 95:
echo "USER: $USER"
            ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
echo "USER: ${USER}"


In run-clickbench-queries.sh line 96:
echo "PASSWORD: $PASSWORD"
                ^-------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
echo "PASSWORD: ${PASSWORD}"


In run-clickbench-queries.sh line 97:
echo "DB: $DB"
          ^-^ SC2154 (warning): DB is referenced but not assigned.
          ^-^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
echo "DB: ${DB}"


In run-clickbench-queries.sh line 100:
  echo $@
       ^-- SC2068 (error): Double quote array expansions to avoid re-splitting elements.


In run-clickbench-queries.sh line 101:
  OUTPUT=(mysql -h$FE_HOST -u$USER -P$FE_QUERY_PORT -D$DB -e "$@")
                  ^------^ SC2206 (warning): Quote to prevent word splitting/globbing, or split robustly with mapfile or read -a.
                  ^------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                             ^---^ SC2206 (warning): Quote to prevent word splitting/globbing, or split robustly with mapfile or read -a.
                             ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                     ^------------^ SC2206 (warning): Quote to prevent word splitting/globbing, or split robustly with mapfile or read -a.
                                     ^------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                                      ^-^ SC2206 (warning): Quote to prevent word splitting/globbing, or split robustly with mapfile or read -a.
                                                      ^-^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
  OUTPUT=(mysql -h${FE_HOST} -u${USER} -P${FE_QUERY_PORT} -D${DB} -e "$@")


In run-clickbench-queries.sh line 102:
  if [[ $? -ne 0 ]]; then
        ^-- SC2181 (style): Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?.


In run-clickbench-queries.sh line 104:
    echo "mysql error message: $OUTPUT"
                               ^-----^ SC2128 (warning): Expanding an array without an index only gives the first element.
                               ^-----^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    echo "mysql error message: ${OUTPUT}"


In run-clickbench-queries.sh line 139:
cat ${QUERIES_FILE} | while read query; do
    ^-------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                            ^--^ SC2162 (info): read without -r will mangle backslashes.

Did you mean: 
cat "${QUERIES_FILE}" | while read query; do


In run-clickbench-queries.sh line 140:
  if [[ ! $query == SELECT* ]]; then
          ^----^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
  if [[ ! ${query} == SELECT* ]]; then


In run-clickbench-queries.sh line 147:
  for i in $(seq 1 $TRIES); do
                   ^----^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                   ^----^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
  for i in $(seq 1 "${TRIES}"); do


In run-clickbench-queries.sh line 148:
    RES=$(mysql -vvv -h$FE_HOST -u$USER -P$FE_QUERY_PORT -D$DB -e "${query}" | perl -nle 'print $1 if /\((\d+\.\d+)+ sec\)/' || :)
                       ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                       ^------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                  ^---^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                  ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                          ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                          ^------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                                           ^-^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                           ^-^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    RES=$(mysql -vvv -h"${FE_HOST}" -u"${USER}" -P"${FE_QUERY_PORT}" -D"${DB}" -e "${query}" | perl -nle 'print $1 if /\((\d+\.\d+)+ sec\)/' || :)


In run-clickbench-queries.sh line 157:
    [[ "$i" != $TRIES ]] && echo -n "," | tee -a result.csv
        ^-- SC2250 (style): Prefer putting braces around variable references even when not strictly required.
               ^----^ SC2053 (warning): Quote the right-hand side of != in [[ ]] to prevent glob matching.
               ^----^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    [[ "${i}" != ${TRIES} ]] && echo -n "," | tee -a result.csv

For more information:
  https://www.shellcheck.net/wiki/SC2068 -- Double quote array expansions to ...
  https://www.shellcheck.net/wiki/SC2034 -- need_download appears unused. Ver...
  https://www.shellcheck.net/wiki/SC2053 -- Quote the right-hand side of != i...
----------

You can address the above issues in one of three ways:
1. Manually correct the issue in the offending shell script;
2. Disable specific issues by adding the comment:
  # shellcheck disable=NNNN
above the line that contains the issue, where NNNN is the error code;
3. Add '-e NNNN' to the SHELLCHECK_OPTS setting in your .yml action file.



shfmt errors

'shfmt ' returned error 1 finding the following formatting issues:

----------
--- create-clickbench-table.sh.orig
+++ create-clickbench-table.sh
@@ -24,62 +24,62 @@
 
 ROOT=$(dirname "$0")
 ROOT=$(
-  cd "$ROOT"
-  pwd
+    cd "$ROOT"
+    pwd
 )
 
 CURDIR=${ROOT}
 
 usage() {
-  echo "
+    echo "
 This script is used to create ClickBench table, 
 will use mysql client to connect Doris server which is specified in conf/doris-cluster.conf file.
 Usage: $0 
   "
-  exit 1
+    exit 1
 }
 
 OPTS=$(getopt \
-  -n $0 \
-  -o '' \
-  -- "$@")
+    -n $0 \
+    -o '' \
+    -- "$@")
 
 eval set -- "$OPTS"
 HELP=0
 
 if [ $# == 0 ]; then
-  usage
+    usage
 fi
 
 while true; do
-  case "$1" in
-  -h)
-    HELP=1
-    shift
-    ;;
-  --)
-    shift
-    break
-    ;;
-  *)
-    echo "Internal error"
-    exit 1
-    ;;
-  esac
+    case "$1" in
+    -h)
+        HELP=1
+        shift
+        ;;
+    --)
+        shift
+        break
+        ;;
+    *)
+        echo "Internal error"
+        exit 1
+        ;;
+    esac
 done
 
 if [[ "${HELP}" -eq 1 ]]; then
-  usage
-  exit
+    usage
+    exit
 fi
 
 check_prerequest() {
-  local CMD=$1
-  local NAME=$2
-  if ! $CMD; then
-    echo "$NAME is missing. This script depends on mysql to create tables in Doris."
-    exit 1
-  fi
+    local CMD=$1
+    local NAME=$2
+    if ! $CMD; then
+        echo "$NAME is missing. This script depends on mysql to create tables in Doris."
+        exit 1
+    fi
 }
 
 check_prerequest "mysql --version" "mysql"
@@ -93,21 +93,21 @@
 
 OUTPUT=$(mysql -h$FE_HOST -u$USER -P$FE_QUERY_PORT -e "CREATE DATABASE IF NOT EXISTS $DB")
 if [[ $? -ne 0 ]]; then
-  echo "Error: Failed to create database: $DB"
-  echo "mysql error message: $OUTPUT"
-  exit 1
+    echo "Error: Failed to create database: $DB"
+    echo "mysql error message: $OUTPUT"
+    exit 1
 fi
 OUTPUT=$(mysql -h$FE_HOST -u$USER -P$FE_QUERY_PORT -D$DB <$CURDIR/sql/create-clickbench-table.sql)
 if [[ $? -ne 0 ]]; then
-  echo "Error:  Failed to execute the SQL script"
-  echo "mysql error message: $OUTPUT"
-  exit 1
+    echo "Error:  Failed to execute the SQL script"
+    echo "mysql error message: $OUTPUT"
+    exit 1
 fi
 OUTPUT=$(mysql -h$FE_HOST -u$USER -P$FE_QUERY_PORT -D$DB -e "show create table hits;")
 if [[ $? -ne 0 ]]; then
-  echo "Error:  Failed to execute 'show create table hits;' in database $DB."
-  echo "mysql error message: $OUTPUT"
-  exit 1
+    echo "Error:  Failed to execute 'show create table hits;' in database $DB."
+    echo "mysql error message: $OUTPUT"
+    exit 1
 fi
 
 echo "DONE."
--- load-clickbench-data.sh.orig
+++ load-clickbench-data.sh
@@ -142,7 +142,7 @@
         echo "Error: Failed to extract the value using awk."
         exit 1
     fi
-    
+
     if (($cv < 16000)); then
         echo -e "advise: revise your Doris BE's conf to set 'streaming_load_max_mb=16000' or above and 'flush_thread_num_per_store=5' to speed up load."
     fi
@@ -203,13 +203,13 @@
 echo "load cost time: $((end - start)) seconds"
 
 run_sql() {
-  echo $@
-  OUTPUT=$(mysql -h$FE_HOST -u$USER -P$FE_QUERY_PORT -D$DB -e "$@")
-  if [[ $? -ne 0 ]]; then
-    echo "Error: Failed to execute the SQL command"
-    echo "mysql error message: $OUTPUT"
-    exit 1
-fi
+    echo $@
+    OUTPUT=$(mysql -h$FE_HOST -u$USER -P$FE_QUERY_PORT -D$DB -e "$@")
+    if [[ $? -ne 0 ]]; then
+        echo "Error: Failed to execute the SQL command"
+        echo "mysql error message: $OUTPUT"
+        exit 1
+    fi
 }
 
 echo '============================================'
--- run-clickbench-queries.sh.orig
+++ run-clickbench-queries.sh
@@ -24,64 +24,64 @@
 
 ROOT=$(dirname "$0")
 ROOT=$(
-  cd "$ROOT"
-  pwd
+    cd "$ROOT"
+    pwd
 )
 
 CURDIR=${ROOT}
 QUERIES_FILE=$CURDIR/sql/queries.sql
 
 usage() {
-  echo "
+    echo "
 This script is used to run ClickBench 43 queries, 
 will use mysql client to connect Doris server which parameter is specified in conf/doris-cluster.conf file.
 Usage: $0 
   "
-  exit 1
+    exit 1
 }
 
 OPTS=$(getopt \
-  -n $0 \
-  -o '' \
-  -o 'h' \
-  -- "$@")
+    -n $0 \
+    -o '' \
+    -o 'h' \
+    -- "$@")
 
 eval set -- "$OPTS"
 HELP=0
 
 if [ $# == 0 ]; then
-  usage
+    usage
 fi
 
 while true; do
-  case "$1" in
-  -h)
-    HELP=1
-    shift
-    ;;
-  --)
-    shift
-    break
-    ;;
-  *)
-    echo "Internal error"
-    exit 1
-    ;;
-  esac
+    case "$1" in
+    -h)
+        HELP=1
+        shift
+        ;;
+    --)
+        shift
+        break
+        ;;
+    *)
+        echo "Internal error"
+        exit 1
+        ;;
+    esac
 done
 
 if [[ "${HELP}" -eq 1 ]]; then
-  usage
-  exit
+    usage
+    exit
 fi
 
 check_prerequest() {
-  local CMD=$1
-  local NAME=$2
-  if ! $CMD; then
-    echo "$NAME is missing. This script depends on mysql to create tables in Doris."
-    exit 1
-  fi
+    local CMD=$1
+    local NAME=$2
+    if ! $CMD; then
+        echo "$NAME is missing. This script depends on mysql to create tables in Doris."
+        exit 1
+    fi
 }
 
 check_prerequest "mysql --version" "mysql"
@@ -97,31 +97,31 @@
 echo "DB: $DB"
 
 run_sql() {
-  echo $@
-  OUTPUT=(mysql -h$FE_HOST -u$USER -P$FE_QUERY_PORT -D$DB -e "$@")
-  if [[ $? -ne 0 ]]; then
-    echo "Error: Failed to execute the SQL command"
-    echo "mysql error message: $OUTPUT"
-    exit 1
-  fi
+    echo $@
+    OUTPUT=(mysql -h$FE_HOST -u$USER -P$FE_QUERY_PORT -D$DB -e "$@")
+    if [[ $? -ne 0 ]]; then
+        echo "Error: Failed to execute the SQL command"
+        echo "mysql error message: $OUTPUT"
+        exit 1
+    fi
 }
 
 get_session_variable() {
-  k="$1"
-  v=$(mysql -h"${FE_HOST}" -u"${USER}" -P"${FE_QUERY_PORT}" -D"${DB}" -e"show variables like '${k}'\G" | grep " Value: ")
+    k="$1"
+    v=$(mysql -h"${FE_HOST}" -u"${USER}" -P"${FE_QUERY_PORT}" -D"${DB}" -e"show variables like '${k}'\G" | grep " Value: ")
 
-  if [[ ${PIPESTATUS[0]} -ne 0 ]]; then
-    echo "Error: Failed to execute SQL command: show variables like '${k}'\G"
-    exit 1
-  fi
-  if [[ ${PIPESTATUS[1]} -eq 1 ]]; then
-    echo "Warning: No lines containing ' Value: ' were found."
-    exit 1
-  elif [[ ${PIPESTATUS[1]} -eq 2 ]]; then
-    echo "Error: An error occurred while running grep."
-    exit 1
-  fi
-  echo "${v/*Value: /}"
+    if [[ ${PIPESTATUS[0]} -ne 0 ]]; then
+        echo "Error: Failed to execute SQL command: show variables like '${k}'\G"
+        exit 1
+    fi
+    if [[ ${PIPESTATUS[1]} -eq 1 ]]; then
+        echo "Warning: No lines containing ' Value: ' were found."
+        exit 1
+    elif [[ ${PIPESTATUS[1]} -eq 2 ]]; then
+        echo "Error: An error occurred while running grep."
+        exit 1
+    fi
+    echo "${v/*Value: /}"
 }
 
 _exec_mem_limit="$(get_session_variable exec_mem_limit)"
@@ -137,28 +137,28 @@
 truncate -s0 result.csv
 
 cat ${QUERIES_FILE} | while read query; do
-  if [[ ! $query == SELECT* ]]; then
-    continue
-  fi
-  sync
-  echo 3 | sudo tee /proc/sys/vm/drop_caches >/dev/null
-
-  echo -n "query${QUERY_NUM}," | tee -a result.csv
-  for i in $(seq 1 $TRIES); do
-    RES=$(mysql -vvv -h$FE_HOST -u$USER -P$FE_QUERY_PORT -D$DB -e "${query}" | perl -nle 'print $1 if /\((\d+\.\d+)+ sec\)/' || :)
-    if [[ ${PIPESTATUS[0]} -ne 0 ]]; then
-      echo "Error: Failed to execute SQL command: ${query}"
-      exit 1
-    elif [[ ${PIPESTATUS[1]} -ne 0 ]]; then
-      echo "Error: "
+    if [[ ! $query == SELECT* ]]; then
+        continue
     fi
+    sync
+    echo 3 | sudo tee /proc/sys/vm/drop_caches >/dev/null
 
-    echo -n "${RES}" | tee -a result.csv
-    [[ "$i" != $TRIES ]] && echo -n "," | tee -a result.csv
-  done
-  echo "" | tee -a result.csv
+    echo -n "query${QUERY_NUM}," | tee -a result.csv
+    for i in $(seq 1 $TRIES); do
+        RES=$(mysql -vvv -h$FE_HOST -u$USER -P$FE_QUERY_PORT -D$DB -e "${query}" | perl -nle 'print $1 if /\((\d+\.\d+)+ sec\)/' || :)
+        if [[ ${PIPESTATUS[0]} -ne 0 ]]; then
+            echo "Error: Failed to execute SQL command: ${query}"
+            exit 1
+        elif [[ ${PIPESTATUS[1]} -ne 0 ]]; then
+            echo "Error: "
+        fi
 
-  QUERY_NUM=$((QUERY_NUM + 1))
+        echo -n "${RES}" | tee -a result.csv
+        [[ "$i" != $TRIES ]] && echo -n "," | tee -a result.csv
+    done
+    echo "" | tee -a result.csv
+
+    QUERY_NUM=$((QUERY_NUM + 1))
 done
 
 cold_run_sum=$(awk -F ',' '{sum+=$2} END {print sum}' result.csv)
----------

You can reformat the above files to meet shfmt's requirements by typing:

  shfmt  -w filename


Copy link
Contributor

sh-checker report

To get the full details, please check in the job output.

shellcheck errors

'shellcheck ' returned error 1 finding the following syntactical issues:

----------

In create-clickbench-table.sh line 27:
  cd "$ROOT"
      ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
  cd "${ROOT}"


In create-clickbench-table.sh line 43:
  -n $0 \
     ^-- SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
  -n "$0" \


In create-clickbench-table.sh line 47:
eval set -- "$OPTS"
             ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
eval set -- "${OPTS}"


In create-clickbench-table.sh line 50:
if [ $# == 0 ]; then
   ^---------^ SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.

Did you mean: 
if [[ $# == 0 ]]; then


In create-clickbench-table.sh line 73:
  exit
  ^--^ SC2317 (info): Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


In create-clickbench-table.sh line 79:
  if ! $CMD; then
       ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
  if ! ${CMD}; then


In create-clickbench-table.sh line 80:
    echo "$NAME is missing. This script depends on mysql to create tables in Doris."
          ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    echo "${NAME} is missing. This script depends on mysql to create tables in Doris."


In create-clickbench-table.sh line 87:
source $CURDIR/conf/doris-cluster.conf
       ^-----------------------------^ SC1091 (info): Not following: ./conf/doris-cluster.conf: openBinaryFile: does not exist (No such file or directory)
       ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
       ^-----^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
source "${CURDIR}"/conf/doris-cluster.conf


In create-clickbench-table.sh line 88:
echo "FE_HOST: $FE_HOST"
               ^------^ SC2154 (warning): FE_HOST is referenced but not assigned.
               ^------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
echo "FE_HOST: ${FE_HOST}"


In create-clickbench-table.sh line 89:
echo "FE_QUERY_PORT: $FE_QUERY_PORT"
                     ^------------^ SC2154 (warning): FE_QUERY_PORT is referenced but not assigned.
                     ^------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
echo "FE_QUERY_PORT: ${FE_QUERY_PORT}"


In create-clickbench-table.sh line 90:
echo "USER: $USER"
            ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
echo "USER: ${USER}"


In create-clickbench-table.sh line 91:
echo "PASSWORD: $PASSWORD"
                ^-------^ SC2154 (warning): PASSWORD is referenced but not assigned.
                ^-------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
echo "PASSWORD: ${PASSWORD}"


In create-clickbench-table.sh line 92:
echo "DB: $DB"
          ^-^ SC2154 (warning): DB is referenced but not assigned.
          ^-^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
echo "DB: ${DB}"


In create-clickbench-table.sh line 94:
OUTPUT=$(mysql -h$FE_HOST -u$USER -P$FE_QUERY_PORT -e "CREATE DATABASE IF NOT EXISTS $DB")
                 ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                 ^------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                            ^---^ SC2086 (info): Double quote to prevent globbing and word splitting.
                            ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                    ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                    ^------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                                                                     ^-^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
OUTPUT=$(mysql -h"${FE_HOST}" -u"${USER}" -P"${FE_QUERY_PORT}" -e "CREATE DATABASE IF NOT EXISTS ${DB}")


In create-clickbench-table.sh line 95:
if [[ $? -ne 0 ]]; then
      ^-- SC2181 (style): Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?.


In create-clickbench-table.sh line 96:
  echo "Error: Failed to create database: $DB"
                                          ^-^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
  echo "Error: Failed to create database: ${DB}"


In create-clickbench-table.sh line 97:
  echo "mysql error message: $OUTPUT"
                             ^-----^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
  echo "mysql error message: ${OUTPUT}"


In create-clickbench-table.sh line 100:
OUTPUT=$(mysql -h$FE_HOST -u$USER -P$FE_QUERY_PORT -D$DB <$CURDIR/sql/create-clickbench-table.sql)
                 ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                 ^------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                            ^---^ SC2086 (info): Double quote to prevent globbing and word splitting.
                            ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                    ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                    ^------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                                     ^-^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                     ^-^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                                          ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                          ^-----^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
OUTPUT=$(mysql -h"${FE_HOST}" -u"${USER}" -P"${FE_QUERY_PORT}" -D"${DB}" <"${CURDIR}"/sql/create-clickbench-table.sql)


In create-clickbench-table.sh line 101:
if [[ $? -ne 0 ]]; then
      ^-- SC2181 (style): Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?.


In create-clickbench-table.sh line 103:
  echo "mysql error message: $OUTPUT"
                             ^-----^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
  echo "mysql error message: ${OUTPUT}"


In create-clickbench-table.sh line 106:
OUTPUT=$(mysql -h$FE_HOST -u$USER -P$FE_QUERY_PORT -D$DB -e "show create table hits;")
                 ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                 ^------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                            ^---^ SC2086 (info): Double quote to prevent globbing and word splitting.
                            ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                    ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                    ^------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                                     ^-^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                     ^-^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
OUTPUT=$(mysql -h"${FE_HOST}" -u"${USER}" -P"${FE_QUERY_PORT}" -D"${DB}" -e "show create table hits;")


In create-clickbench-table.sh line 107:
if [[ $? -ne 0 ]]; then
      ^-- SC2181 (style): Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?.


In create-clickbench-table.sh line 108:
  echo "Error:  Failed to execute 'show create table hits;' in database $DB."
                                                                        ^-^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
  echo "Error:  Failed to execute 'show create table hits;' in database ${DB}."


In create-clickbench-table.sh line 109:
  echo "mysql error message: $OUTPUT"
                             ^-----^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
  echo "mysql error message: ${OUTPUT}"


In load-clickbench-data.sh line 27:
    cd "$ROOT"
        ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    cd "${ROOT}"


In load-clickbench-data.sh line 32:
DATA_DIR=$CURDIR/
         ^-----^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
DATA_DIR=${CURDIR}/


In load-clickbench-data.sh line 50:
    -n $0 \
       ^-- SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
    -n "$0" \


In load-clickbench-data.sh line 54:
eval set -- "$OPTS"
             ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
eval set -- "${OPTS}"


In load-clickbench-data.sh line 87:
    if ! $CMD; then
         ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    if ! ${CMD}; then


In load-clickbench-data.sh line 88:
        echo "$NAME is missing. This script depends on cURL to load data to Doris."
              ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
        echo "${NAME} is missing. This script depends on cURL to load data to Doris."


In load-clickbench-data.sh line 97:
source $CURDIR/conf/doris-cluster.conf
       ^-----------------------------^ SC1091 (info): Not following: ./conf/doris-cluster.conf: openBinaryFile: does not exist (No such file or directory)
       ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
       ^-----^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
source "${CURDIR}"/conf/doris-cluster.conf


In load-clickbench-data.sh line 101:
echo "FE_HOST: $FE_HOST"
               ^------^ SC2154 (warning): FE_HOST is referenced but not assigned.
               ^------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
echo "FE_HOST: ${FE_HOST}"


In load-clickbench-data.sh line 102:
echo "FE_HTTP_PORT: $FE_HTTP_PORT"
                    ^-----------^ SC2154 (warning): FE_HTTP_PORT is referenced but not assigned.
                    ^-----------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
echo "FE_HTTP_PORT: ${FE_HTTP_PORT}"


In load-clickbench-data.sh line 103:
echo "USER: $USER"
            ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
echo "USER: ${USER}"


In load-clickbench-data.sh line 104:
echo "PASSWORD: $PASSWORD"
                ^-------^ SC2154 (warning): PASSWORD is referenced but not assigned.
                ^-------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
echo "PASSWORD: ${PASSWORD}"


In load-clickbench-data.sh line 105:
echo "DB: $DB"
          ^-^ SC2154 (warning): DB is referenced but not assigned.
          ^-^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
echo "DB: ${DB}"


In load-clickbench-data.sh line 108:
    cv=$(mysql -h$FE_HOST -P$FE_QUERY_PORT -u$USER -e 'admin show frontend config' | grep 'stream_load_default_timeout_second' | awk '{print $2}')
                 ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                 ^------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                            ^------------^ SC2154 (warning): FE_QUERY_PORT is referenced but not assigned.
                            ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                            ^------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                             ^---^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                             ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    cv=$(mysql -h"${FE_HOST}" -P"${FE_QUERY_PORT}" -u"${USER}" -e 'admin show frontend config' | grep 'stream_load_default_timeout_second' | awk '{print $2}')


In load-clickbench-data.sh line 125:
    if (($cv < 3600)); then
         ^-^ SC2004 (style): $/${} is unnecessary on arithmetic variables.
         ^-^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    if ((${cv} < 3600)); then


In load-clickbench-data.sh line 129:
    cv=$(curl "${BE_HOST}:${BE_WEBSERVER_PORT}/varz" 2>/dev/null | grep 'streaming_load_max_mb' | awk -F'=' '{print $2}')
               ^--------^ SC2154 (warning): BE_HOST is referenced but not assigned.
                          ^------------------^ SC2154 (warning): BE_WEBSERVER_PORT is referenced but not assigned.


In load-clickbench-data.sh line 146:
    if (($cv < 16000)); then
         ^-^ SC2004 (style): $/${} is unnecessary on arithmetic variables.
         ^-^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    if ((${cv} < 16000)); then


In load-clickbench-data.sh line 153:
    need_download=false
    ^-----------^ SC2034 (warning): need_download appears unused. Verify use (or export if used externally).


In load-clickbench-data.sh line 154:
    cd $DATA_DIR
       ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
       ^-------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    cd "${DATA_DIR}"


In load-clickbench-data.sh line 156:
        if [ ! -f "$DATA_DIR/hits_split${i}" ]; then
           ^-- SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.
                   ^-------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
        if [[ ! -f "${DATA_DIR}/hits_split${i}" ]]; then


In load-clickbench-data.sh line 157:
            echo "will download hits_split${i} to $DATA_DIR"
                                                  ^-------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
            echo "will download hits_split${i} to ${DATA_DIR}"


In load-clickbench-data.sh line 160:
            wget_pids[${#wget_pids[@]}]=$PID
                                        ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
            wget_pids[${#wget_pids[@]}]=${PID}


In load-clickbench-data.sh line 168:
    echo "(2/2) load clickbench data file $DATA_DIR/hits_split[0-9] into Doris"
                                          ^-------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    echo "(2/2) load clickbench data file ${DATA_DIR}/hits_split[0-9] into Doris"


In load-clickbench-data.sh line 174:
                -u $USER:$PASSWORD \
                   ^---^ SC2086 (info): Double quote to prevent globbing and word splitting.
                   ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                         ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                         ^-------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
                -u "${USER}":"${PASSWORD}" \


In load-clickbench-data.sh line 175:
                -T "$DATA_DIR/hits_split${i}" \
                    ^-------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
                -T "${DATA_DIR}/hits_split${i}" \


In load-clickbench-data.sh line 177:
                http://$FE_HOST:$FE_HTTP_PORT/api/$DB/hits/_stream_load
                       ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                       ^------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                ^-----------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                ^-----------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                                  ^-^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                  ^-^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
                http://"${FE_HOST}":"${FE_HTTP_PORT}"/api/"${DB}"/hits/_stream_load


In load-clickbench-data.sh line 180:
                -u $USER:$PASSWORD \
                   ^---^ SC2086 (info): Double quote to prevent globbing and word splitting.
                   ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                         ^-------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                         ^-------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
                -u "${USER}":"${PASSWORD}" \


In load-clickbench-data.sh line 181:
                -T "$DATA_DIR/hits_split${i}" \
                    ^-------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
                -T "${DATA_DIR}/hits_split${i}" \


In load-clickbench-data.sh line 184:
                http://$FE_HOST:$FE_HTTP_PORT/api/$DB/hits/_stream_load
                       ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                       ^------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                ^-----------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                ^-----------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                                  ^-^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                  ^-^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
                http://"${FE_HOST}":"${FE_HTTP_PORT}"/api/"${DB}"/hits/_stream_load


In load-clickbench-data.sh line 191:
    for PID in ${wget_pids[@]}; do
               ^-------------^ SC2068 (error): Double quote array expansions to avoid re-splitting elements.


In load-clickbench-data.sh line 192:
        kill -9 $PID
                ^--^ SC2086 (info): Double quote to prevent globbing and word splitting.
                ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
        kill -9 "${PID}"


In load-clickbench-data.sh line 206:
  echo $@
       ^-- SC2068 (error): Double quote array expansions to avoid re-splitting elements.


In load-clickbench-data.sh line 207:
  OUTPUT=$(mysql -h$FE_HOST -u$USER -P$FE_QUERY_PORT -D$DB -e "$@")
                   ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                   ^------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                              ^---^ SC2086 (info): Double quote to prevent globbing and word splitting.
                              ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                      ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                      ^------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                                       ^-^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                       ^-^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
  OUTPUT=$(mysql -h"${FE_HOST}" -u"${USER}" -P"${FE_QUERY_PORT}" -D"${DB}" -e "$@")


In load-clickbench-data.sh line 208:
  if [[ $? -ne 0 ]]; then
        ^-- SC2181 (style): Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?.


In load-clickbench-data.sh line 210:
    echo "mysql error message: $OUTPUT"
                               ^-----^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    echo "mysql error message: ${OUTPUT}"


In run-clickbench-queries.sh line 27:
  cd "$ROOT"
      ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
  cd "${ROOT}"


In run-clickbench-queries.sh line 32:
QUERIES_FILE=$CURDIR/sql/queries.sql
             ^-----^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
QUERIES_FILE=${CURDIR}/sql/queries.sql


In run-clickbench-queries.sh line 44:
  -n $0 \
     ^-- SC2086 (info): Double quote to prevent globbing and word splitting.

Did you mean: 
  -n "$0" \


In run-clickbench-queries.sh line 49:
eval set -- "$OPTS"
             ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
eval set -- "${OPTS}"


In run-clickbench-queries.sh line 52:
if [ $# == 0 ]; then
   ^---------^ SC2292 (style): Prefer [[ ]] over [ ] for tests in Bash/Ksh.

Did you mean: 
if [[ $# == 0 ]]; then


In run-clickbench-queries.sh line 75:
  exit
  ^--^ SC2317 (info): Command appears to be unreachable. Check usage (or ignore if invoked indirectly).


In run-clickbench-queries.sh line 81:
  if ! $CMD; then
       ^--^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
  if ! ${CMD}; then


In run-clickbench-queries.sh line 82:
    echo "$NAME is missing. This script depends on mysql to create tables in Doris."
          ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    echo "${NAME} is missing. This script depends on mysql to create tables in Doris."


In run-clickbench-queries.sh line 90:
source $CURDIR/conf/doris-cluster.conf
       ^-----------------------------^ SC1091 (info): Not following: ./conf/doris-cluster.conf: openBinaryFile: does not exist (No such file or directory)
       ^-----^ SC2086 (info): Double quote to prevent globbing and word splitting.
       ^-----^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
source "${CURDIR}"/conf/doris-cluster.conf


In run-clickbench-queries.sh line 91:
export MYSQL_PWD=$PASSWORD
                 ^-------^ SC2154 (warning): PASSWORD is referenced but not assigned.
                 ^-------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
export MYSQL_PWD=${PASSWORD}


In run-clickbench-queries.sh line 93:
echo "FE_HOST: $FE_HOST"
               ^------^ SC2154 (warning): FE_HOST is referenced but not assigned.
               ^------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
echo "FE_HOST: ${FE_HOST}"


In run-clickbench-queries.sh line 94:
echo "FE_QUERY_PORT: $FE_QUERY_PORT"
                     ^------------^ SC2154 (warning): FE_QUERY_PORT is referenced but not assigned.
                     ^------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
echo "FE_QUERY_PORT: ${FE_QUERY_PORT}"


In run-clickbench-queries.sh line 95:
echo "USER: $USER"
            ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
echo "USER: ${USER}"


In run-clickbench-queries.sh line 96:
echo "PASSWORD: $PASSWORD"
                ^-------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
echo "PASSWORD: ${PASSWORD}"


In run-clickbench-queries.sh line 97:
echo "DB: $DB"
          ^-^ SC2154 (warning): DB is referenced but not assigned.
          ^-^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
echo "DB: ${DB}"


In run-clickbench-queries.sh line 100:
  echo $@
       ^-- SC2068 (error): Double quote array expansions to avoid re-splitting elements.


In run-clickbench-queries.sh line 101:
  OUTPUT=(mysql -h$FE_HOST -u$USER -P$FE_QUERY_PORT -D$DB -e "$@")
                  ^------^ SC2206 (warning): Quote to prevent word splitting/globbing, or split robustly with mapfile or read -a.
                  ^------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                             ^---^ SC2206 (warning): Quote to prevent word splitting/globbing, or split robustly with mapfile or read -a.
                             ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                     ^------------^ SC2206 (warning): Quote to prevent word splitting/globbing, or split robustly with mapfile or read -a.
                                     ^------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                                      ^-^ SC2206 (warning): Quote to prevent word splitting/globbing, or split robustly with mapfile or read -a.
                                                      ^-^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
  OUTPUT=(mysql -h${FE_HOST} -u${USER} -P${FE_QUERY_PORT} -D${DB} -e "$@")


In run-clickbench-queries.sh line 102:
  if [[ $? -ne 0 ]]; then
        ^-- SC2181 (style): Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?.


In run-clickbench-queries.sh line 104:
    echo "mysql error message: $OUTPUT"
                               ^-----^ SC2128 (warning): Expanding an array without an index only gives the first element.
                               ^-----^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    echo "mysql error message: ${OUTPUT}"


In run-clickbench-queries.sh line 139:
cat ${QUERIES_FILE} | while read query; do
    ^-------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                            ^--^ SC2162 (info): read without -r will mangle backslashes.

Did you mean: 
cat "${QUERIES_FILE}" | while read query; do


In run-clickbench-queries.sh line 140:
  if [[ ! $query == SELECT* ]]; then
          ^----^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
  if [[ ! ${query} == SELECT* ]]; then


In run-clickbench-queries.sh line 147:
  for i in $(seq 1 $TRIES); do
                   ^----^ SC2248 (style): Prefer double quoting even when variables don't contain special characters.
                   ^----^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
  for i in $(seq 1 "${TRIES}"); do


In run-clickbench-queries.sh line 148:
    RES=$(mysql -vvv -h$FE_HOST -u$USER -P$FE_QUERY_PORT -D$DB -e "${query}" | perl -nle 'print $1 if /\((\d+\.\d+)+ sec\)/' || :)
                       ^------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                       ^------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                  ^---^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                  ^---^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                          ^------------^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                          ^------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.
                                                           ^-^ SC2086 (info): Double quote to prevent globbing and word splitting.
                                                           ^-^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    RES=$(mysql -vvv -h"${FE_HOST}" -u"${USER}" -P"${FE_QUERY_PORT}" -D"${DB}" -e "${query}" | perl -nle 'print $1 if /\((\d+\.\d+)+ sec\)/' || :)


In run-clickbench-queries.sh line 157:
    [[ "$i" != $TRIES ]] && echo -n "," | tee -a result.csv
        ^-- SC2250 (style): Prefer putting braces around variable references even when not strictly required.
               ^----^ SC2053 (warning): Quote the right-hand side of != in [[ ]] to prevent glob matching.
               ^----^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Did you mean: 
    [[ "${i}" != ${TRIES} ]] && echo -n "," | tee -a result.csv

For more information:
  https://www.shellcheck.net/wiki/SC2068 -- Double quote array expansions to ...
  https://www.shellcheck.net/wiki/SC2034 -- need_download appears unused. Ver...
  https://www.shellcheck.net/wiki/SC2053 -- Quote the right-hand side of != i...
----------

You can address the above issues in one of three ways:
1. Manually correct the issue in the offending shell script;
2. Disable specific issues by adding the comment:
  # shellcheck disable=NNNN
above the line that contains the issue, where NNNN is the error code;
3. Add '-e NNNN' to the SHELLCHECK_OPTS setting in your .yml action file.



shfmt errors

'shfmt ' returned error 1 finding the following formatting issues:

----------
--- create-clickbench-table.sh.orig
+++ create-clickbench-table.sh
@@ -24,62 +24,62 @@
 
 ROOT=$(dirname "$0")
 ROOT=$(
-  cd "$ROOT"
-  pwd
+    cd "$ROOT"
+    pwd
 )
 
 CURDIR=${ROOT}
 
 usage() {
-  echo "
+    echo "
 This script is used to create ClickBench table, 
 will use mysql client to connect Doris server which is specified in conf/doris-cluster.conf file.
 Usage: $0 
   "
-  exit 1
+    exit 1
 }
 
 OPTS=$(getopt \
-  -n $0 \
-  -o '' \
-  -- "$@")
+    -n $0 \
+    -o '' \
+    -- "$@")
 
 eval set -- "$OPTS"
 HELP=0
 
 if [ $# == 0 ]; then
-  usage
+    usage
 fi
 
 while true; do
-  case "$1" in
-  -h)
-    HELP=1
-    shift
-    ;;
-  --)
-    shift
-    break
-    ;;
-  *)
-    echo "Internal error"
-    exit 1
-    ;;
-  esac
+    case "$1" in
+    -h)
+        HELP=1
+        shift
+        ;;
+    --)
+        shift
+        break
+        ;;
+    *)
+        echo "Internal error"
+        exit 1
+        ;;
+    esac
 done
 
 if [[ "${HELP}" -eq 1 ]]; then
-  usage
-  exit
+    usage
+    exit
 fi
 
 check_prerequest() {
-  local CMD=$1
-  local NAME=$2
-  if ! $CMD; then
-    echo "$NAME is missing. This script depends on mysql to create tables in Doris."
-    exit 1
-  fi
+    local CMD=$1
+    local NAME=$2
+    if ! $CMD; then
+        echo "$NAME is missing. This script depends on mysql to create tables in Doris."
+        exit 1
+    fi
 }
 
 check_prerequest "mysql --version" "mysql"
@@ -93,21 +93,21 @@
 
 OUTPUT=$(mysql -h$FE_HOST -u$USER -P$FE_QUERY_PORT -e "CREATE DATABASE IF NOT EXISTS $DB")
 if [[ $? -ne 0 ]]; then
-  echo "Error: Failed to create database: $DB"
-  echo "mysql error message: $OUTPUT"
-  exit 1
+    echo "Error: Failed to create database: $DB"
+    echo "mysql error message: $OUTPUT"
+    exit 1
 fi
 OUTPUT=$(mysql -h$FE_HOST -u$USER -P$FE_QUERY_PORT -D$DB <$CURDIR/sql/create-clickbench-table.sql)
 if [[ $? -ne 0 ]]; then
-  echo "Error:  Failed to execute the SQL script"
-  echo "mysql error message: $OUTPUT"
-  exit 1
+    echo "Error:  Failed to execute the SQL script"
+    echo "mysql error message: $OUTPUT"
+    exit 1
 fi
 OUTPUT=$(mysql -h$FE_HOST -u$USER -P$FE_QUERY_PORT -D$DB -e "show create table hits;")
 if [[ $? -ne 0 ]]; then
-  echo "Error:  Failed to execute 'show create table hits;' in database $DB."
-  echo "mysql error message: $OUTPUT"
-  exit 1
+    echo "Error:  Failed to execute 'show create table hits;' in database $DB."
+    echo "mysql error message: $OUTPUT"
+    exit 1
 fi
 
 echo "DONE."
--- load-clickbench-data.sh.orig
+++ load-clickbench-data.sh
@@ -142,7 +142,7 @@
         echo "Error: Failed to extract the value using awk."
         exit 1
     fi
-    
+
     if (($cv < 16000)); then
         echo -e "advise: revise your Doris BE's conf to set 'streaming_load_max_mb=16000' or above and 'flush_thread_num_per_store=5' to speed up load."
     fi
@@ -203,13 +203,13 @@
 echo "load cost time: $((end - start)) seconds"
 
 run_sql() {
-  echo $@
-  OUTPUT=$(mysql -h$FE_HOST -u$USER -P$FE_QUERY_PORT -D$DB -e "$@")
-  if [[ $? -ne 0 ]]; then
-    echo "Error: Failed to execute the SQL command"
-    echo "mysql error message: $OUTPUT"
-    exit 1
-fi
+    echo $@
+    OUTPUT=$(mysql -h$FE_HOST -u$USER -P$FE_QUERY_PORT -D$DB -e "$@")
+    if [[ $? -ne 0 ]]; then
+        echo "Error: Failed to execute the SQL command"
+        echo "mysql error message: $OUTPUT"
+        exit 1
+    fi
 }
 
 echo '============================================'
--- run-clickbench-queries.sh.orig
+++ run-clickbench-queries.sh
@@ -24,64 +24,64 @@
 
 ROOT=$(dirname "$0")
 ROOT=$(
-  cd "$ROOT"
-  pwd
+    cd "$ROOT"
+    pwd
 )
 
 CURDIR=${ROOT}
 QUERIES_FILE=$CURDIR/sql/queries.sql
 
 usage() {
-  echo "
+    echo "
 This script is used to run ClickBench 43 queries, 
 will use mysql client to connect Doris server which parameter is specified in conf/doris-cluster.conf file.
 Usage: $0 
   "
-  exit 1
+    exit 1
 }
 
 OPTS=$(getopt \
-  -n $0 \
-  -o '' \
-  -o 'h' \
-  -- "$@")
+    -n $0 \
+    -o '' \
+    -o 'h' \
+    -- "$@")
 
 eval set -- "$OPTS"
 HELP=0
 
 if [ $# == 0 ]; then
-  usage
+    usage
 fi
 
 while true; do
-  case "$1" in
-  -h)
-    HELP=1
-    shift
-    ;;
-  --)
-    shift
-    break
-    ;;
-  *)
-    echo "Internal error"
-    exit 1
-    ;;
-  esac
+    case "$1" in
+    -h)
+        HELP=1
+        shift
+        ;;
+    --)
+        shift
+        break
+        ;;
+    *)
+        echo "Internal error"
+        exit 1
+        ;;
+    esac
 done
 
 if [[ "${HELP}" -eq 1 ]]; then
-  usage
-  exit
+    usage
+    exit
 fi
 
 check_prerequest() {
-  local CMD=$1
-  local NAME=$2
-  if ! $CMD; then
-    echo "$NAME is missing. This script depends on mysql to create tables in Doris."
-    exit 1
-  fi
+    local CMD=$1
+    local NAME=$2
+    if ! $CMD; then
+        echo "$NAME is missing. This script depends on mysql to create tables in Doris."
+        exit 1
+    fi
 }
 
 check_prerequest "mysql --version" "mysql"
@@ -97,31 +97,31 @@
 echo "DB: $DB"
 
 run_sql() {
-  echo $@
-  OUTPUT=(mysql -h$FE_HOST -u$USER -P$FE_QUERY_PORT -D$DB -e "$@")
-  if [[ $? -ne 0 ]]; then
-    echo "Error: Failed to execute the SQL command"
-    echo "mysql error message: $OUTPUT"
-    exit 1
-  fi
+    echo $@
+    OUTPUT=(mysql -h$FE_HOST -u$USER -P$FE_QUERY_PORT -D$DB -e "$@")
+    if [[ $? -ne 0 ]]; then
+        echo "Error: Failed to execute the SQL command"
+        echo "mysql error message: $OUTPUT"
+        exit 1
+    fi
 }
 
 get_session_variable() {
-  k="$1"
-  v=$(mysql -h"${FE_HOST}" -u"${USER}" -P"${FE_QUERY_PORT}" -D"${DB}" -e"show variables like '${k}'\G" | grep " Value: ")
+    k="$1"
+    v=$(mysql -h"${FE_HOST}" -u"${USER}" -P"${FE_QUERY_PORT}" -D"${DB}" -e"show variables like '${k}'\G" | grep " Value: ")
 
-  if [[ ${PIPESTATUS[0]} -ne 0 ]]; then
-    echo "Error: Failed to execute SQL command: show variables like '${k}'\G"
-    exit 1
-  fi
-  if [[ ${PIPESTATUS[1]} -eq 1 ]]; then
-    echo "Warning: No lines containing ' Value: ' were found."
-    exit 1
-  elif [[ ${PIPESTATUS[1]} -eq 2 ]]; then
-    echo "Error: An error occurred while running grep."
-    exit 1
-  fi
-  echo "${v/*Value: /}"
+    if [[ ${PIPESTATUS[0]} -ne 0 ]]; then
+        echo "Error: Failed to execute SQL command: show variables like '${k}'\G"
+        exit 1
+    fi
+    if [[ ${PIPESTATUS[1]} -eq 1 ]]; then
+        echo "Warning: No lines containing ' Value: ' were found."
+        exit 1
+    elif [[ ${PIPESTATUS[1]} -eq 2 ]]; then
+        echo "Error: An error occurred while running grep."
+        exit 1
+    fi
+    echo "${v/*Value: /}"
 }
 
 _exec_mem_limit="$(get_session_variable exec_mem_limit)"
@@ -137,28 +137,28 @@
 truncate -s0 result.csv
 
 cat ${QUERIES_FILE} | while read query; do
-  if [[ ! $query == SELECT* ]]; then
-    continue
-  fi
-  sync
-  echo 3 | sudo tee /proc/sys/vm/drop_caches >/dev/null
-
-  echo -n "query${QUERY_NUM}," | tee -a result.csv
-  for i in $(seq 1 $TRIES); do
-    RES=$(mysql -vvv -h$FE_HOST -u$USER -P$FE_QUERY_PORT -D$DB -e "${query}" | perl -nle 'print $1 if /\((\d+\.\d+)+ sec\)/' || :)
-    if [[ ${PIPESTATUS[0]} -ne 0 ]]; then
-      echo "Error: Failed to execute SQL command: ${query}"
-      exit 1
-    elif [[ ${PIPESTATUS[1]} -ne 0 ]]; then
-      echo "Error: "
+    if [[ ! $query == SELECT* ]]; then
+        continue
     fi
+    sync
+    echo 3 | sudo tee /proc/sys/vm/drop_caches >/dev/null
 
-    echo -n "${RES}" | tee -a result.csv
-    [[ "$i" != $TRIES ]] && echo -n "," | tee -a result.csv
-  done
-  echo "" | tee -a result.csv
+    echo -n "query${QUERY_NUM}," | tee -a result.csv
+    for i in $(seq 1 $TRIES); do
+        RES=$(mysql -vvv -h$FE_HOST -u$USER -P$FE_QUERY_PORT -D$DB -e "${query}" | perl -nle 'print $1 if /\((\d+\.\d+)+ sec\)/' || :)
+        if [[ ${PIPESTATUS[0]} -ne 0 ]]; then
+            echo "Error: Failed to execute SQL command: ${query}"
+            exit 1
+        elif [[ ${PIPESTATUS[1]} -ne 0 ]]; then
+            echo "Error: "
+        fi
 
-  QUERY_NUM=$((QUERY_NUM + 1))
+        echo -n "${RES}" | tee -a result.csv
+        [[ "$i" != $TRIES ]] && echo -n "," | tee -a result.csv
+    done
+    echo "" | tee -a result.csv
+
+    QUERY_NUM=$((QUERY_NUM + 1))
 done
 
 cold_run_sum=$(awk -F ',' '{sum+=$2} END {print sum}' result.csv)
----------

You can reformat the above files to meet shfmt's requirements by typing:

  shfmt  -w filename


Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants