Skip to content

Commit

Permalink
Make mypy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
Fokko committed Sep 6, 2023
1 parent 2b04ae2 commit 2f06a24
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion py-polars/polars/io/iceberg.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def _(a: Call) -> Any:
elif f == "is_nan":
return IsNaN(ref)
elif f == "scalar":
return AlwaysTrue() if args[0] else AlwaysFalse()
return AlwaysTrue() if args[0] else AlwaysFalse() # type: ignore[no-untyped-call]

raise ValueError(f"Unknown call: {f}")

Expand Down
18 changes: 13 additions & 5 deletions py-polars/tests/unit/io/test_iceberg.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,23 @@
import contextlib
import os
from pathlib import Path
from typing import TYPE_CHECKING

import pytest

import polars as pl
from polars.io.iceberg import _convert_predicate, _to_ast

if TYPE_CHECKING:
from pyiceberg.expressions import BooleanExpression


@pytest.fixture()
def iceberg_path() -> str:
# Iceberg requires absolute paths, so we'll symlink
# the test table into /tmp/iceberg/t1/
Path("/tmp/iceberg").mkdir(parents=True, exist_ok=True)
current_path = Path.cwd()
current_path = os.path.dirname(__file__)
with contextlib.suppress(FileExistsError):
os.symlink(f"{current_path}/files/iceberg-table", "/tmp/iceberg/t1")

Expand All @@ -42,15 +46,19 @@ def test_scan_iceberg_filter_on_column(iceberg_path: str) -> None:
def test_true_expression() -> None:
from pyiceberg.expressions import AlwaysTrue

always_true: BooleanExpression = AlwaysTrue()

expr = _to_ast("pa.compute.scalar(True)")
assert _convert_predicate(expr) == AlwaysTrue()
assert _convert_predicate(expr) == always_true


def test_false_expression() -> None:
from pyiceberg.expressions import AlwaysFalse

always_false: BooleanExpression = AlwaysFalse()

expr = _to_ast("pa.compute.scalar(False)")
assert _convert_predicate(expr) == AlwaysFalse()
assert _convert_predicate(expr) == always_false


def test_is_null_expression() -> None:
Expand Down Expand Up @@ -82,7 +90,7 @@ def test_is_not_nan_expression() -> None:


def test_isin_expression() -> None:
from pyiceberg.expressions import In, literal
from pyiceberg.expressions import In, literal # type: ignore[attr-defined]

expr = _to_ast("(pa.compute.field('location_id')).isin([1,2,3])")
assert _convert_predicate(expr) == In(
Expand All @@ -91,7 +99,7 @@ def test_isin_expression() -> None:


def test_parse_combined_expression() -> None:
from pyiceberg.expressions import (
from pyiceberg.expressions import ( # type: ignore[attr-defined]
And,
EqualTo,
GreaterThan,
Expand Down

0 comments on commit 2f06a24

Please sign in to comment.