Skip to content

Commit 293f676

Browse files
authored
deps: remove parsy dependency (#1610)
* deps: remove parsy dependency We do not need to specify ibis types as strings. * remove an instance of cast via string * remove another hidden instance of string to cast
1 parent b4b7073 commit 293f676

File tree

12 files changed

+9
-270
lines changed

12 files changed

+9
-270
lines changed

bigframes/core/compile/scalar_op_compiler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -747,12 +747,12 @@ def date_diff_op_impl(x: ibis_types.DateValue, y: ibis_types.DateValue):
747747

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

752752

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

757757

758758
@scalar_op_compiler.register_unary_op(ops.FloorDtOp, pass_op=True)

setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
"db-dtypes >=1.4.2",
6262
# For vendored ibis-framework.
6363
"atpublic>=2.3,<6",
64-
"parsy>=2,<3",
6564
"python-dateutil>=2.8.2,<3",
6665
"pytz>=2022.7",
6766
"toolz>=0.11,<2",

testing/constraints-3.9.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ matplotlib==3.7.1
2727
db-dtypes==1.4.2
2828
# For vendored ibis-framework.
2929
atpublic==2.3
30-
parsy==2.0
3130
python-dateutil==2.8.2
3231
pytz==2022.7
3332
toolz==0.11

third_party/bigframes_vendored/ibis/backends/bigquery/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from bigframes_vendored.ibis.backends.sql.compilers import BigQueryCompiler
2929
from bigframes_vendored.ibis.backends.sql.datatypes import BigQueryType
3030
import bigframes_vendored.ibis.common.exceptions as com
31+
import bigframes_vendored.ibis.expr.datatypes as ibis_dtypes
3132
import bigframes_vendored.ibis.expr.operations as ops
3233
import bigframes_vendored.ibis.expr.schema as sch
3334
import bigframes_vendored.ibis.expr.types as ir
@@ -773,7 +774,7 @@ def execute(self, expr, params=None, limit="default", **kwargs):
773774
self._run_pre_execute_hooks(expr)
774775

775776
schema = expr.as_table().schema() - bigframes_vendored.ibis.schema(
776-
{"_TABLE_SUFFIX": "string"}
777+
{"_TABLE_SUFFIX": ibis_dtypes.string()}
777778
)
778779

779780
sql = self.compile(expr, limit=limit, params=params, **kwargs)

third_party/bigframes_vendored/ibis/expr/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2369,7 +2369,7 @@ def ifelse(condition: Any, true_expr: Any, false_expr: Any) -> ir.Value:
23692369
if not isinstance(condition, ir.Value):
23702370
condition = literal(condition, type="bool")
23712371
elif not condition.type().is_boolean():
2372-
condition = condition.cast("bool")
2372+
condition = condition.cast(bool)
23732373
return condition.ifelse(true_expr, false_expr)
23742374

23752375

third_party/bigframes_vendored/ibis/expr/datatypes/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
from bigframes_vendored.ibis.expr.datatypes.cast import * # noqa: F403
66
from bigframes_vendored.ibis.expr.datatypes.core import * # noqa: F403
7-
from bigframes_vendored.ibis.expr.datatypes.parse import * # noqa: F403
87
from bigframes_vendored.ibis.expr.datatypes.value import * # noqa: F403
98

109
halffloat = float16 # noqa: F405

third_party/bigframes_vendored/ibis/expr/datatypes/core.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -167,15 +167,6 @@ def castable(self, to, **kwargs) -> bool:
167167

168168
return castable(self, to, **kwargs)
169169

170-
@classmethod
171-
def from_string(cls, value) -> Self:
172-
from bigframes_vendored.ibis.expr.datatypes.parse import parse
173-
174-
try:
175-
return parse(value)
176-
except SyntaxError:
177-
raise TypeError(f"{value!r} cannot be parsed as a datatype")
178-
179170
@classmethod
180171
def from_typehint(cls, typ, nullable=True) -> Self:
181172
origin_type = get_origin(typ)

third_party/bigframes_vendored/ibis/expr/datatypes/parse.py

Lines changed: 0 additions & 211 deletions
This file was deleted.

third_party/bigframes_vendored/ibis/expr/types/arrays.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ def map(self, func: Deferred | Callable[[ir.Value], ir.Value]) -> ir.ArrayValue:
416416
417417
The most succinct way to use `map` is with `Deferred` expressions:
418418
419-
>>> t.a.map((_ + 100).cast("float"))
419+
>>> t.a.map((_ + 100).cast(float))
420420
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
421421
┃ ArrayMap(a, Cast(Add(_, 100), float64)) ┃
422422
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
@@ -429,7 +429,7 @@ def map(self, func: Deferred | Callable[[ir.Value], ir.Value]) -> ir.ArrayValue:
429429
430430
You can also use `map` with a lambda function:
431431
432-
>>> t.a.map(lambda x: (x + 100).cast("float"))
432+
>>> t.a.map(lambda x: (x + 100).cast(float))
433433
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
434434
┃ ArrayMap(a, Cast(Add(x, 100), float64)) ┃
435435
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩

third_party/bigframes_vendored/ibis/expr/types/generic.py

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -179,31 +179,10 @@ def cast(self, target_type: Any) -> Value:
179179
│ … │
180180
└────────────────────────────┘
181181
182-
or string names
183-
184-
>>> x.cast("uint16")
185-
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
186-
┃ Cast(bill_depth_mm, uint16) ┃
187-
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
188-
│ uint16 │
189-
├─────────────────────────────┤
190-
│ 19 │
191-
│ 17 │
192-
│ 18 │
193-
│ NULL │
194-
│ 19 │
195-
│ 21 │
196-
│ 18 │
197-
│ 20 │
198-
│ 18 │
199-
│ 20 │
200-
│ … │
201-
└─────────────────────────────┘
202-
203182
If you make an illegal cast, you won't know until the backend actually
204183
executes it. Consider [`.try_cast()`](#ibis.expr.types.generic.Value.try_cast).
205184
206-
>>> ibis.literal("a string").cast("int64") # doctest: +SKIP
185+
>>> ibis.literal("a string").cast(int) # doctest: +SKIP
207186
<error>
208187
"""
209188
op = ops.Cast(self, to=target_type)

third_party/bigframes_vendored/ibis/expr/types/json.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -446,24 +446,6 @@ def str(self) -> ir.StringValue:
446446
│ NULL │
447447
└──────────────────────┘
448448
449-
Note the difference between `.string` and `.cast("string")`.
450-
451-
The latter preserves quotes for JSON string values and returns a valid
452-
JSON string.
453-
454-
>>> t.js.cast("string")
455-
┏━━━━━━━━━━━━━━━━━━┓
456-
┃ Cast(js, string) ┃
457-
┡━━━━━━━━━━━━━━━━━━┩
458-
│ string │
459-
├──────────────────┤
460-
│ "a" │
461-
│ "b" │
462-
│ 1 │
463-
│ {} │
464-
│ [{"a": 1}] │
465-
└──────────────────┘
466-
467449
Here's a more complex example with a table containing a JSON column
468450
with nested fields.
469451

third_party/bigframes_vendored/ibis/expr/types/relations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3798,7 +3798,7 @@ def pivot_longer(
37983798
... names_pattern=r"wk(.+)",
37993799
... names_transform=int,
38003800
... values_to="rank",
3801-
... values_transform=_.cast("int"),
3801+
... values_transform=_.cast(int),
38023802
... ).drop_null("rank")
38033803
┏━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━┳━━━━━━━┓
38043804
┃ artist ┃ track ┃ date_entered ┃ week ┃ rank ┃

0 commit comments

Comments
 (0)