Skip to content

Commit 9aadf3a

Browse files
authored
Merge pull request #863 from gizmodata/gizmosql-cli-client
GizmoSQL: switch from gizmosqlline (Java) to gizmosql_client
2 parents 73fe9af + 837d9b8 commit 9aadf3a

3 files changed

Lines changed: 25 additions & 39 deletions

File tree

gizmosql/benchmark.sh

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
export HOME=/home/ubuntu
55

66
# Install requirements
7-
apt-get update -y
8-
apt install openjdk-17-jre-headless unzip netcat-openbsd -y
7+
sudo apt-get update -y
8+
sudo apt-get install -y unzip netcat-openbsd
99

1010
# Detect architecture (maps x86_64->amd64, aarch64->arm64)
1111
ARCH=$(uname -m)
@@ -15,17 +15,12 @@ elif [ "$ARCH" = "aarch64" ]; then
1515
ARCH="arm64"
1616
fi
1717

18-
# Server setup Install
18+
# Install the GizmoSQL server and client (gizmosql_client is the CLI shell) into a local directory
19+
mkdir -p ./bin
1920
curl -L -o gizmosql.zip "https://github.com/gizmodata/gizmosql/releases/latest/download/gizmosql_cli_linux_${ARCH}.zip"
20-
unzip gizmosql.zip
21-
mv gizmosql_server gizmosql_client /usr/local/bin/
22-
23-
# Install Java and the GizmoSQLLine CLI client
24-
pushd /tmp
25-
curl -L -o gizmosqlline https://github.com/gizmodata/gizmosqlline/releases/latest/download/gizmosqlline
26-
chmod +x gizmosqlline
27-
mv gizmosqlline /usr/local/bin/
28-
popd
21+
unzip -o gizmosql.zip -d ./bin
22+
chmod +x ./bin/gizmosql_server ./bin/gizmosql_client
23+
export PATH="$PWD/bin:$PATH"
2924

3025
# Source our env vars and utility functions for starting/stopping gizmosql server
3126
. util.sh
@@ -34,21 +29,13 @@ popd
3429
start_gizmosql
3530

3631
# Create the table
37-
gizmosqlline \
38-
-u ${GIZMOSQL_SERVER_URI} \
39-
-n ${GIZMOSQL_USERNAME} \
40-
-p ${GIZMOSQL_PASSWORD} \
41-
-f create.sql
32+
gizmosql_client --file create.sql
4233

4334
# Load the data
4435
../download-hits-parquet-single
4536

4637
echo -n "Load time: "
47-
time gizmosqlline \
48-
-u ${GIZMOSQL_SERVER_URI} \
49-
-n ${GIZMOSQL_USERNAME} \
50-
-p ${GIZMOSQL_PASSWORD} \
51-
-f load.sql
38+
time gizmosql_client --file load.sql
5239

5340
stop_gizmosql
5441

@@ -62,8 +49,8 @@ echo -n "Data size: "
6249
wc -c clickbench.db
6350

6451
cat log.txt | \
65-
grep -E 'rows? selected \([0-9.]+ seconds\)|Killed|Segmentation' | \
66-
sed -E 's/.*rows? selected \(([0-9.]+) seconds\).*/\1/; s/.*(Killed|Segmentation).*/null/' | \
52+
grep -E 'Run Time: [0-9.]+s|Killed|Segmentation' | \
53+
sed -E 's/.*Run Time: ([0-9.]+)s.*/\1/; s/.*(Killed|Segmentation).*/null/' | \
6754
awk '{
6855
if (NR % 3 == 1) printf "[";
6956
if ($1 == "null") printf "null";

gizmosql/run.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,15 @@ for query in "${queries[@]}"; do
1919

2020
# Clear Linux memory caches to ensure fair benchmark comparisons
2121
sync
22-
echo 3 | tee /proc/sys/vm/drop_caches > /dev/null
22+
echo 3 | sudo tee /proc/sys/vm/drop_caches > /dev/null
2323

2424
# Start the GizmoSQL server
2525
start_gizmosql
2626

27+
# Enable timer and discard result rows (we only care about Run Time)
28+
echo ".timer on" >> "${TEMP_SQL_FILE}"
29+
echo ".mode trash" >> "${TEMP_SQL_FILE}"
30+
2731
# Add a comment to identify the query in the output
2832
echo "-- Query: ${query}" >> "${TEMP_SQL_FILE}"
2933

@@ -32,12 +36,8 @@ for query in "${queries[@]}"; do
3236
echo "${query}" >> "${TEMP_SQL_FILE}"
3337
done
3438

35-
# Execute the query script
36-
gizmosqlline \
37-
-u ${GIZMOSQL_SERVER_URI} \
38-
-n ${GIZMOSQL_USERNAME} \
39-
-p ${GIZMOSQL_PASSWORD} \
40-
-f "${TEMP_SQL_FILE}"
39+
# Execute the query script (timer output goes to stderr; merge to stdout)
40+
gizmosql_client --file "${TEMP_SQL_FILE}" 2>&1
4141

4242
# Stop the server before next query
4343
stop_gizmosql

gizmosql/util.sh

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
11
#!/bin/bash
22

3-
# Variables
4-
GIZMOSQL_SERVER_URI="jdbc:arrow-flight-sql://localhost:31337?useEncryption=false"
5-
GIZMOSQL_USERNAME=clickbench
6-
GIZMOSQL_PASSWORD=clickbench
3+
# Variables (env var names match what gizmosql_client recognizes natively)
4+
export GIZMOSQL_HOST=localhost
5+
export GIZMOSQL_PORT=31337
6+
export GIZMOSQL_USER=clickbench
7+
export GIZMOSQL_PASSWORD=clickbench
78
PID_FILE="/tmp/gizmosql_server_$$.pid"
89

910
# Function to start the GizmoSQL server
1011
start_gizmosql() {
11-
export GIZMOSQL_PASSWORD="${GIZMOSQL_PASSWORD}"
12-
1312
nohup gizmosql_server \
14-
--username ${GIZMOSQL_USERNAME} \
13+
--username ${GIZMOSQL_USER} \
1514
--database-filename clickbench.db \
1615
--print-queries >> gizmosql_server.log 2>&1 &
1716

1817
echo $! > "${PID_FILE}"
1918

2019
# Wait for server to be ready
2120
echo "Waiting for gizmosql_server to start..."
22-
while ! nc -z localhost 31337 2>/dev/null; do
21+
while ! nc -z ${GIZMOSQL_HOST} ${GIZMOSQL_PORT} 2>/dev/null; do
2322
sleep 1
2423
done
2524
echo "gizmosql_server is ready (PID: $(cat ${PID_FILE}))"

0 commit comments

Comments
 (0)