Skip to content

Commit 533dd88

Browse files
committed
chore: add logging to bigframes.bigquery functions
1 parent 6370d3b commit 533dd88

File tree

8 files changed

+37
-3
lines changed

8 files changed

+37
-3
lines changed

bigframes/bigquery/_operations/approx_agg.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
from __future__ import annotations
1616

17+
from bigframes.core import log_adapter
1718
import bigframes.operations.aggregations as agg_ops
1819
import bigframes.series as series
1920

@@ -23,6 +24,7 @@
2324
"""
2425

2526

27+
@log_adapter.method_logger
2628
def approx_top_count(
2729
series: series.Series,
2830
number: int,

bigframes/bigquery/_operations/array.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import bigframes_vendored.constants as constants
2626

27+
from bigframes.core import log_adapter
2728
import bigframes.core.groupby as groupby
2829
import bigframes.operations as ops
2930
import bigframes.operations.aggregations as agg_ops
@@ -33,6 +34,7 @@
3334
import bigframes.dataframe as dataframe
3435

3536

37+
@log_adapter.method_logger
3638
def array_length(series: series.Series) -> series.Series:
3739
"""Compute the length of each array element in the Series.
3840
@@ -68,6 +70,7 @@ def array_length(series: series.Series) -> series.Series:
6870
return series._apply_unary_op(ops.len_op)
6971

7072

73+
@log_adapter.method_logger
7174
def array_agg(
7275
obj: groupby.SeriesGroupBy | groupby.DataFrameGroupBy,
7376
) -> series.Series | dataframe.DataFrame:
@@ -121,6 +124,7 @@ def array_agg(
121124
)
122125

123126

127+
@log_adapter.method_logger
124128
def array_to_string(series: series.Series, delimiter: str) -> series.Series:
125129
"""Converts array elements within a Series into delimited strings.
126130

bigframes/bigquery/_operations/datetime.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414

1515
from bigframes import operations as ops
1616
from bigframes import series
17+
from bigframes.core import log_adapter
1718

1819

20+
@log_adapter.method_logger
1921
def unix_seconds(input: series.Series) -> series.Series:
2022
"""Converts a timestmap series to unix epoch seconds
2123
@@ -43,6 +45,7 @@ def unix_seconds(input: series.Series) -> series.Series:
4345
return input._apply_unary_op(ops.UnixSeconds())
4446

4547

48+
@log_adapter.method_logger
4649
def unix_millis(input: series.Series) -> series.Series:
4750
"""Converts a timestmap series to unix epoch milliseconds
4851
@@ -70,6 +73,7 @@ def unix_millis(input: series.Series) -> series.Series:
7073
return input._apply_unary_op(ops.UnixMillis())
7174

7275

76+
@log_adapter.method_logger
7377
def unix_micros(input: series.Series) -> series.Series:
7478
"""Converts a timestmap series to unix epoch microseconds
7579

bigframes/bigquery/_operations/geo.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import shapely # type: ignore
2020

2121
from bigframes import operations as ops
22+
from bigframes.core import log_adapter
2223
import bigframes.geopandas
2324
import bigframes.series
2425

