Skip to content

deps: remove parsy dependency #1610

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bigframes/core/compile/scalar_op_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -747,12 +747,12 @@ def date_diff_op_impl(x: ibis_types.DateValue, y: ibis_types.DateValue):

@scalar_op_compiler.register_binary_op(ops.date_add_op)
def date_add_op_impl(x: ibis_types.DateValue, y: ibis_types.IntegerValue):
return x.cast("timestamp") + y.to_interval("us") # type: ignore
return x.cast(ibis_dtypes.timestamp()) + y.to_interval("us") # type: ignore


@scalar_op_compiler.register_binary_op(ops.date_sub_op)
def date_sub_op_impl(x: ibis_types.DateValue, y: ibis_types.IntegerValue):
return x.cast("timestamp") - y.to_interval("us") # type: ignore
return x.cast(ibis_dtypes.timestamp()) - y.to_interval("us") # type: ignore


@scalar_op_compiler.register_unary_op(ops.FloorDtOp, pass_op=True)
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
"db-dtypes >=1.4.2",
# For vendored ibis-framework.
"atpublic>=2.3,<6",
"parsy>=2,<3",
"python-dateutil>=2.8.2,<3",
"pytz>=2022.7",
"toolz>=0.11,<2",
Expand Down
1 change: 0 additions & 1 deletion testing/constraints-3.9.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ matplotlib==3.7.1
db-dtypes==1.4.2
# For vendored ibis-framework.
atpublic==2.3
parsy==2.0
python-dateutil==2.8.2
pytz==2022.7
toolz==0.11
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from bigframes_vendored.ibis.backends.sql.compilers import BigQueryCompiler
from bigframes_vendored.ibis.backends.sql.datatypes import BigQueryType
import bigframes_vendored.ibis.common.exceptions as com
import bigframes_vendored.ibis.expr.datatypes as ibis_dtypes
import bigframes_vendored.ibis.expr.operations as ops
import bigframes_vendored.ibis.expr.schema as sch
import bigframes_vendored.ibis.expr.types as ir
Expand Down Expand Up @@ -773,7 +774,7 @@ def execute(self, expr, params=None, limit="default", **kwargs):
self._run_pre_execute_hooks(expr)

schema = expr.as_table().schema() - bigframes_vendored.ibis.schema(
{"_TABLE_SUFFIX": "string"}
{"_TABLE_SUFFIX": ibis_dtypes.string()}
)

sql = self.compile(expr, limit=limit, params=params, **kwargs)
Expand Down
2 changes: 1 addition & 1 deletion third_party/bigframes_vendored/ibis/expr/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2369,7 +2369,7 @@ def ifelse(condition: Any, true_expr: Any, false_expr: Any) -> ir.Value:
if not isinstance(condition, ir.Value):
condition = literal(condition, type="bool")
elif not condition.type().is_boolean():
condition = condition.cast("bool")
condition = condition.cast(bool)
return condition.ifelse(true_expr, false_expr)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from bigframes_vendored.ibis.expr.datatypes.cast import * # noqa: F403
from bigframes_vendored.ibis.expr.datatypes.core import * # noqa: F403
from bigframes_vendored.ibis.expr.datatypes.parse import * # noqa: F403
from bigframes_vendored.ibis.expr.datatypes.value import * # noqa: F403

halffloat = float16 # noqa: F405
Expand Down
9 changes: 0 additions & 9 deletions third_party/bigframes_vendored/ibis/expr/datatypes/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,6 @@ def castable(self, to, **kwargs) -> bool:

return castable(self, to, **kwargs)

@classmethod
def from_string(cls, value) -> Self:
from bigframes_vendored.ibis.expr.datatypes.parse import parse

try:
return parse(value)
except SyntaxError:
raise TypeError(f"{value!r} cannot be parsed as a datatype")

@classmethod
def from_typehint(cls, typ, nullable=True) -> Self:
origin_type = get_origin(typ)
Expand Down
211 changes: 0 additions & 211 deletions third_party/bigframes_vendored/ibis/expr/datatypes/parse.py

This file was deleted.

4 changes: 2 additions & 2 deletions third_party/bigframes_vendored/ibis/expr/types/arrays.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ def map(self, func: Deferred | Callable[[ir.Value], ir.Value]) -> ir.ArrayValue:

The most succinct way to use `map` is with `Deferred` expressions:

>>> t.a.map((_ + 100).cast("float"))
>>> t.a.map((_ + 100).cast(float))
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ ArrayMap(a, Cast(Add(_, 100), float64)) ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
Expand All @@ -429,7 +429,7 @@ def map(self, func: Deferred | Callable[[ir.Value], ir.Value]) -> ir.ArrayValue:

You can also use `map` with a lambda function:

>>> t.a.map(lambda x: (x + 100).cast("float"))
>>> t.a.map(lambda x: (x + 100).cast(float))
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ ArrayMap(a, Cast(Add(x, 100), float64)) ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
Expand Down
23 changes: 1 addition & 22 deletions third_party/bigframes_vendored/ibis/expr/types/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,31 +179,10 @@ def cast(self, target_type: Any) -> Value:
│ … │
└────────────────────────────┘

or string names

>>> x.cast("uint16")
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Cast(bill_depth_mm, uint16) ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ uint16 │
├─────────────────────────────┤
│ 19 │
│ 17 │
│ 18 │
│ NULL │
│ 19 │
│ 21 │
│ 18 │
│ 20 │
│ 18 │
│ 20 │
│ … │
└─────────────────────────────┘

If you make an illegal cast, you won't know until the backend actually
executes it. Consider [`.try_cast()`](#ibis.expr.types.generic.Value.try_cast).

>>> ibis.literal("a string").cast("int64") # doctest: +SKIP
>>> ibis.literal("a string").cast(int) # doctest: +SKIP
<error>
"""
op = ops.Cast(self, to=target_type)
Expand Down
18 changes: 0 additions & 18 deletions third_party/bigframes_vendored/ibis/expr/types/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,24 +446,6 @@ def str(self) -> ir.StringValue:
│ NULL │
└──────────────────────┘

Note the difference between `.string` and `.cast("string")`.

The latter preserves quotes for JSON string values and returns a valid
JSON string.

>>> t.js.cast("string")
┏━━━━━━━━━━━━━━━━━━┓
┃ Cast(js, string) ┃
┡━━━━━━━━━━━━━━━━━━┩
│ string │
├──────────────────┤
│ "a" │
│ "b" │
│ 1 │
│ {} │
│ [{"a": 1}] │
└──────────────────┘

Here's a more complex example with a table containing a JSON column
with nested fields.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3798,7 +3798,7 @@ def pivot_longer(
... names_pattern=r"wk(.+)",
... names_transform=int,
... values_to="rank",
... values_transform=_.cast("int"),
... values_transform=_.cast(int),
... ).drop_null("rank")
┏━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━┳━━━━━━━┓
┃ artist ┃ track ┃ date_entered ┃ week ┃ rank ┃
Expand Down