Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions tests/unit/core/compile/sqlglot/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ def _create_compiler_session(table_name, table_schema):


@pytest.fixture(scope="session")
def compiler_session(scalars_types_table_schema):
def compiler_session(scalar_types_table_schema):
"""Compiler session for scalar types."""
return _create_compiler_session("scalar_types", scalars_types_table_schema)
return _create_compiler_session("scalar_types", scalar_types_table_schema)


@pytest.fixture(scope="session")
Expand All @@ -72,7 +72,7 @@ def compiler_session_w_json_types(json_types_table_schema):


@pytest.fixture(scope="session")
def scalars_types_table_schema() -> typing.Sequence[bigquery.SchemaField]:
def scalar_types_table_schema() -> typing.Sequence[bigquery.SchemaField]:
return [
bigquery.SchemaField("bool_col", "BOOLEAN"),
bigquery.SchemaField("bytes_col", "BYTES"),
Expand All @@ -92,7 +92,7 @@ def scalars_types_table_schema() -> typing.Sequence[bigquery.SchemaField]:


@pytest.fixture(scope="session")
def scalars_types_df(compiler_session) -> bpd.DataFrame:
def scalar_types_df(compiler_session) -> bpd.DataFrame:
"""Returns a BigFrames DataFrame containing all scalar types and using the `rowindex`
column as the index."""
bf_df = compiler_session.read_gbq_table("bigframes-dev.sqlglot_test.scalar_types")
Expand All @@ -101,7 +101,7 @@ def scalars_types_df(compiler_session) -> bpd.DataFrame:


@pytest.fixture(scope="session")
def scalars_types_pandas_df() -> pd.DataFrame:
def scalar_types_pandas_df() -> pd.DataFrame:
"""Returns a pandas DataFrame containing all scalar types and using the `rowindex`
column as the index."""
# TODO: add tests for empty dataframes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,24 @@
pytest.importorskip("pytest_snapshot")


def test_add_numeric(scalars_types_df: bpd.DataFrame, snapshot):
bf_df = scalars_types_df[["int64_col"]]
def test_add_numeric(scalar_types_df: bpd.DataFrame, snapshot):
bf_df = scalar_types_df[["int64_col"]]

bf_df["int64_col"] = bf_df["int64_col"] + bf_df["int64_col"]

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


def test_add_numeric_w_scalar(scalars_types_df: bpd.DataFrame, snapshot):
bf_df = scalars_types_df[["int64_col"]]
def test_add_numeric_w_scalar(scalar_types_df: bpd.DataFrame, snapshot):
bf_df = scalar_types_df[["int64_col"]]

bf_df["int64_col"] = bf_df["int64_col"] + 1

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


def test_add_string(scalars_types_df: bpd.DataFrame, snapshot):
bf_df = scalars_types_df[["string_col"]]
def test_add_string(scalar_types_df: bpd.DataFrame, snapshot):
bf_df = scalar_types_df[["string_col"]]

bf_df["string_col"] = bf_df["string_col"] + "a"

Expand Down
4 changes: 2 additions & 2 deletions tests/unit/core/compile/sqlglot/test_compile_concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@


def test_compile_concat(
scalars_types_pandas_df: pd.DataFrame, compiler_session: bigframes.Session, snapshot
scalar_types_pandas_df: pd.DataFrame, compiler_session: bigframes.Session, snapshot
):
# TODO: concat two same dataframes, which SQL does not get reused.
# TODO: concat dataframes from a gbq table but trigger a windows compiler.
df1 = bpd.DataFrame(scalars_types_pandas_df, session=compiler_session)
df1 = bpd.DataFrame(scalar_types_pandas_df, session=compiler_session)
df1 = df1[["rowindex", "int64_col", "string_col"]]
concat_df = bpd.concat([df1, df1])
snapshot.assert_match(concat_df.sql, "out.sql")
4 changes: 2 additions & 2 deletions tests/unit/core/compile/sqlglot/test_compile_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
pytest.importorskip("pytest_snapshot")


def test_compile_filter(scalars_types_df: bpd.DataFrame, snapshot):
bf_df = scalars_types_df[["rowindex", "int64_col"]]
def test_compile_filter(scalar_types_df: bpd.DataFrame, snapshot):
bf_df = scalar_types_df[["rowindex", "int64_col"]]
bf_filter = bf_df[bf_df["rowindex"] >= 1]
snapshot.assert_match(bf_filter.sql, "out.sql")
4 changes: 2 additions & 2 deletions tests/unit/core/compile/sqlglot/test_compile_readlocal.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@


def test_compile_readlocal(
scalars_types_pandas_df: pd.DataFrame, compiler_session: bigframes.Session, snapshot
scalar_types_pandas_df: pd.DataFrame, compiler_session: bigframes.Session, snapshot
):
bf_df = bpd.DataFrame(scalars_types_pandas_df, session=compiler_session)
bf_df = bpd.DataFrame(scalar_types_pandas_df, session=compiler_session)
snapshot.assert_match(bf_df.sql, "out.sql")


Expand Down
12 changes: 6 additions & 6 deletions tests/unit/core/compile/sqlglot/test_compile_readtable.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
pytest.importorskip("pytest_snapshot")


def test_compile_readtable(scalars_types_df: bpd.DataFrame, snapshot):
snapshot.assert_match(scalars_types_df.sql, "out.sql")
def test_compile_readtable(scalar_types_df: bpd.DataFrame, snapshot):
snapshot.assert_match(scalar_types_df.sql, "out.sql")


def test_compile_readtable_w_repeated_types(repeated_types_df: bpd.DataFrame, snapshot):
Expand All @@ -37,13 +37,13 @@ def test_compile_readtable_w_json_types(json_types_df: bpd.DataFrame, snapshot):
snapshot.assert_match(json_types_df.sql, "out.sql")


def test_compile_readtable_w_ordering(scalars_types_df: bpd.DataFrame, snapshot):
bf_df = scalars_types_df[["int64_col"]]
def test_compile_readtable_w_ordering(scalar_types_df: bpd.DataFrame, snapshot):
bf_df = scalar_types_df[["int64_col"]]
bf_df = bf_df.sort_values("int64_col")
snapshot.assert_match(bf_df.sql, "out.sql")


def test_compile_readtable_w_limit(scalars_types_df: bpd.DataFrame, snapshot):
bf_df = scalars_types_df[["int64_col"]]
def test_compile_readtable_w_limit(scalar_types_df: bpd.DataFrame, snapshot):
bf_df = scalar_types_df[["int64_col"]]
bf_df = bf_df.sort_index().head(10)
snapshot.assert_match(bf_df.sql, "out.sql")