Skip to content

Commit 6c481b8

Browse files
authored
Merge branch 'main' into migrate-euclidean-dist
2 parents 23b769d + 0d7d7e4 commit 6c481b8

File tree

28 files changed

+313
-221
lines changed

28 files changed

+313
-221
lines changed

.github/workflows/docs-deploy.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Deploy docs to GitHub Pages
2+
3+
on:
4+
# Runs on pushes targeting the default branch
5+
# TODO(tswast): Update this to only be releases once we confirm it's working.
6+
push:
7+
branches: ["main"]
8+
9+
# Allows you to run this workflow manually from the Actions tab
10+
workflow_dispatch:
11+
12+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
13+
permissions:
14+
contents: read
15+
pages: write
16+
id-token: write
17+
18+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
19+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
20+
concurrency:
21+
group: "pages"
22+
cancel-in-progress: false
23+
24+
jobs:
25+
# Build job
26+
build:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v4
31+
- name: Setup Python
32+
uses: actions/setup-python@v5
33+
with:
34+
python-version: "3.13"
35+
- name: Install nox
36+
run: |
37+
python -m pip install --upgrade setuptools pip wheel
38+
python -m pip install nox
39+
- name: Run docs
40+
run: |
41+
nox -s docs
42+
- name: Upload artifact
43+
uses: actions/upload-pages-artifact@v3
44+
with:
45+
path: docs/_build/html/
46+
47+
# Deployment job
48+
deploy:
49+
environment:
50+
name: github-pages
51+
url: ${{ steps.deployment.outputs.page_url }}
52+
runs-on: ubuntu-latest
53+
needs: build
54+
steps:
55+
- name: Deploy to GitHub Pages
56+
id: deployment
57+
uses: actions/deploy-pages@v4

.github/workflows/docs.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ on:
22
pull_request:
33
branches:
44
- main
5+
push:
6+
branches:
7+
- main
58
name: docs
69
jobs:
710
docs:
@@ -12,7 +15,7 @@ jobs:
1215
- name: Setup Python
1316
uses: actions/setup-python@v5
1417
with:
15-
python-version: "3.10"
18+
python-version: "3.13"
1619
- name: Install nox
1720
run: |
1821
python -m pip install --upgrade setuptools pip wheel

.github/workflows/lint.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ on:
22
pull_request:
33
branches:
44
- main
5+
push:
6+
branches:
7+
- main
58
name: lint
69
jobs:
710
lint:

.github/workflows/mypy.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ on:
22
pull_request:
33
branches:
44
- main
5+
push:
6+
branches:
7+
- main
58
name: mypy
69
jobs:
710
mypy:

.github/workflows/unittest.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ on:
22
pull_request:
33
branches:
44
- main
5+
push:
6+
branches:
7+
- main
58
name: unittest
69
jobs:
710
unit:

README.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
:orphan:
2+
13
BigQuery DataFrames (BigFrames)
24
===============================
35

bigframes/core/compile/sqlglot/expressions/geo_ops.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import bigframes.core.compile.sqlglot.scalar_compiler as scalar_compiler
2222

2323
register_unary_op = scalar_compiler.scalar_op_compiler.register_unary_op
24+
register_binary_op = scalar_compiler.scalar_op_compiler.register_binary_op
2425

2526

2627
@register_unary_op(ops.geo_area_op)
@@ -108,3 +109,8 @@ def _(expr: TypedExpr) -> sge.Expression:
108109
@register_unary_op(ops.geo_y_op)
109110
def _(expr: TypedExpr) -> sge.Expression:
110111
return sge.func("SAFE.ST_Y", expr.expr)
112+
113+
114+
@register_binary_op(ops.geo_st_difference_op)
115+
def _(left: TypedExpr, right: TypedExpr) -> sge.Expression:
116+
return sge.func("ST_DIFFERENCE", left.expr, right.expr)

bigframes/core/compile/sqlglot/expressions/numeric_ops.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ def _(expr: TypedExpr) -> sge.Expression:
7777
return sge.func("ASINH", expr.expr)
7878

7979

80+
@register_binary_op(ops.arctan2_op)
81+
def _(left: TypedExpr, right: TypedExpr) -> sge.Expression:
82+
left_expr = _coerce_bool_to_int(left)
83+
right_expr = _coerce_bool_to_int(right)
84+
return sge.func("ATAN2", left_expr, right_expr)
85+
86+
8087
@register_unary_op(ops.arctan_op)
8188
def _(expr: TypedExpr) -> sge.Expression:
8289
return sge.func("ATAN", expr.expr)
@@ -118,6 +125,18 @@ def _(expr: TypedExpr) -> sge.Expression:
118125
)
119126

120127

