Skip to content

Commit

Permalink
feat(exasol): add exasol backend
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicoretti authored and cpcloud committed Dec 14, 2023
1 parent bf6ed1a commit 295903d
Show file tree
Hide file tree
Showing 43 changed files with 1,175 additions and 96 deletions.
18 changes: 17 additions & 1 deletion .github/workflows/ibis-backends.yml
Expand Up @@ -159,6 +159,13 @@ jobs:
- oracle
services:
- oracle
- name: exasol
title: Exasol
serial: true
extras:
- exasol
services:
- exasol
- name: flink
title: Flink
serial: true
Expand Down Expand Up @@ -283,6 +290,15 @@ jobs:
- flink
services:
- flink
- os: windows-latest
backend:
name: exasol
title: Exasol
serial: true
extras:
- exasol
services:
- exasol
steps:
- name: update and install system dependencies
if: matrix.os == 'ubuntu-latest' && matrix.backend.sys-deps != null
Expand Down Expand Up @@ -604,7 +620,7 @@ jobs:
- run: python -m pip install --upgrade pip 'poetry==1.7.1'

- name: remove deps that are not compatible with sqlalchemy 2
run: poetry remove snowflake-sqlalchemy
run: poetry remove snowflake-sqlalchemy sqlalchemy-exasol

- name: add sqlalchemy 2
run: poetry add --lock --optional 'sqlalchemy>=2,<3'
Expand Down
75 changes: 75 additions & 0 deletions ci/schema/exasol.sql
@@ -0,0 +1,75 @@
DROP SCHEMA IF EXISTS EXASOL CASCADE;
CREATE SCHEMA EXASOL;

CREATE OR REPLACE TABLE EXASOL.diamonds
(
"carat" DOUBLE,
"cut" VARCHAR(256),
"color" VARCHAR(256),
"clarity" VARCHAR(256),
"depth" DOUBLE,
"table" DOUBLE,
"price" BIGINT,
"x" DOUBLE,
"y" DOUBLE,
"z" DOUBLE
);

CREATE OR REPLACE TABLE EXASOL.batting
(
"playerID" VARCHAR(256),
"yearID" BIGINT,
"stint" BIGINT,
"teamID" VARCHAR(256),
"logID" VARCHAR(256),
"G" BIGINT,
"AB" BIGINT,
"R" BIGINT,
"H" BIGINT,
"X2B" BIGINT,
"X3B" BIGINT,
"HR" BIGINT,
"RBI" BIGINT,
"SB" BIGINT,
"CS" BIGINT,
"BB" BIGINT,
"SO" BIGINT,
"IBB" BIGINT,
"HBP" BIGINT,
"SH" BIGINT,
"SF" BIGINT,
"GIDP" BIGINT
);

CREATE OR REPLACE TABLE EXASOL.awards_players
(
"playerId" VARCHAR(256),
"awardID" VARCHAR(256),
"yearID" VARCHAR(256),
"logID" VARCHAR(256),
"tie" VARCHAR(256),
"notest" VARCHAR(256)
);

CREATE OR REPLACE TABLE EXASOL.functional_alltypes
(
"id" INTEGER,
"bool_col" BOOLEAN,
"tinyint_col" SHORTINT,
"small_int" SMALLINT,
"int_col" INTEGER,
"bigint_col" BIGINT,
"float_col" FLOAT,
"double_col" DOUBLE PRECISION,
"date_string_col" VARCHAR(256),
"string_col" VARCHAR(256),
"timestamp_col" TIMESTAMP,
"year" INTEGER,
"month" INTEGER
);


IMPORT INTO EXASOL.diamonds FROM LOCAL CSV FILE '/data/diamonds.csv' COLUMN SEPARATOR = ',' SKIP = 1;
IMPORT INTO EXASOL.batting FROM LOCAL CSV FILE '/data/batting.csv' COLUMN SEPARATOR = ',' SKIP = 1;
IMPORT INTO EXASOL.awards_players FROM LOCAL CSV FILE '/data/awards_players.csv' COLUMN SEPARATOR = ',' SKIP = 1;
IMPORT INTO EXASOL.functional_alltypes FROM LOCAL CSV FILE '/data/functional_alltypes.csv' COLUMN SEPARATOR = ',' SKIP = 1;
19 changes: 19 additions & 0 deletions compose.yaml
Expand Up @@ -412,6 +412,23 @@ services:
volumes:
- oracle:/opt/oracle/data