@@ -28,6 +29,7 @@
2829
"""
2930

3031

32+
@log_adapter.method_logger
3133
def st_area(
3234
series: Union[bigframes.series.Series, bigframes.geopandas.GeoSeries],
3335
) -> bigframes.series.Series:
@@ -103,6 +105,7 @@ def st_area(
103105
return series
104106

105107

108+
@log_adapter.method_logger
106109
def st_buffer(
107110
series: Union[bigframes.series.Series, bigframes.geopandas.GeoSeries],
108111
buffer_radius: float,
@@ -172,6 +175,7 @@ def st_buffer(
172175
return series
173176

174177

178+
@log_adapter.method_logger
175179
def st_centroid(
176180
series: Union[bigframes.series.Series, bigframes.geopandas.GeoSeries],
177181
) -> bigframes.series.Series:
@@ -229,6 +233,7 @@ def st_centroid(
229233
return series
230234

231235

236+
@log_adapter.method_logger
232237
def st_convexhull(
233238
series: Union[bigframes.series.Series, bigframes.geopandas.GeoSeries],
234239
) -> bigframes.series.Series:
@@ -284,6 +289,7 @@ def st_convexhull(
284289
return series
285290

286291

292+
@log_adapter.method_logger
287293
def st_difference(
288294
series: Union[bigframes.series.Series, bigframes.geopandas.GeoSeries],
289295
other: Union[
@@ -387,6 +393,7 @@ def st_difference(
387393
return series._apply_binary_op(other, ops.geo_st_difference_op)
388394

389395

396+
@log_adapter.method_logger
390397
def st_distance(
391398
series: Union[bigframes.series.Series, bigframes.geopandas.GeoSeries],
392399
other: Union[
@@ -464,6 +471,7 @@ def st_distance(
464471
)
465472

466473

474+
@log_adapter.method_logger
467475
def st_intersection(
468476
series: Union[bigframes.series.Series, bigframes.geopandas.GeoSeries],
469477
other: Union[
@@ -563,6 +571,7 @@ def st_intersection(
563571
return series._apply_binary_op(other, ops.geo_st_intersection_op)
564572

565573

574+
@log_adapter.method_logger
566575
def st_isclosed(
567576
series: Union[bigframes.series.Series, bigframes.geopandas.GeoSeries],
568577
) -> bigframes.series.Series:
@@ -623,6 +632,7 @@ def st_isclosed(
623632
return series
624633

625634

635+
@log_adapter.method_logger
626636
def st_length(
627637
series: Union[bigframes.series.Series, bigframes.geopandas.GeoSeries],
628638
*,

bigframes/bigquery/_operations/json.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from typing import Any, cast, Optional, Sequence, Tuple, Union
2525
import warnings
2626

27+
from bigframes.core import log_adapter
2728
import bigframes.core.utils as utils
2829
import bigframes.dtypes
2930
import bigframes.exceptions as bfe
@@ -33,6 +34,7 @@
3334
from . import array
3435

3536

37+
@log_adapter.method_logger
3638
@utils.preview(name="The JSON-related API `json_set`")
3739
def json_set(
3840
input: series.Series,
@@ -85,6 +87,7 @@ def json_set(
8587
return result
8688

8789

90+
@log_adapter.method_logger
8891
def json_extract(
8992
input: series.Series,
9093
json_path: str,
@@ -125,6 +128,7 @@ def json_extract(
125128
return input._apply_unary_op(ops.JSONExtract(json_path=json_path))
126129

127130

131+
@log_adapter.method_logger
128132
def json_extract_array(
129133
input: series.Series,
130134
json_path: str = "$",
@@ -184,6 +188,7 @@ def json_extract_array(
184188
return input._apply_unary_op(ops.JSONExtractArray(json_path=json_path))
185189

186190

191+
@log_adapter.method_logger
187192
def json_extract_string_array(
188193
input: series.Series,
189194
json_path: str = "$",
@@ -260,6 +265,7 @@ def json_extract_string_array(
260265
return array_series
261266

262267

268+
@log_adapter.method_logger
263269
def json_query(
264270
input: series.Series,
265271
json_path: str,
@@ -291,6 +297,7 @@ def json_query(
291297
return input._apply_unary_op(ops.JSONQuery(json_path=json_path))
292298

293299

300+
@log_adapter.method_logger
294301
def json_query_array(
295302
input: series.Series,
296303
json_path: str = "$",
@@ -341,6 +348,7 @@ def json_query_array(
341348
return input._apply_unary_op(ops.JSONQueryArray(json_path=json_path))
342349

343350

351+
@log_adapter.method_logger
344352
def json_value(
345353
input: series.Series,
346354
json_path: str = "$",
@@ -375,6 +383,7 @@ def json_value(
375383
return input._apply_unary_op(ops.JSONValue(json_path=json_path))
376384

377385

386+
@log_adapter.method_logger
378387
def json_value_array(
379388
input: series.Series,
380389
json_path: str = "$",
@@ -430,6 +439,7 @@ def json_value_array(
430439
return input._apply_unary_op(ops.JSONValueArray(json_path=json_path))
431440

432441

442+
@log_adapter.method_logger
433443
@utils.preview(name="The JSON-related API `parse_json`")
434444
def parse_json(
435445
input: series.Series,

bigframes/bigquery/_operations/search.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
import google.cloud.bigquery as bigquery
2222

23-
import bigframes.core.sql
23+
from bigframes.core import log_adapter
2424
import bigframes.ml.utils as utils
2525

2626
if typing.TYPE_CHECKING:
@@ -34,6 +34,7 @@
3434
"""
3535

3636

37+
@log_adapter.method_logger
3738
def create_vector_index(
3839
table_id: str,
3940
column_name: str,
@@ -89,6 +90,7 @@ def create_vector_index(
8990
read_gbq_query(sql)
9091

9192

93+
@log_adapter.method_logger
9294
def vector_search(
9395
base_table: str,
9496
column_to_search: str,

bigframes/bigquery/_operations/sql.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020

2121
import google.cloud.bigquery
2222

23+
from bigframes.core import log_adapter
2324
import bigframes.core.compile.sqlglot.sqlglot_ir as sqlglot_ir
24-
import bigframes.core.sql
25-
import bigframes.dataframe
2625
import bigframes.dtypes
2726
import bigframes.operations
2827
import bigframes.series
2928

3029

30+
@log_adapter.method_logger
3131
def sql_scalar(
3232
sql_template: str,
3333
columns: Sequence[bigframes.series.Series],

bigframes/bigquery/_operations/struct.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@
2222

2323
import typing
2424

25+
from bigframes.core import log_adapter
2526
import bigframes.operations as ops
2627
import bigframes.series as series
2728

2829
if typing.TYPE_CHECKING:
2930
import bigframes.dataframe as dataframe
3031

3132

33+
@log_adapter.method_logger
3234
def struct(value: dataframe.DataFrame) -> series.Series:
3335
"""Takes a DataFrame and converts it into a Series of structs with each
3436
struct entry corresponding to a DataFrame row and each struct field

0 commit comments

Comments
 (0)