Skip to content

Commit d600bf2

Browse files
committed
NYC Yellowcab example: Improve SQL statement and output formatting
1 parent 0b38683 commit d600bf2

File tree

1 file changed

+36
-11
lines changed

1 file changed

+36
-11
lines changed

spikes/testbench-yellowcab/cratedb-import-nyc-yellowcab.sh

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ CRATEDB_IMAGE=${CRATEDB_IMAGE:-crate:4.8.1}
1717
# 0. Define incantations.
1818
crash="docker run --interactive --rm --network=host ${CRATEDB_IMAGE} crash"
1919
cratedb_start="docker run --detach --rm --publish=4200:4200 --publish=5432:5432 --health-cmd=\"curl http://localhost:4200\" --health-interval=1s --health-start-period=5s --health-retries=15 --name=${CONTAINER_NAME} ${CRATEDB_IMAGE} -Cdiscovery.type=single-node"
20-
cratedb_stop="docker stop ${CONTAINER_NAME}"
20+
cratedb_stop="docker rm ${CONTAINER_NAME} --force"
2121
cratedb_status="docker inspect -f {{.State.Health.Status}} ${CONTAINER_NAME}"
2222
echo=$(which echo)
2323

2424
# 1. Start CrateDB and wait for availability.
2525
$cratedb_status > /dev/null 2>&1
2626
if [ $? -ne 0 ]; then
27-
echo "Starting CrateDB."
27+
echo "Starting CrateDB '${CRATEDB_IMAGE}'."
2828
sh -c "$cratedb_start"
2929
else
3030
echo "CrateDB already started."
@@ -37,11 +37,30 @@ done;
3737
echo
3838

3939
# 2. Insert NYC Yellowcab data.
40-
echo "Importing NYC Yellowcab data. This will take a few seconds/minutes."
40+
echo "Importing NYC Yellowcab data."
41+
echo "This will take a few seconds or minutes, depending on system performance and network speed."
4142
time $crash <<EOF
4243
CREATE TABLE IF NOT EXISTS "nyc_taxi"
43-
("congestion_surcharge" REAL, "dolocationid" INTEGER, "extra" REAL, "fare_amount" REAL, "improvement_surcharge" REAL, "mta_tax" REAL, "passenger_count" INTEGER, "payment_type" INTEGER, "pickup_datetime" TIMESTAMP WITH TIME ZONE, "pulocationid" INTEGER, "ratecodeid" INTEGER, "store_and_fwd_flag" TEXT, "tip_amount" REAL, "tolls_amount" REAL, "total_amount" REAL, "trip_distance" REAL, "vendorid" INTEGER)
44-
WITH ("column_policy" = 'dynamic', "number_of_replicas" = '0', "refresh_interval" = 10000);
44+
(
45+
"congestion_surcharge" REAL,
46+
"dolocationid" INTEGER,
47+
"extra" REAL,
48+
"fare_amount" REAL,
49+
"improvement_surcharge" REAL,
50+
"mta_tax" REAL,
51+
"passenger_count" INTEGER,
52+
"payment_type" INTEGER,
53+
"pickup_datetime" TIMESTAMP WITH TIME ZONE,
54+
"pulocationid" INTEGER,
55+
"ratecodeid" INTEGER,
56+
"store_and_fwd_flag" TEXT,
57+
"tip_amount" REAL,
58+
"tolls_amount" REAL,
59+
"total_amount" REAL,
60+
"trip_distance" REAL,
61+
"vendorid" INTEGER
62+
)
63+
WITH ("number_of_replicas" = '0', "refresh_interval" = 1000);
4564
4665
COPY "nyc_taxi"
4766
FROM 'https://s3.amazonaws.com/crate.sampledata/nyc.yellowcab/yc.2019.07.gz'
@@ -60,9 +79,15 @@ echo
6079

6180
# 4. User notes
6281
echo
63-
echo "The CrateDB database service has been started and populated with a subset of the NYC Yellowcab data into the table 'doc.nyc_taxi'."
64-
echo "The administration interface is available at http://localhost:4200."
65-
echo
66-
echo "If you are finished, you may want to shut down the database service using '${cratedb_stop}'."
67-
echo "Enjoy conducting your experiments."
68-
echo
82+
cat <<EOF
83+
The CrateDB database service has been started and populated with a
84+
subset of the NYC Yellowcab data into the table 'doc.nyc_taxi'.
85+
86+
The CrateDB administration interface is available at http://localhost:4200.
87+
88+
If you are finished, you may want to shut down and remove any remnants
89+
of the database service container using '${cratedb_stop}'.
90+
91+
Enjoy conducting your experiments.
92+
93+
EOF

0 commit comments

Comments
 (0)