exasol:
image: exasol/docker-db:7.1.23
privileged: true
ports:
- 8563:8563
healthcheck:
interval: 10s
retries: 9
timeout: 90s
test:
- CMD-SHELL
- /usr/opt/EXASuite-7/EXASolution-7.1.23/bin/Console/exaplus -c 127.0.0.1:8563 -u sys -p exasol -encryption OFF <<< 'SELECT 1'
networks:
- exasol
volumes:
- exasol:/data

flink-jobmanager:
build: ./docker/flink
image: ibis-flink
Expand Down Expand Up @@ -452,6 +469,7 @@ networks:
trino:
druid:
oracle:
exasol:
flink:

volumes:
Expand All @@ -469,3 +487,4 @@ volumes:
oracle:
postgres:
minio:
exasol:
96 changes: 96 additions & 0 deletions docs/backends/exasol.qmd
@@ -0,0 +1,96 @@
# Exasol

[https://www.exasol.com](https://www.exasol.com)

## Install

Install Ibis and dependencies for the Exasol backend:

::: {.panel-tabset}

## `pip`

Install with the `exasol` extra:

```{.bash}
pip install 'ibis-framework[exasol]'
```

And connect:

```{.python}
import ibis
con = ibis.exasol.connect(...) # <1>
```

1. Adjust connection parameters as needed.

## `conda`

Install for Exasol:

```{.bash}
conda install -c conda-forge ibis-exasol
```

And connect:

```{.python}
import ibis
con = ibis.exasol.connect(...) # <1>
```

1. Adjust connection parameters as needed.

## `mamba`

Install for Exasol:

```{.bash}
mamba install -c conda-forge ibis-exasol
```

And connect:

```{.python}
import ibis
con = ibis.exasol.connect(...) # <1>
```

1. Adjust connection parameters as needed.

:::

## Connect

### `ibis.exasol.connect`

```python
con = ibis.exasol.connect(
user = "username",
password = "password",
host = "localhost",
port = 8563,
schema = None,
encryption = True,
certificate_validation = True,
encoding = "en_US.UTF-8"
)
```

::: {.callout-note}
`ibis.exasol.connect` is a thin wrapper around [`ibis.backends.exasol.Backend.do_connect`](#ibis.backends.exasol.Backend.do_connect).
:::

### Connection Parameters

```{python}
#| echo: false
#| output: asis
from _utils import render_do_connect
render_do_connect("exasol")
```
6 changes: 4 additions & 2 deletions ibis/backends/base/__init__.py
Expand Up @@ -33,16 +33,16 @@

__all__ = ("BaseBackend", "Database", "connect")


_IBIS_TO_SQLGLOT_DIALECT = {
"mssql": "tsql",
"impala": "hive",
"pyspark": "spark",
"polars": "postgres",
"datafusion": "postgres",
# closest match see https://github.com/ibis-project/ibis/pull/7303#discussion_r1350223901
"exa.websocket": "oracle",
}


_SQLALCHEMY_TO_SQLGLOT_DIALECT = {
# sqlalchemy dialects of backends not listed here match the sqlglot dialect
# name
Expand All @@ -52,6 +52,8 @@
# druid allows double quotes for identifiers, like postgres:
# https://druid.apache.org/docs/latest/querying/sql#identifiers-and-literals
"druid": "postgres",
# closest match see https://github.com/ibis-project/ibis/pull/7303#discussion_r1350223901
"exa.websocket": "oracle",
}


Expand Down
2 changes: 1 addition & 1 deletion ibis/backends/base/sql/alchemy/__init__.py
Expand Up @@ -554,7 +554,7 @@ def _schema_from_sqla_table(
dtype = schema[name]
else:
dtype = cls.compiler.translator_class.get_ibis_type(
column.type, nullable=column.nullable
column.type, nullable=column.nullable or column.nullable is None
)
pairs.append((name, dtype))
return sch.schema(pairs)
Expand Down
1 change: 1 addition & 0 deletions ibis/backends/conftest.py
Expand Up @@ -539,6 +539,7 @@ def ddl_con(ddl_backend):
params=_get_backends_to_test(
keep=(
"duckdb",
"exasol",
"mssql",
"mysql",
"oracle",
Expand Down

0 comments on commit 295903d

Please sign in to comment.