Skip to content

Commit 84fd8fa

Browse files
committed
generates literal from None
1 parent 59a719a commit 84fd8fa

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

bigframes/bigquery/_operations/sql.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def sql_scalar(
7474
# template, then this will fail with an error earlier in the process,
7575
# aiding users in debugging.
7676
literals_sql = [
77-
sqlglot_ir._literal(column.values[0], column.dtype).sql(dialect="bigquery")
77+
sqlglot_ir._literal(None, column.dtype).sql(dialect="bigquery")
7878
for column in columns
7979
]
8080
select_sql = sql_template.format(*literals_sql)

tests/system/small/bigquery/test_sql.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import pytest
1516
import pandas as pd
1617
import pyarrow as pa
1718

@@ -55,10 +56,26 @@ def test_sql_scalar_on_scalars_null_index(scalars_df_null_index):
5556
assert len(result) == len(scalars_df_null_index)
5657

5758

58-
def test_sql_scalar_w_bool_series(scalars_df_index):
59-
series: bpd.Series = scalars_df_index["bool_col"]
60-
result = bbq.sql_scalar("CAST({0} AS INT64)", [series])
61-
expected = series.astype(dtypes.INT_DTYPE)
59+
@pytest.mark.parametrize(
60+
("column_name"),
61+
[
62+
pytest.param("bool_col"),
63+
pytest.param("bytes_col"),
64+
pytest.param("date_col"),
65+
pytest.param("datetime_col"),
66+
pytest.param("geography_col"),
67+
pytest.param("int64_col"),
68+
pytest.param("numeric_col"),
69+
pytest.param("float64_col"),
70+
pytest.param("string_col"),
71+
pytest.param("time_col"),
72+
pytest.param("timestamp_col"),
73+
],
74+
)
75+
def test_sql_scalar_w_all_scalar_output(scalars_df_index, column_name):
76+
series: bpd.Series = scalars_df_index[column_name]
77+
result = bbq.sql_scalar("{0}", [series])
78+
expected = series
6279
expected.name = None
6380
pd.testing.assert_series_equal(result.to_pandas(), expected.to_pandas())
6481

0 commit comments

Comments
 (0)