35 lines
1.2 KiB
Bash
Executable file
35 lines
1.2 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Выполняет SQL только через локальный Trino в стенде из задания.
|
|
set -euo pipefail
|
|
lab_dir=$(cd -- "$(dirname -- "$0")" && pwd)
|
|
assignment_dir=$(cd -- "${1:?Specify the checked-out assignment directory}" && pwd)
|
|
export PORTFOLIO_LAB_DIR="$lab_dir"
|
|
compose=(docker compose --project-directory "$assignment_dir" -f "$assignment_dir/docker-compose.yml" -f "$lab_dir/compose.tpch.yml")
|
|
"${compose[@]}" up -d --build
|
|
"${compose[@]}" wait mc
|
|
for attempt in {1..30}; do
|
|
if "${compose[@]}" exec -T trino trino --execute 'SHOW SCHEMAS FROM tpch' >/dev/null 2>&1; then
|
|
break
|
|
fi
|
|
if [[ $attempt == 30 ]]; then
|
|
printf '%s\n' 'Trino or its TPC-H catalogue did not become available' >&2
|
|
exit 1
|
|
fi
|
|
sleep 2
|
|
done
|
|
sql() {
|
|
printf '\n%s\n' "$1"
|
|
"${compose[@]}" exec -T trino trino --output-format TSV < "$lab_dir/sql/$1"
|
|
}
|
|
sql 01-raw.sql
|
|
sql 02-vault.sql
|
|
sql 03-stage.sql
|
|
printf '\nInitial order history\n'
|
|
sql 04-history.sql
|
|
printf '\nChanged and reverted order, then replay\n'
|
|
sql 05-change.sql
|
|
sql 04-history.sql
|
|
sql 05-change.sql
|
|
sql 04-history.sql
|
|
sql 06-marts.sql
|
|
sql 07-quality.sql
|