Skip to content

Commit

Permalink
Respond to review comments and test env changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jmao-denver committed Jan 25, 2023
1 parent 4181607 commit a0a04b5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
5 changes: 0 additions & 5 deletions Integrations/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,6 @@ def runInDocker = { String name, String sourcePath, List<String> command, Closur
runCommand '''set -eux; \\
pip3 install unittest-xml-reporting==3.0.4; \\
mkdir -p /out/report; \\
apt-get -qq update; \\
apt-get -qq -y install odbc-postgresql; \\
apt-get -qq -y install g++ libboost-all-dev unixodbc-dev; \\
pip3 install turbodbc; \\
pip3 install adbc-driver-manager adbc-driver-postgresql; \\
echo "[PostgreSQL]" > /etc/odbcinst.ini; \\
echo "Driver = /usr/lib/x86_64-linux-gnu/odbc/psqlodbcw.so" >> /etc/odbcinst.ini; \\
echo "Threading = 2" >> /etc/odbcinst.ini'''
Expand Down
2 changes: 2 additions & 0 deletions py/server/deephaven/dbc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#
# Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending
#

"""The dbc package includes the modules for external database integration."""
11 changes: 6 additions & 5 deletions py/server/deephaven/dbc/adbc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
# Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending
#
"""This module supports ingesting data from external databases (relational and other types) into Deephaven via the
Python DB-API 2.0 ( PEP 249) and the Apache Arrow Database Connectivity (ADBC) interfaces. (Please refer to
Python DB-API 2.0 (PEP 249) and the Apache Arrow Database Connectivity (ADBC) interfaces. (Please refer to
https://arrow.apache.org/docs/dev/format/ADBC.html for more details on ADBC).
ADBC defines a standard API to fetch data in Arrow format from databases that support Arrow natively as well as
from databases that only support ODBC/JDBC. By relying on ADBC, Deephaven is able to ingest data efficiently from a
wide variety of data sources. """

from typing import Any

from deephaven.table import Table
Expand All @@ -20,7 +21,7 @@
raise DHError(message="import ADBC driver manager failed")


def read_cursor(cursor: Any) -> Table:
def read_cursor(cursor: adbc_driver_manager.dbapi.Cursor) -> Table:
"""Converts the Arrow data of the provided cursor into a Deephaven table.
Args:
Expand All @@ -31,15 +32,15 @@ def read_cursor(cursor: Any) -> Table:
a new Table
Raises:
DHError
DHError, TypeError
"""

if not isinstance(cursor, adbc_driver_manager.dbapi.Cursor):
raise DHError(message='')
raise TypeError(f"expect {adbc_driver_manager.dbapi.Cursor} got {type(cursor)} instead.")

try:
pa_table = cursor.fetch_arrow_table()
except Exception as e:
raise DHError(e, message="failed to fetch ADBC result as a Arrow table.") from e
raise DHError(e, message="failed to fetch ADBC result as an Arrow table.") from e

return dharrow.to_table(pa_table)
14 changes: 7 additions & 7 deletions py/server/deephaven/dbc/odbc.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#
# Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending
#
"""This module supports ingesting data from external relational databases into Deephaven via the Python DB-API 2.0 (
PEP 249) and the Open Database Connectivity (ODBC) interfaces by using the Turbodbc module.
"""This module supports ingesting data from external relational databases into Deephaven via the Python DB-API 2.0
(PEP 249) and the Open Database Connectivity (ODBC) interfaces by using the Turbodbc module.
Turbodbc is DB-API 2.0 compliant, provides access to relational databases via the ODBC interface and more
importantly it has optimized built-in Apache Arrow support when fetching ODBC result sets. This enables Deephaven to
importantly it has optimized, built-in Apache Arrow support when fetching ODBC result sets. This enables Deephaven to
achieve maximum efficiency when ingesting relational data. """

from typing import Any

from deephaven import DHError
Expand All @@ -19,7 +20,7 @@
raise DHError(message="import turbodbc failed")


def read_cursor(cursor: Any) -> Table:
def read_cursor(cursor: turbodbc.cursor.Cursor) -> Table:
"""Converts the result set of the provided cursor into a Deephaven table.
Args:
Expand All @@ -30,12 +31,11 @@ def read_cursor(cursor: Any) -> Table:
a new Table
Raises:
DHError
DHError, TypeError
"""

if not isinstance(cursor, turbodbc.cursor.Cursor):
raise DHError(message='')

raise TypeError(f"expect {turbodbc.cursor.Cursor} got {type(cursor)} instead.")
try:
pa_table = cursor.fetchallarrow()
except Exception as e:
Expand Down

0 comments on commit a0a04b5

Please sign in to comment.