Skip to content

Commit

Permalink
fix: use pyarrow_hotfix where necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud authored and gforsyth committed Nov 9, 2023
1 parent a3f156f commit 0fa1e5d
Show file tree
Hide file tree
Showing 20 changed files with 36 additions and 3 deletions.
2 changes: 2 additions & 0 deletions ibis/backends/base/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ def _import_pyarrow():
"Exporting to arrow formats requires `pyarrow` but it is not installed"
)
else:
import pyarrow_hotfix # noqa: F401

return pyarrow

def to_pandas_batches(
Expand Down
1 change: 1 addition & 0 deletions ibis/backends/base/sql/alchemy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ def create_table(

import pandas as pd
import pyarrow as pa
import pyarrow_hotfix # noqa: F401

if isinstance(obj, (pd.DataFrame, pa.Table)):
obj = ibis.memtable(obj)
Expand Down
1 change: 1 addition & 0 deletions ibis/backends/bigquery/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,7 @@ def create_table(

if obj is not None:
import pyarrow as pa
import pyarrow_hotfix # noqa: F401

if isinstance(obj, (pd.DataFrame, pa.Table)):
table = ibis.memtable(obj, schema=schema)
Expand Down
1 change: 1 addition & 0 deletions ibis/backends/clickhouse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import clickhouse_connect as cc
import pyarrow as pa
import pyarrow_hotfix # noqa: F401
import sqlalchemy as sa
import sqlglot as sg
import toolz
Expand Down
1 change: 1 addition & 0 deletions ibis/backends/datafusion/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import datafusion as df
import pyarrow as pa
import pyarrow.dataset as ds
import pyarrow_hotfix # noqa: F401
import sqlglot as sg
from sqlglot import exp, transforms
from sqlglot.dialects import Postgres
Expand Down
1 change: 1 addition & 0 deletions ibis/backends/datafusion/udfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import pyarrow as pa
import pyarrow.compute as pc
import pyarrow_hotfix # noqa: F401

import ibis.expr.datatypes as dt # noqa: TCH001

Expand Down
1 change: 1 addition & 0 deletions ibis/backends/duckdb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import duckdb
import pyarrow as pa
import pyarrow_hotfix # noqa: F401
import sqlalchemy as sa
import sqlglot as sg
import toolz
Expand Down
2 changes: 2 additions & 0 deletions ibis/backends/flink/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ def create_table(
"""
import pandas as pd
import pyarrow as pa
import pyarrow_hotfix # noqa: F401

import ibis.expr.types as ir

Expand Down Expand Up @@ -485,6 +486,7 @@ def insert(
"""
import pandas as pd
import pyarrow as pa
import pyarrow_hotfix # noqa: F401

if isinstance(obj, ir.Table):
expr = obj
Expand Down
1 change: 1 addition & 0 deletions ibis/backends/impala/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1389,6 +1389,7 @@ def to_pyarrow(
**kwargs: Any,
) -> pa.Table:
import pyarrow as pa
import pyarrow_hotfix # noqa: F401

from ibis.formats.pyarrow import PyArrowData

Expand Down
3 changes: 1 addition & 2 deletions ibis/backends/pandas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import pandas as pd
import pyarrow as pa
import pyarrow_hotfix # noqa: F401

import ibis.common.exceptions as com
import ibis.config
Expand Down Expand Up @@ -242,8 +243,6 @@ def _from_pandas(df: pd.DataFrame) -> pd.DataFrame:

@classmethod
def _convert_object(cls, obj: Any) -> Any:
import pyarrow as pa

if isinstance(obj, ir.Table):
# Support memtables
assert isinstance(obj.op(), ops.InMemoryTable)
Expand Down
2 changes: 2 additions & 0 deletions ibis/backends/pyspark/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ def create_table(
"""
import pandas as pd
import pyarrow as pa
import pyarrow_hotfix # noqa: F401

if obj is None and schema is None:
raise com.IbisError("The schema or obj parameter is required")
Expand Down Expand Up @@ -827,6 +828,7 @@ def to_pyarrow(
**kwargs: Any,
) -> pa.Table:
import pyarrow as pa
import pyarrow_hotfix # noqa: F401

from ibis.formats.pyarrow import PyArrowData

Expand Down
1 change: 1 addition & 0 deletions ibis/backends/snowflake/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from typing import TYPE_CHECKING, Any

import pyarrow as pa
import pyarrow_hotfix # noqa: F401
import sqlalchemy as sa
import sqlglot as sg
from packaging.version import parse as vparse
Expand Down
1 change: 1 addition & 0 deletions ibis/backends/snowflake/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from typing import TYPE_CHECKING, Any

import pyarrow.parquet as pq
import pyarrow_hotfix # noqa: F401
import pytest
import sqlalchemy as sa
import sqlglot as sg
Expand Down
1 change: 1 addition & 0 deletions ibis/backends/trino/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ def literal_compile(v):

if obj is not None:
import pyarrow as pa
import pyarrow_hotfix # noqa: F401

if isinstance(obj, (pd.DataFrame, pa.Table)):
table = ibis.memtable(obj, schema=schema)
Expand Down
2 changes: 2 additions & 0 deletions ibis/examples/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ def fetch(
else:
return backend.read_csv(path, table_name=table_name)
else:
import pyarrow_hotfix # noqa: F401

if path.endswith(".parquet"):
import pyarrow.parquet

Expand Down
2 changes: 2 additions & 0 deletions ibis/expr/operations/relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ def to_pyarrow(self, schema: Schema) -> pa.Table: # pragma: no cover

def to_pyarrow_bytes(self, schema: Schema) -> bytes:
import pyarrow as pa
import pyarrow_hotfix # noqa: F401

data = self.to_pyarrow(schema=schema)
out = pa.BufferOutputStream()
Expand Down Expand Up @@ -170,6 +171,7 @@ def to_frame(self) -> pd.DataFrame:

def to_pyarrow(self, schema: Schema) -> pa.Table:
import pyarrow as pa
import pyarrow_hotfix # noqa: F401

from ibis.formats.pyarrow import PyArrowSchema

Expand Down
1 change: 1 addition & 0 deletions ibis/formats/pyarrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import TYPE_CHECKING, Any

import pyarrow as pa
import pyarrow_hotfix # noqa: F401

import ibis.expr.datatypes as dt
from ibis.expr.schema import Schema
Expand Down
13 changes: 12 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pandas = ">=1.2.5,<3"
parsy = ">=2,<3"
pins = { version = ">=0.8.3,<1", extras = ["gcs"] }
pyarrow = ">=2,<15"
pyarrow-hotfix = ">=0.4,<1"
python-dateutil = ">=2.8.2,<3"
pytz = ">=2022.7"
rich = ">=12.4.4,<14"
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ pure-eval==0.2.2 ; python_version >= "3.9" and python_version < "4.0"
pure-sasl==0.6.2 ; python_version >= "3.9" and python_version < "4.0"
py-cpuinfo==9.0.0 ; python_version >= "3.9" and python_version < "4.0"
py4j==0.10.9.5 ; python_version >= "3.9" and python_version < "4.0"
pyarrow-hotfix==0.4 ; python_version >= "3.9" and python_version < "4.0"
pyarrow==14.0.0 ; python_version >= "3.9" and python_version < "4.0"
pyasn1-modules==0.3.0 ; python_version >= "3.9" and python_version < "4.0"
pyasn1==0.5.0 ; python_version >= "3.9" and python_version < "4.0"
Expand Down

0 comments on commit 0fa1e5d

Please sign in to comment.