Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.

Conversation

@sirupsen
Copy link
Contributor

@sirupsen sirupsen commented May 27, 2022

This adds a docker-compose setup for PrestoSQL v 340.

You can run this with docker-compose up presto.

It's accessible via:

import prestodb prestodb.dbapi.connect(host="127.0.0.1", user="presto").cursor().execute('SELECT * FROM system.runtime.nodes')
# For now while we are in heavy development we install the latest with Poetry
# and execute directly with Poetry. Later, we'll move to the released Pip package.
RUN poetry install -E preql -E mysql -E pgsql -E snowflake
RUN poetry install
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This installs all dev dependencies anyway; not necessary to do the extras anymore.

@@ -0,0 +1,25 @@
FROM openjdk:11-jdk-slim-buster
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Borrowed from this buddy's Github

@erezsh
Copy link
Contributor

erezsh commented May 30, 2022

@sirupsen The docker works, but I still can't change the db. Any advice?

>>> cur.execute('create table tpch.tiny.a(x int)') >>> cur.fetchall() Traceback (most recent call last): ... prestodb.exceptions.PrestoUserError: PrestoUserError(type=USER_ERROR, name=NOT_SUPPORTED, message="This connector does not support creating tables", query_id=20220530_152518_00004_mverw)
@sirupsen
Copy link
Contributor Author

@erezsh I added dev/presto-conf/standalone/catalog/postgresql.properties with the appropriate configuration for connecting to the docker-compose managed PostgreSQL. 👍🏻

If you want to use your own, local PostgreSQL you'd need to update the username/password. In addition, you'll need to map the port from localhost into the container, doing what's described in this Stackoverflow answer. But I suggest you just switch to the one in docker-compose and import the 1M table one in there with the instructions from the README.

For me locally this script:

import prestodb cur = prestodb.dbapi.connect(host="127.0.0.1", user="presto").cursor() print(list(cur.execute('SHOW SCHEMAS FROM postgresql'))) print(list(cur.execute('SELECT * FROM postgresql.public.rating LIMIT 10')))

Yields:

[['information_schema'], ['pg_catalog'], ['public']] [[1, 1, 296, 5.0, 1147880044], [2, 1, 306, 3.5, 1147868817], [3, 1, 307, 5.0, 1147868828], [4, 1, 665, 5.0, 1147878820], [5, 1, 899, 3.5, 1147868510], [6, 1, 1088, 4.0, 1147868495], [7, 1, 1175, 3.5, 1147868826], [8, 1, 1217, 3.5, 1147878326], [9, 1, 1237, 5.0, 1147868839], [10, 1, 1250, 4.0, 1147868414]] 

Because Presto is just a query layer on top, you should be able to just use the existing rating* tables 👍🏻

@erezsh
Copy link
Contributor

erezsh commented May 31, 2022

Okay, it seems to be working! Thanks for the help

@sirupsen
Copy link
Contributor Author

@erezsh cool, good with me merging then?

@erezsh
Copy link
Contributor

erezsh commented May 31, 2022

I think so.

@sirupsen sirupsen merged commit e6c61f8 into master May 31, 2022
@sirupsen sirupsen deleted the presto-docker branch May 31, 2022 14:00
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

3 participants