Skip to content

Commit

Permalink
Trino container (#1756)
Browse files Browse the repository at this point in the history
* Add trino container.

* Try using container script

---------

Co-authored-by: Lloyd Tabb <ltabb@meta.com>
  • Loading branch information
Will Scullin and lloydtabb authored Jul 6, 2024
1 parent c9a4256 commit e06fb3a
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 6 deletions.
18 changes: 13 additions & 5 deletions .github/workflows/db-trino.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: Trino DB

on: [pull_request, workflow_call]
on:
pull_request:
workflow_call:
secrets:
BQ_PRESTO_TRINO_KEY:
required: true

jobs:
# Label of the container job
Expand All @@ -24,11 +29,14 @@ jobs:
npm ci --loglevel error
npm run build
npm run build-duckdb-db
npm run ping-db trino
./test/trino/trino_start.sh
npm run test packages/malloy-db-trino
npm run test test
./test/trino/trino_stop.sh
env:
MALLOY_DATABASES: trino
TRINO_SERVER: https://malloytesting-test-cluster.trino.galaxy.starburst.io
TRINO_USER: ${{ secrets.TRINO_USER}}
TRINO_PASSWORD: ${{ secrets.TRINO_PASSWORD}}
BQ_CREDENTIALS_KEY: ${{ secrets.BQ_PRESTO_TRINO_KEY }}
TRINO_CATALOG: bigquery
TRINO_SCHEMA: malloytest
TRINO_SERVER: http://localhost:8090
TRINO_USER: malloy-ci-bot@malloydata.org
2 changes: 1 addition & 1 deletion packages/malloy-db-trino/src/trino_connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export class TrinoConnection implements Connection, PersistSQLResults {
// TODO: check user is set.
this.trino = Trino.create({
server: config.server,
catalog: 'malloy_demo', //config.catalog,
catalog: config.catalog,
schema: config.schema,
auth: new BasicAuth(config.user!, config.password),
});
Expand Down
34 changes: 34 additions & 0 deletions test/trino/trino_start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#! /bin/bash
rm -rf .tmp
mkdir .tmp

# generate config file
> ./.tmp/bigquery.properties
cat << EOF > ./.tmp/bigquery.properties
connector.name=bigquery
bigquery.project-id=advance-lacing-417917
bigquery.credentials-key=$BQ_CREDENTIALS_KEY
bigquery.arrow-serialization.enabled=false
EOF

# run docker
docker run -p 8090:8080 -d -v ./.tmp/bigquery.properties:/etc/trino/catalog/bigquery.properties --name trino-malloy trinodb/trino

# wait for server to start
counter=0
while ! docker logs trino-malloy 2>&1 | grep -q "SERVER STARTED"
do
sleep 1
counter=$((counter+1))
# if doesn't start after 2 minutes, output logs and kill process
if [ $counter -eq 120 ]
then
docker logs trino-malloy >& ./.tmp/trino-malloy.logs
docker rm -f trino-malloy
echo "Trino did not start successfully, check .tmp/trino-malloy.logs"
exit 1
break
fi
done

echo "Trino running on port localhost:8090"
7 changes: 7 additions & 0 deletions test/trino/trino_stop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#! /bin/bash

# clear tmp files
rm -rf .tmp

# stop container
docker rm -f trino-malloy

0 comments on commit e06fb3a

Please sign in to comment.