Skip to content

Commit

Permalink
Merge pull request #27 from cody-scott/polars-null-fix
Browse files Browse the repository at this point in the history
replace nulls for polars
  • Loading branch information
cody-scott authored Dec 17, 2024
2 parents 837565e + 9ccd077 commit 901c72e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions dagster_mssql_bcp_tests/bcp_pandas/test_io_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,8 @@ def my_asset(context):

data = pd.DataFrame(
{
"a": [1, 1],
"b": ["a\t\nb", "a\t\tb"],
"a": [1, 1, 1],
"b": ["a\t\nb", "a\t\tb", ""],
}
)

Expand All @@ -400,7 +400,7 @@ def my_asset(context):
with self.connect_mssql() as connection:
data = connection.exec_driver_sql(
f'SELECT * FROM {schema}.{table}')
assert data.fetchall() == [(1, 'a\t\nb'), (1, 'a\t\tb')]
assert data.fetchall() == [(1, 'a\t\nb'), (1, 'a\t\tb'), (1, None)]

def test_absent_identity(self):
schema = "test_pandas_bcp_schema"
Expand Down
8 changes: 4 additions & 4 deletions dagster_mssql_bcp_tests/bcp_polars/test_bcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,13 +276,13 @@ def test_replace_values(self, polars_io):
expected = pl.DataFrame(
{
"c": [
'',
'',
None,
None,
"c",
"abc__TAB__def",
"abc__TAB____NEWLINE__def",
"abc__NEWLINE__def",
'',
None,
"somenanthing",
],
"should_process_replacements": [0, 0, 0, 1, 1, 1, 0, 0],
Expand Down Expand Up @@ -337,7 +337,7 @@ def test_replace_values(self, polars_io):
[{"name": "a", "type": "NVARCHAR", "length": 20}]
)
df = pl.DataFrame({"a": ['""', "a", '', '"adsf"']})
expected = pl.DataFrame({"a": ['', "a", '', '"adsf"'], "should_process_replacements": [0,0,0,0]})
expected = pl.DataFrame({"a": [None, "a", None, '"adsf"'], "should_process_replacements": [0,0,0,0]})
df = polars_io._replace_values(df, schema)
pl_testing.assert_frame_equal(df, expected)

Expand Down
6 changes: 3 additions & 3 deletions dagster_mssql_bcp_tests/bcp_polars/test_io_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,8 @@ def my_asset(context):

data = pl.DataFrame(
{
"a": [1, 1],
"b": ["a\t\nb", "a\t\tb"],
"a": [1, 1, 1],
"b": ["a\t\nb", "a\t\tb", ""],
}
)

Expand All @@ -392,7 +392,7 @@ def my_asset(context):
)
with self.connect_mssql() as connection:
data = connection.exec_driver_sql(f'SELECT * FROM {schema}.{table}')
assert data.fetchall() == [(1, 'a\t\nb'), (1, 'a\t\tb')]
assert data.fetchall() == [(1, 'a\t\nb'), (1, 'a\t\tb'), (1, None)]

def test_absent_identity(self):
schema = "test_polars_bcp_schema"
Expand Down
2 changes: 1 addition & 1 deletion src/dagster_mssql_bcp/bcp_polars/polars_mssql_bcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def _replace_values(self, data: pl.LazyFrame, asset_schema: AssetSchema):
]
)

# data = data.with_columns(pl.col(pl.String).replace("", None))
data = data.with_columns(pl.col(pl.String).replace("", None))

return data

Expand Down

0 comments on commit 901c72e

Please sign in to comment.