generated from tconbeer/harlequin-adapter-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: trino-adapter initial implementation (#1)
* feat: trino adapter WIP * feat: trino adapter completed * fix: update poetry lock file
- Loading branch information
1 parent
8eb1c9f
commit ae548ef
Showing
25 changed files
with
1,565 additions
and
306 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: Build and Publish Package | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
types: | ||
- closed | ||
|
||
jobs: | ||
publish-package: | ||
if: ${{ github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/v') }} | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out harlequin-trino main branch | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: main | ||
- name: Set up Python 3.10 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.10" | ||
- name: Install Poetry | ||
uses: snok/install-poetry@v1 | ||
with: | ||
version: 1.6.1 | ||
- name: Configure poetry | ||
run: poetry config --no-interaction pypi-token.pypi ${{ secrets.HARLEQUIN_TRINO_PYPI_TOKEN }} | ||
- name: Get harlequin-trino Version | ||
id: harlequin_trino_version | ||
run: echo "harlequin_trino_version=$(poetry version --short)" >> $GITHUB_OUTPUT | ||
- name: Build package | ||
run: poetry build --no-interaction | ||
- name: Publish package to PyPI | ||
run: poetry publish --no-interaction | ||
- name: Create a Github Release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
tag_name: v${{ steps.harlequin_trino_version.outputs.harlequin_trino_version }} | ||
target_commitish: main | ||
token: ${{ secrets.HARLEQUIN_TRINO_RELEASE_TOKEN }} | ||
body_path: CHANGELOG.md | ||
files: | | ||
LICENSE | ||
dist/*harlequin*.whl | ||
dist/*harlequin*.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: Create Release Branch | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
newVersion: | ||
description: A version number for this release (e.g., "0.1.0") | ||
required: true | ||
|
||
jobs: | ||
prepare-release: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
|
||
steps: | ||
- name: Check out harlequin-trino main branch | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: main | ||
- name: Set up Python 3.10 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.10" | ||
- name: Install Poetry | ||
uses: snok/install-poetry@v1 | ||
with: | ||
version: 1.6.1 | ||
- name: Create release branch | ||
run: | | ||
git checkout -b release/v${{ github.event.inputs.newVersion }} | ||
git push --set-upstream origin release/v${{ github.event.inputs.newVersion }} | ||
- name: Bump version | ||
run: poetry version ${{ github.event.inputs.newVersion }} --no-interaction | ||
- name: Ensure package can be built | ||
run: poetry build --no-interaction | ||
- name: Update CHANGELOG | ||
uses: thomaseizinger/keep-a-changelog-new-release@v1 | ||
with: | ||
version: ${{ github.event.inputs.newVersion }} | ||
- name: Commit Changes | ||
uses: stefanzweifel/git-auto-commit-action@v5 | ||
with: | ||
commit_message: Bumps version to ${{ github.event.inputs.newVersion }} | ||
- name: Create pull request into main | ||
uses: thomaseizinger/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
head: release/v${{ github.event.inputs.newVersion }} | ||
base: main | ||
title: v${{ github.event.inputs.newVersion }} | ||
body: > | ||
This PR was automatically generated. It bumps the version number | ||
in pyproject.toml and updates CHANGELOG.md. You may have to close | ||
this PR and reopen it to get the required checks to run. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Harlequin-Trino CHANGELOG | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
## [Unreleased] | ||
|
||
### Features | ||
- Adds a basic Trino adapter with most common connection options. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
.PHONY: check | ||
check: | ||
ruff format . | ||
ruff . --fix | ||
mypy | ||
pytest | ||
|
||
.PHONY: init | ||
init: | ||
docker-compose up -d | ||
|
||
.PHONY: clean | ||
clean: | ||
docker-compose down | ||
|
||
.PHONY: serve | ||
serve: | ||
harlequin -P None -a trino --host localhost -p 8080 -U trino |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,72 @@ | ||
# harlequin-adapter-template | ||
This repo provides a template you can use to accelerate development of a new [Harlequin](https://harlequin.sh) database adapter. | ||
# harlequin-trino | ||
|
||
For an in-depth guide on writing your own adapter, see the [Harlequin Docs](https://harlequin.sh/docs/contributing/adapter-guide). | ||
This repo provides the Harlequin adapter for Trino. | ||
|
||
## Installation | ||
|
||
`harlequin-trino` depends on `harlequin`, so installing this package will also install Harlequin. | ||
|
||
### Using pip | ||
|
||
To install this adapter into an activated virtual environment: | ||
```bash | ||
pip install harlequin-trino | ||
``` | ||
|
||
### Using poetry | ||
|
||
```bash | ||
poetry add harlequin-trino | ||
``` | ||
|
||
### Using pipx | ||
|
||
If you do not already have Harlequin installed: | ||
|
||
```bash | ||
pip install harlequin-trino | ||
``` | ||
|
||
If you would like to add the Trino adapter to an existing Harlequin installation: | ||
|
||
```bash | ||
pipx inject harlequin harlequin-trino | ||
``` | ||
|
||
### As an Extra | ||
Alternatively, you can install Harlequin with the `trino` extra: | ||
|
||
```bash | ||
pip install harlequin[trino] | ||
``` | ||
|
||
```bash | ||
poetry add harlequin[trino] | ||
``` | ||
|
||
```bash | ||
pipx install harlequin[trino] | ||
``` | ||
|
||
## Usage and Configuration | ||
For a minimum connection you are going to need: | ||
- host | ||
- port | ||
- user | ||
|
||
```bash | ||
harlequin -a trino -h localhost -p 8080 -U my_user | ||
``` | ||
|
||
If your trino instance requires a password you can set the `--require_auth` flag to password and use the `--password` flag for your password | ||
```bash | ||
harlequin -a trino -h localhost -p 8080 -U my_user --password my-pass --require_auth password | ||
``` | ||
|
||
Many more options are available; to see the full list, run: | ||
|
||
```bash | ||
harlequin --help | ||
``` | ||
|
||
For more information, see the [Harlequin Docs](https://harlequin.sh/docs/trino/index). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
version: '3.1' | ||
|
||
services: | ||
db: | ||
image: postgres:latest | ||
restart: always | ||
environment: | ||
POSTGRES_PASSWORD: postgres | ||
ports: | ||
- 5432:5432 | ||
|
||
trino: | ||
image: trinodb/trino | ||
restart: always | ||
ports: | ||
- 8080:8080 | ||
volumes: | ||
- ./trino/etc:/etc/trino | ||
|
||
adminer: | ||
image: adminer | ||
restart: always | ||
ports: | ||
- 8081:8080 | ||
|
||
networks: | ||
shared_network: | ||
driver: bridge |
Oops, something went wrong.