128+
@register_binary_op(ops.cosine_distance_op)
129+
def _(left: TypedExpr, right: TypedExpr) -> sge.Expression:
130+
return sge.Anonymous(
131+
this="ML.DISTANCE",
132+
expressions=[
133+
left.expr,
134+
right.expr,
135+
sge.Literal.string("COSINE"),
136+
],
137+
)
138+
139+
121140
@register_unary_op(ops.exp_op)
122141
def _(expr: TypedExpr) -> sge.Expression:
123142
return sge.Case(

bigframes/core/local_data.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,16 @@ def _(
253253
value_generator = iter_array(
254254
array.flatten(), bigframes.dtypes.get_array_inner_type(dtype)
255255
)
256-
for (start, end) in _pairwise(array.offsets):
257-
arr_size = end.as_py() - start.as_py()
258-
yield list(itertools.islice(value_generator, arr_size))
256+
offset_generator = iter_array(array.offsets, bigframes.dtypes.INT_DTYPE)
257+
258+
start_offset = None
259+
end_offset = None
260+
for offset in offset_generator:
261+
start_offset = end_offset
262+
end_offset = offset
263+
if start_offset is not None:
264+
arr_size = end_offset - start_offset
265+
yield list(itertools.islice(value_generator, arr_size))
259266

260267
@iter_array.register
261268
def _(
@@ -267,8 +274,15 @@ def _(
267274
sub_generators[field_name] = iter_array(array.field(field_name), dtype)
268275

269276
keys = list(sub_generators.keys())
270-
for row_values in zip(*sub_generators.values()):
271-
yield {key: value for key, value in zip(keys, row_values)}
277+
is_null_generator = iter_array(array.is_null(), bigframes.dtypes.BOOL_DTYPE)
278+
279+
for values in zip(is_null_generator, *sub_generators.values()):
280+
is_row_null = values[0]
281+
row_values = values[1:]
282+
if not is_row_null:
283+
yield {key: value for key, value in zip(keys, row_values)}
284+
else:
285+
yield None
272286

273287
for batch in table.to_batches():
274288
sub_generators: dict[str, Generator[Any, None, None]] = {}
@@ -491,16 +505,3 @@ def _schema_durations_to_ints(schema: pa.Schema) -> pa.Schema:
491505
return pa.schema(
492506
pa.field(field.name, _durations_to_ints(field.type)) for field in schema
493507
)
494-
495-
496-
def _pairwise(iterable):
497-
do_yield = False
498-
a = None
499-
b = None
500-
for item in iterable:
501-
a = b
502-
b = item
503-
if do_yield:
504-
yield (a, b)
505-
else:
506-
do_yield = True

docs/conf.py

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@
2424
# All configuration values have a default; values that are commented out
2525
# serve to show the default.
2626

27+
from __future__ import annotations
28+
2729
import os
28-
import shlex
2930
import sys
31+
from typing import Any
3032

3133
# If extensions (or modules to document with autodoc) are in another directory,
3234
# add these directories to sys.path here. If the directory is relative to the
@@ -56,7 +58,7 @@
5658
"sphinx.ext.napoleon",
5759
"sphinx.ext.todo",
5860
"sphinx.ext.viewcode",
59-
"recommonmark",
61+
"myst_parser",
6062
]
6163

6264
# autodoc/autosummary flags
@@ -98,7 +100,7 @@
98100
#
99101
# This is also used if you do content translation via gettext catalogs.
100102
# Usually you set "language" from the command line for these cases.
101-
language = None
103+
language = "en-US"
102104

103105
# There are two options for replacing |today|: either, you set today to some
104106
# non-false value, then it is used:
@@ -148,19 +150,27 @@
148150

149151
# The theme to use for HTML and HTML Help pages. See the documentation for
150152
# a list of builtin themes.
151-
html_theme = "alabaster"
153+
html_theme = "pydata_sphinx_theme"
152154

153155
# Theme options are theme-specific and customize the look and feel of a theme
154156
# further. For a list of options available for each theme, see the
155157
# documentation.
158+
# https://pydata-sphinx-theme.readthedocs.io/en/stable/user_guide/layout.html#references
156159
html_theme_options = {
157-
"description": "BigQuery DataFrames provides DataFrame APIs on the BigQuery engine",
158-
"github_user": "googleapis",
159-
"github_repo": "python-bigquery-dataframes",
160-
"github_banner": True,
161-
"font_family": "'Roboto', Georgia, sans",
162-
"head_font_family": "'Roboto', Georgia, serif",
163-
"code_font_family": "'Roboto Mono', 'Consolas', monospace",
160+
"github_url": "https://github.com/googleapis/python-bigquery-dataframes",
161+
"logo": {
162+
"text": "BigQuery DataFrames (BigFrames)",
163+
},
164+
"external_links": [
165+
{
166+
"name": "Getting started",
167+
"url": "https://docs.cloud.google.com/bigquery/docs/dataframes-quickstart",
168+
},
169+
{
170+
"name": "User guide",
171+
"url": "https://docs.cloud.google.com/bigquery/docs/bigquery-dataframes-introduction",
172+
},
173+
],
164174
}
165175

166176
# Add any paths that contain custom themes here, relative to this directory.
@@ -264,7 +274,7 @@
264274

265275
# -- Options for LaTeX output ---------------------------------------------
266276

267-
latex_elements = {
277+
latex_elements: dict[str, Any] = {
268278
# The paper size ('letterpaper' or 'a4paper').
269279
#'papersize': 'letterpaper',
270280
# The font size ('10pt', '11pt' or '12pt').
@@ -282,7 +292,7 @@
282292
(
283293
root_doc,
284294
"bigframes.tex",
285-
"bigframes Documentation",
295+
"BigQuery DataFrames (BigFrames)",
286296
author,
287297
"manual",
288298
)
@@ -317,7 +327,7 @@
317327
(
318328
root_doc,
319329
"bigframes",
320-
"bigframes Documentation",
330+
"BigQuery DataFrames (BigFrames)",
321331
[author],
322332
1,
323333
)
@@ -336,7 +346,7 @@
336346
(
337347
root_doc,
338348
"bigframes",
339-
"bigframes Documentation",
349+
"BigQuery DataFrames (BigFrames)",
340350
author,
341351
"bigframes",
342352
"bigframes Library",

0 commit comments

Comments
 (0)