-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…le/read_html/read_xml
- Loading branch information
1 parent
5a0aca2
commit 60f6a33
Showing
10 changed files
with
524 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,9 @@ Input/Output | |
read_json | ||
read_parquet | ||
read_sas | ||
read_pickle | ||
read_html | ||
read_xml | ||
|
||
.. rubric:: SQL | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
386 changes: 384 additions & 2 deletions
386
src/snowflake/snowpark/modin/plugin/extensions/io_overrides.py
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# | ||
# Copyright (c) 2012-2024 Snowflake Computing Inc. All rights reserved. | ||
# | ||
import os | ||
import uuid | ||
|
||
import modin.pandas as pd | ||
import pandas as native_pd | ||
|
||
from tests.integ.modin.utils import assert_frame_equal | ||
from tests.integ.utils.sql_counter import SqlCounter | ||
|
||
|
||
def test_read_html(): | ||
html_str = """ | ||
<table> | ||
<tr> | ||
<th>A</th> | ||
<th colspan="1">B</th> | ||
<th rowspan="1">C</th> | ||
</tr> | ||
<tr> | ||
<td>a</td> | ||
<td>b</td> | ||
<td>c</td> | ||
</tr> | ||
</table> | ||
""" | ||
filename = f"test_read_html_{str(uuid.uuid4())}" | ||
|
||
with open(filename, "w") as f: | ||
f.write(html_str) | ||
|
||
try: | ||
with SqlCounter(query_count=1): | ||
assert_frame_equal( | ||
pd.read_html(filename)[0], | ||
native_pd.read_html(filename)[0], | ||
check_dtype=False, | ||
) | ||
finally: | ||
if os.path.exists(filename): | ||
os.remove(filename) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# | ||
# Copyright (c) 2012-2024 Snowflake Computing Inc. All rights reserved. | ||
# | ||
import os | ||
import uuid | ||
|
||
import modin.pandas as pd | ||
import pandas as native_pd | ||
|
||
from tests.integ.modin.utils import assert_frame_equal | ||
from tests.integ.utils.sql_counter import SqlCounter | ||
|
||
|
||
def test_read_pickle(): | ||
df = native_pd.DataFrame({"foo": range(5), "bar": range(5, 10)}) | ||
|
||
filename = f"test_read_pickle_{str(uuid.uuid4())}" | ||
try: | ||
native_pd.to_pickle(df, filename) | ||
with SqlCounter(query_count=1): | ||
assert_frame_equal( | ||
pd.read_pickle(filename), | ||
native_pd.read_pickle(filename), | ||
check_dtype=False, | ||
) | ||
finally: | ||
if os.path.exists(filename): | ||
os.remove(filename) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# | ||
# Copyright (c) 2012-2024 Snowflake Computing Inc. All rights reserved. | ||
# | ||
from io import StringIO | ||
|
||
import modin.pandas as pd | ||
import pandas as native_pd | ||
|
||
from tests.integ.modin.utils import assert_frame_equal | ||
from tests.integ.utils.sql_counter import SqlCounter | ||
|
||
|
||
def test_read_xml(): | ||
xml = """<?xml version='1.0' encoding='utf-8'?> | ||
<data xmlns="http://example.com"> | ||
<row> | ||
<shape>square</shape> | ||
<degrees>360</degrees> | ||
<sides>4.0</sides> | ||
</row> | ||
<row> | ||
<shape>circle</shape> | ||
<degrees>360</degrees> | ||
<sides/> | ||
</row> | ||
<row> | ||
<shape>triangle</shape> | ||
<degrees>180</degrees> | ||
<sides>3.0</sides> | ||
</row> | ||
</data> | ||
""" | ||
|
||
with SqlCounter(query_count=1): | ||
assert_frame_equal( | ||
pd.read_xml(StringIO(xml)), | ||
native_pd.read_xml(StringIO(xml)), | ||
check_dtype=False, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters