Skip to content

Commit e8d1263

Browse files
committed
fix import errors
1 parent 9f3a050 commit e8d1263

File tree

10 files changed

+168
-116
lines changed

10 files changed

+168
-116
lines changed

tests/unit/core/compile/sqlglot/expressions/test_array_ops.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,16 @@
1717
from bigframes import operations as ops
1818
from bigframes.operations._op_converters import convert_index, convert_slice
1919
import bigframes.pandas as bpd
20-
from tests.unit.core.compile.sqlglot.expressions.utils import _apply_unary_ops
20+
21+
from . import utils
2122

2223
pytest.importorskip("pytest_snapshot")
2324

2425

2526
def test_array_to_string(repeated_types_df: bpd.DataFrame, snapshot):
2627
col_name = "string_list_col"
2728
bf_df = repeated_types_df[[col_name]]
28-
sql = _apply_unary_ops(
29+
sql = utils._apply_unary_ops(
2930
bf_df, [ops.ArrayToStringOp(delimiter=".").as_expr(col_name)], [col_name]
3031
)
3132

@@ -35,15 +36,17 @@ def test_array_to_string(repeated_types_df: bpd.DataFrame, snapshot):
3536
def test_array_index(repeated_types_df: bpd.DataFrame, snapshot):
3637
col_name = "string_list_col"
3738
bf_df = repeated_types_df[[col_name]]
38-
sql = _apply_unary_ops(bf_df, [convert_index(1).as_expr(col_name)], [col_name])
39+
sql = utils._apply_unary_ops(
40+
bf_df, [convert_index(1).as_expr(col_name)], [col_name]
41+
)
3942

4043
snapshot.assert_match(sql, "out.sql")
4144

4245

4346
def test_array_slice_with_only_start(repeated_types_df: bpd.DataFrame, snapshot):
4447
col_name = "string_list_col"
4548
bf_df = repeated_types_df[[col_name]]
46-
sql = _apply_unary_ops(
49+
sql = utils._apply_unary_ops(
4750
bf_df, [convert_slice(slice(1, None)).as_expr(col_name)], [col_name]
4851
)
4952

@@ -53,7 +56,7 @@ def test_array_slice_with_only_start(repeated_types_df: bpd.DataFrame, snapshot)
5356
def test_array_slice_with_start_and_stop(repeated_types_df: bpd.DataFrame, snapshot):
5457
col_name = "string_list_col"
5558
bf_df = repeated_types_df[[col_name]]
56-
sql = _apply_unary_ops(
59+
sql = utils._apply_unary_ops(
5760
bf_df, [convert_slice(slice(1, 5)).as_expr(col_name)], [col_name]
5861
)
5962

tests/unit/core/compile/sqlglot/expressions/test_comparison_ops.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616

1717
from bigframes import operations as ops
1818
import bigframes.pandas as bpd
19-
from tests.unit.core.compile.sqlglot.expressions.utils import _apply_unary_ops
19+
20+
from . import utils
2021

2122
pytest.importorskip("pytest_snapshot")
2223

@@ -40,5 +41,5 @@ def test_is_in(scalar_types_df: bpd.DataFrame, snapshot):
4041
"float_in_ints": ops.IsInOp(values=(1, 2, 3, None)).as_expr(float_col),
4142
}
4243

43-
sql = _apply_unary_ops(bf_df, list(ops_map.values()), list(ops_map.keys()))
44+
sql = utils._apply_unary_ops(bf_df, list(ops_map.values()), list(ops_map.keys()))
4445
snapshot.assert_match(sql, "out.sql")

tests/unit/core/compile/sqlglot/expressions/test_datetime_ops.py

Lines changed: 42 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,103 +16,112 @@
1616

1717
from bigframes import operations as ops
1818
import bigframes.pandas as bpd
19-
from tests.unit.core.compile.sqlglot.expressions.utils import _apply_unary_ops
19+
20+
from . import utils
2021

2122
pytest.importorskip("pytest_snapshot")
2223

2324

2425
def test_date(scalar_types_df: bpd.DataFrame, snapshot):
2526
col_name = "timestamp_col"
2627
bf_df = scalar_types_df[[col_name]]
27-
sql = _apply_unary_ops(bf_df, [ops.date_op.as_expr(col_name)], [col_name])
28+
sql = utils._apply_unary_ops(bf_df, [ops.date_op.as_expr(col_name)], [col_name])
2829

2930
snapshot.assert_match(sql, "out.sql")
3031

3132

3233
def test_day(scalar_types_df: bpd.DataFrame, snapshot):
3334
col_name = "timestamp_col"
3435
bf_df = scalar_types_df[[col_name]]
35-
sql = _apply_unary_ops(bf_df, [ops.day_op.as_expr(col_name)], [col_name])
36+
sql = utils._apply_unary_ops(bf_df, [ops.day_op.as_expr(col_name)], [col_name])
3637

3738
snapshot.assert_match(sql, "out.sql")
3839

3940

4041
def test_dayofweek(scalar_types_df: bpd.DataFrame, snapshot):
4142
col_name = "timestamp_col"
4243
bf_df = scalar_types_df[[col_name]]
43-
sql = _apply_unary_ops(bf_df, [ops.dayofweek_op.as_expr(col_name)], [col_name])
44+
sql = utils._apply_unary_ops(
45+
bf_df, [ops.dayofweek_op.as_expr(col_name)], [col_name]
46+
)
4447

4548
snapshot.assert_match(sql, "out.sql")
4649

4750

4851
def test_dayofyear(scalar_types_df: bpd.DataFrame, snapshot):
4952
col_name = "timestamp_col"
5053
bf_df = scalar_types_df[[col_name]]
51-
sql = _apply_unary_ops(bf_df, [ops.dayofyear_op.as_expr(col_name)], [col_name])
54+
sql = utils._apply_unary_ops(
55+
bf_df, [ops.dayofyear_op.as_expr(col_name)], [col_name]
56+
)
5257

5358
snapshot.assert_match(sql, "out.sql")
5459

5560

5661
def test_floor_dt(scalar_types_df: bpd.DataFrame, snapshot):
5762
col_name = "timestamp_col"
5863
bf_df = scalar_types_df[[col_name]]
59-
sql = _apply_unary_ops(bf_df, [ops.FloorDtOp("D").as_expr(col_name)], [col_name])
64+
sql = utils._apply_unary_ops(
65+
bf_df, [ops.FloorDtOp("D").as_expr(col_name)], [col_name]
66+
)
6067

6168
snapshot.assert_match(sql, "out.sql")
6269

6370

6471
def test_hour(scalar_types_df: bpd.DataFrame, snapshot):
6572
col_name = "timestamp_col"
6673
bf_df = scalar_types_df[[col_name]]
67-
sql = _apply_unary_ops(bf_df, [ops.hour_op.as_expr(col_name)], [col_name])
74+
sql = utils._apply_unary_ops(bf_df, [ops.hour_op.as_expr(col_name)], [col_name])
6875

6976
snapshot.assert_match(sql, "out.sql")
7077

7178

7279
def test_minute(scalar_types_df: bpd.DataFrame, snapshot):
7380
col_name = "timestamp_col"
7481
bf_df = scalar_types_df[[col_name]]
75-
sql = _apply_unary_ops(bf_df, [ops.minute_op.as_expr(col_name)], [col_name])
82+
sql = utils._apply_unary_ops(bf_df, [ops.minute_op.as_expr(col_name)], [col_name])
7683

7784
snapshot.assert_match(sql, "out.sql")
7885

7986

8087
def test_month(scalar_types_df: bpd.DataFrame, snapshot):
8188
col_name = "timestamp_col"
8289
bf_df = scalar_types_df[[col_name]]
83-
sql = _apply_unary_ops(bf_df, [ops.month_op.as_expr(col_name)], [col_name])
90+
sql = utils._apply_unary_ops(bf_df, [ops.month_op.as_expr(col_name)], [col_name])
8491

8592
snapshot.assert_match(sql, "out.sql")
8693

8794

8895
def test_normalize(scalar_types_df: bpd.DataFrame, snapshot):
8996
col_name = "timestamp_col"
9097
bf_df = scalar_types_df[[col_name]]
91-
sql = _apply_unary_ops(bf_df, [ops.normalize_op.as_expr(col_name)], [col_name])
98+
sql = utils._apply_unary_ops(
99+
bf_df, [ops.normalize_op.as_expr(col_name)], [col_name]
100+
)
92101

93102
snapshot.assert_match(sql, "out.sql")
94103

95104

96105
def test_quarter(scalar_types_df: bpd.DataFrame, snapshot):
97106
col_name = "timestamp_col"
98107
bf_df = scalar_types_df[[col_name]]
99-
sql = _apply_unary_ops(bf_df, [ops.quarter_op.as_expr(col_name)], [col_name])
108+
sql = utils._apply_unary_ops(bf_df, [ops.quarter_op.as_expr(col_name)], [col_name])
100109

101110
snapshot.assert_match(sql, "out.sql")
102111

103112

104113
def test_second(scalar_types_df: bpd.DataFrame, snapshot):
105114
col_name = "timestamp_col"
106115
bf_df = scalar_types_df[[col_name]]
107-
sql = _apply_unary_ops(bf_df, [ops.second_op.as_expr(col_name)], [col_name])
116+
sql = utils._apply_unary_ops(bf_df, [ops.second_op.as_expr(col_name)], [col_name])
108117

109118
snapshot.assert_match(sql, "out.sql")
110119

111120

112121
def test_strftime(scalar_types_df: bpd.DataFrame, snapshot):
113122
col_name = "timestamp_col"
114123
bf_df = scalar_types_df[[col_name]]
115-
sql = _apply_unary_ops(
124+
sql = utils._apply_unary_ops(
116125
bf_df, [ops.StrftimeOp("%Y-%m-%d").as_expr(col_name)], [col_name]
117126
)
118127

@@ -122,78 +131,88 @@ def test_strftime(scalar_types_df: bpd.DataFrame, snapshot):
122131
def test_time(scalar_types_df: bpd.DataFrame, snapshot):
123132
col_name = "timestamp_col"
124133
bf_df = scalar_types_df[[col_name]]
125-
sql = _apply_unary_ops(bf_df, [ops.time_op.as_expr(col_name)], [col_name])
134+
sql = utils._apply_unary_ops(bf_df, [ops.time_op.as_expr(col_name)], [col_name])
126135

127136
snapshot.assert_match(sql, "out.sql")
128137

129138

130139
def test_to_datetime(scalar_types_df: bpd.DataFrame, snapshot):
131140
col_name = "int64_col"
132141
bf_df = scalar_types_df[[col_name]]
133-
sql = _apply_unary_ops(bf_df, [ops.ToDatetimeOp().as_expr(col_name)], [col_name])
142+
sql = utils._apply_unary_ops(
143+
bf_df, [ops.ToDatetimeOp().as_expr(col_name)], [col_name]
144+
)
134145

135146
snapshot.assert_match(sql, "out.sql")
136147

137148

138149
def test_to_timestamp(scalar_types_df: bpd.DataFrame, snapshot):
139150
col_name = "int64_col"
140151
bf_df = scalar_types_df[[col_name]]
141-
sql = _apply_unary_ops(bf_df, [ops.ToTimestampOp().as_expr(col_name)], [col_name])
152+
sql = utils._apply_unary_ops(
153+
bf_df, [ops.ToTimestampOp().as_expr(col_name)], [col_name]
154+
)
142155

143156
snapshot.assert_match(sql, "out.sql")
144157

145158

146159
def test_unix_micros(scalar_types_df: bpd.DataFrame, snapshot):
147160
col_name = "timestamp_col"
148161
bf_df = scalar_types_df[[col_name]]
149-
sql = _apply_unary_ops(bf_df, [ops.UnixMicros().as_expr(col_name)], [col_name])
162+
sql = utils._apply_unary_ops(
163+
bf_df, [ops.UnixMicros().as_expr(col_name)], [col_name]
164+
)
150165

151166
snapshot.assert_match(sql, "out.sql")
152167

153168

154169
def test_unix_millis(scalar_types_df: bpd.DataFrame, snapshot):
155170
col_name = "timestamp_col"
156171
bf_df = scalar_types_df[[col_name]]
157-
sql = _apply_unary_ops(bf_df, [ops.UnixMillis().as_expr(col_name)], [col_name])
172+
sql = utils._apply_unary_ops(
173+
bf_df, [ops.UnixMillis().as_expr(col_name)], [col_name]
174+
)
158175

159176
snapshot.assert_match(sql, "out.sql")
160177

161178

162179
def test_unix_seconds(scalar_types_df: bpd.DataFrame, snapshot):
163180
col_name = "timestamp_col"
164181
bf_df = scalar_types_df[[col_name]]
165-
sql = _apply_unary_ops(bf_df, [ops.UnixSeconds().as_expr(col_name)], [col_name])
182+
sql = utils._apply_unary_ops(
183+
bf_df, [ops.UnixSeconds().as_expr(col_name)], [col_name]
184+
)
166185

167186
snapshot.assert_match(sql, "out.sql")
168187

169188

170189
def test_year(scalar_types_df: bpd.DataFrame, snapshot):
171190
col_name = "timestamp_col"
172191
bf_df = scalar_types_df[[col_name]]
173-
sql = _apply_unary_ops(bf_df, [ops.year_op.as_expr(col_name)], [col_name])
192+
sql = utils._apply_unary_ops(bf_df, [ops.year_op.as_expr(col_name)], [col_name])
174193

175194
snapshot.assert_match(sql, "out.sql")
176195

177196

178197
def test_iso_day(scalar_types_df: bpd.DataFrame, snapshot):
179198
col_name = "timestamp_col"
180199
bf_df = scalar_types_df[[col_name]]
181-
sql = _apply_unary_ops(bf_df, [ops.iso_day_op.as_expr(col_name)], [col_name])
200+
sql = utils._apply_unary_ops(bf_df, [ops.iso_day_op.as_expr(col_name)], [col_name])
182201

183202
snapshot.assert_match(sql, "out.sql")
184203

185204

186205
def test_iso_week(scalar_types_df: bpd.DataFrame, snapshot):
187206
col_name = "timestamp_col"
188207
bf_df = scalar_types_df[[col_name]]
189-
sql = _apply_unary_ops(bf_df, [ops.iso_week_op.as_expr(col_name)], [col_name])
208+
sql = utils._apply_unary_ops(bf_df, [ops.iso_week_op.as_expr(col_name)], [col_name])
190209

191210
snapshot.assert_match(sql, "out.sql")
192211

193212

194213
def test_iso_year(scalar_types_df: bpd.DataFrame, snapshot):
195214
col_name = "timestamp_col"
196215
bf_df = scalar_types_df[[col_name]]
197-
sql = _apply_unary_ops(bf_df, [ops.iso_year_op.as_expr(col_name)], [col_name])
216+
sql = utils._apply_unary_ops(bf_df, [ops.iso_year_op.as_expr(col_name)], [col_name])
198217

199218
snapshot.assert_match(sql, "out.sql")

tests/unit/core/compile/sqlglot/expressions/test_generic_ops.py

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

1717
from bigframes import operations as ops
1818
import bigframes.pandas as bpd
19-
from tests.unit.core.compile.sqlglot.expressions.utils import _apply_unary_ops
19+
20+
from . import utils
2021

2122
pytest.importorskip("pytest_snapshot")
2223

2324

2425
def test_hash(scalar_types_df: bpd.DataFrame, snapshot):
2526
col_name = "string_col"
2627
bf_df = scalar_types_df[[col_name]]
27-
sql = _apply_unary_ops(bf_df, [ops.hash_op.as_expr(col_name)], [col_name])
28+
sql = utils._apply_unary_ops(bf_df, [ops.hash_op.as_expr(col_name)], [col_name])
2829

2930
snapshot.assert_match(sql, "out.sql")
3031

3132

3233
def test_isnull(scalar_types_df: bpd.DataFrame, snapshot):
3334
col_name = "float64_col"
3435
bf_df = scalar_types_df[[col_name]]
35-
sql = _apply_unary_ops(bf_df, [ops.isnull_op.as_expr(col_name)], [col_name])
36+
sql = utils._apply_unary_ops(bf_df, [ops.isnull_op.as_expr(col_name)], [col_name])
3637

3738
snapshot.assert_match(sql, "out.sql")
3839

3940

4041
def test_notnull(scalar_types_df: bpd.DataFrame, snapshot):
4142
col_name = "float64_col"
4243
bf_df = scalar_types_df[[col_name]]
43-
sql = _apply_unary_ops(bf_df, [ops.notnull_op.as_expr(col_name)], [col_name])
44+
sql = utils._apply_unary_ops(bf_df, [ops.notnull_op.as_expr(col_name)], [col_name])
4445

4546
snapshot.assert_match(sql, "out.sql")
4647

4748

4849
def test_map(scalar_types_df: bpd.DataFrame, snapshot):
4950
col_name = "string_col"
5051
bf_df = scalar_types_df[[col_name]]
51-
sql = _apply_unary_ops(
52+
sql = utils._apply_unary_ops(
5253
bf_df,
5354
[ops.MapOp(mappings=(("value1", "mapped1"),)).as_expr(col_name)],
5455
[col_name],

0 commit comments

Comments
 (0)