Skip to content

Commit 53b6113

Browse files
committed
chore: fix formatting and types
1 parent e45cd9e commit 53b6113

File tree

6 files changed

+36
-14
lines changed

6 files changed

+36
-14
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,4 @@ tests/js/node_modules/
6464
pylintrc
6565
pylintrc.test
6666
dummy.pkl
67+
.mypy_cache/

bigframes/bigquery/_operations/obj.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,25 @@
1313
# limitations under the License.
1414

1515

16-
"""
17-
ObjectRef functions defined from
18-
https://cloud.google.com/bigquery/docs/reference/standard-sql/object-ref-functions
16+
"""This module integrates BigQuery built-in 'ObjectRef' functions for use with Series/DataFrame objects,
17+
such as OBJ.FETCH_METADATA:
18+
https://docs.cloud.google.com/bigquery/docs/reference/standard-sql/objectref_functions
19+
20+
21+
.. warning::
22+
23+
This product or feature is subject to the "Pre-GA Offerings Terms" in the
24+
General Service Terms section of the `Service Specific Terms
25+
<https://cloud.google.com/terms/service-terms>`_. Pre-GA products and
26+
features are available "as is" and might have limited support. For more
27+
information, see the `launch stage descriptions
28+
<https://cloud.google.com/products?hl=en#product-launch-stages>`_.
29+
30+
31+
.. note::
32+
33+
To provide feedback or request support for this feature, send an email to
34+
bq-objectref-feedback@google.com.
1935
"""
2036

2137

bigframes/bigquery/obj.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@
1616
<https://cloud.google.com/bigquery/docs/object-table-object-ref-functions>`_ functions.
1717
"""
1818

19-
from bigframes.bigquery._operations.obj import (
20-
fetch_metadata,
21-
get_access_url,
22-
make_ref,
23-
)
19+
from bigframes.bigquery._operations.obj import fetch_metadata, get_access_url, make_ref
2420

2521
__all__ = [
2622
"fetch_metadata",

bigframes/core/compile/ibis_compiler/scalar_op_registry.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import functools
1818
import typing
19+
from typing import cast
1920

2021
from bigframes_vendored import ibis
2122
import bigframes_vendored.ibis.expr.api as ibis_api
@@ -1248,7 +1249,9 @@ def obj_fetch_metadata_op_impl(obj_ref: ibis_types.Value):
12481249
@scalar_op_compiler.register_unary_op(ops.ObjGetAccessUrl, pass_op=True)
12491250
def obj_get_access_url_op_impl(obj_ref: ibis_types.Value, op: ops.ObjGetAccessUrl):
12501251
if op.duration is not None:
1251-
duration_value = ibis_types.literal(op.duration).to_interval("us")
1252+
duration_value = cast(
1253+
ibis_types.IntegerValue, ibis_types.literal(op.duration)
1254+
).to_interval("us")
12521255
return obj_get_access_url_with_duration(
12531256
obj_ref=obj_ref, mode=op.mode, duration=duration_value
12541257
)
@@ -2162,9 +2165,7 @@ def obj_get_access_url(obj_ref: _OBJ_REF_IBIS_DTYPE, mode: ibis_dtypes.String) -
21622165

21632166

21642167
@ibis_udf.scalar.builtin(name="OBJ.GET_ACCESS_URL")
2165-
def obj_get_access_url_with_duration(
2166-
obj_ref: _OBJ_REF_IBIS_DTYPE, mode: ibis_dtypes.String, duration: ibis_dtypes.Interval(unit="us") # type: ignore
2167-
) -> ibis_dtypes.JSON: # type: ignore
2168+
def obj_get_access_url_with_duration(obj_ref, mode, duration) -> ibis_dtypes.JSON: # type: ignore
21682169
"""Get access url (as ObjectRefRumtime JSON) from ObjectRef."""
21692170

21702171

docs/reference/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ packages.
1111
bigframes.bigquery
1212
bigframes.bigquery.ai
1313
bigframes.bigquery.ml
14+
bigframes.bigquery.obj
1415
bigframes.enums
1516
bigframes.exceptions
1617
bigframes.geopandas

tests/unit/bigquery/test_obj.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
import datetime
1616
from unittest.mock import MagicMock
1717

18-
import pytest
19-
2018
import bigframes.bigquery.obj as obj
2119
import bigframes.operations as ops
2220
import bigframes.series as series
@@ -26,26 +24,31 @@ def test_fetch_metadata_op_structure():
2624
op = ops.obj_fetch_metadata_op
2725
assert op.name == "obj_fetch_metadata"
2826

27+
2928
def test_get_access_url_op_structure():
3029
op = ops.ObjGetAccessUrl(mode="r")
3130
assert op.name == "obj_get_access_url"
3231
assert op.mode == "r"
3332
assert op.duration is None
3433

34+
3535
def test_get_access_url_with_duration_op_structure():
3636
op = ops.ObjGetAccessUrl(mode="rw", duration=3600000000)
3737
assert op.name == "obj_get_access_url"
3838
assert op.mode == "rw"
3939
assert op.duration == 3600000000
4040

41+
4142
def test_make_ref_op_structure():
4243
op = ops.obj_make_ref_op
4344
assert op.name == "obj_make_ref"
4445

46+
4547
def test_make_ref_json_op_structure():
4648
op = ops.obj_make_ref_json_op
4749
assert op.name == "obj_make_ref_json"
4850

51+
4952
def test_fetch_metadata_calls_apply_unary_op():
5053
s = MagicMock(spec=series.Series)
5154

@@ -55,6 +58,7 @@ def test_fetch_metadata_calls_apply_unary_op():
5558
args, _ = s._apply_unary_op.call_args
5659
assert args[0] == ops.obj_fetch_metadata_op
5760

61+
5862
def test_get_access_url_calls_apply_unary_op_without_duration():
5963
s = MagicMock(spec=series.Series)
6064

@@ -66,6 +70,7 @@ def test_get_access_url_calls_apply_unary_op_without_duration():
6670
assert args[0].mode == "r"
6771
assert args[0].duration is None
6872

73+
6974
def test_get_access_url_calls_apply_unary_op_with_duration():
7075
s = MagicMock(spec=series.Series)
7176
duration = datetime.timedelta(hours=1)
@@ -79,6 +84,7 @@ def test_get_access_url_calls_apply_unary_op_with_duration():
7984
# 1 hour = 3600 seconds = 3600 * 1000 * 1000 microseconds
8085
assert args[0].duration == 3600000000
8186

87+
8288
def test_make_ref_calls_apply_binary_op_with_authorizer():
8389
uri = MagicMock(spec=series.Series)
8490
auth = MagicMock(spec=series.Series)
@@ -90,6 +96,7 @@ def test_make_ref_calls_apply_binary_op_with_authorizer():
9096
assert args[0] == auth
9197
assert args[1] == ops.obj_make_ref_op
9298

99+
93100
def test_make_ref_calls_apply_unary_op_without_authorizer():
94101
json_val = MagicMock(spec=series.Series)
95102

0 commit comments

Comments
 (0)