-
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle unsupported column type with proper Exception and log
- Loading branch information
Showing
2 changed files
with
106 additions
and
7 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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!python3 | ||
|
||
import os | ||
import unittest | ||
import zipfile | ||
import urllib.request | ||
|
||
import pandas as pd | ||
import chdb | ||
|
||
|
||
class TestIssue251(unittest.TestCase): | ||
def setUp(self): | ||
# if /tmp/issue251/artifacts/create_final_community_reports.parquet not exists, | ||
# download https://github.com/user-attachments/files/16361689/parquet-test-data.zip | ||
# and unzip it to /tmp/issue251/ | ||
if not os.path.exists( | ||
"/tmp/issue251/artifacts/create_final_community_reports.parquet" | ||
): | ||
print("Downloading parquet-test-data.zip") | ||
|
||
url = "https://github.com/user-attachments/files/16361689/parquet-test-data.zip" | ||
os.makedirs("/tmp/issue251/", exist_ok=True) | ||
urllib.request.urlretrieve(url, "/tmp/issue251/parquet-test-data.zip") | ||
with zipfile.ZipFile("/tmp/issue251/parquet-test-data.zip", "r") as zip_ref: | ||
zip_ref.extractall("/tmp/issue251/") | ||
|
||
def test_issue251(self): | ||
df = pd.read_parquet( | ||
"/tmp/issue251/artifacts/create_final_community_reports.parquet", | ||
columns=[ | ||
"id", | ||
"community", | ||
"level", | ||
"title", | ||
"summary", | ||
"findings", | ||
"rank", | ||
"rank_explanation", | ||
], | ||
) | ||
|
||
# make pandas show all columns | ||
pd.set_option("display.max_columns", None) | ||
print(df.head(2)) | ||
print(df.dtypes) | ||
try: | ||
chdb.query("FROM Python(df) SELECT * LIMIT 10") | ||
except Exception as e: | ||
self.assertTrue( | ||
"Unsupported Python object type numpy.ndarray" in str(e) | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |