This repository was archived by the owner on May 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 288
Fix motherduck bug (#858) #861
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
a3dbbf2
quick debug logs
8b31425
fix the override method
887cd5b
remove submods
ca375ad
remove prints
e36a778
remove submods
a21feac
revert change
979f5ec
Refactor dynamic database clause in DuckDB.py
b1d05b2
draft tests
c09f9cf
Add validation for input path in select_table_schema method
83f674b
style fixes by ruff
sungchun12 0f491b2
Revert "Add validation for input path in select_table_schema method"
5711dcb
Merge branch 'fix-motherduck-bug' of https://github.com/datafold/data…
c4e5041
Remove unnecessary code in test_duckdb.py
30894a7
Merge branch 'master' into fix-motherduck-bug
sungchun12 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,42 @@ | ||
import unittest | ||
from data_diff.databases import duckdb as duckdb_differ | ||
import os | ||
import uuid | ||
|
||
test_duckdb_filepath = str(uuid.uuid4()) + ".duckdb" | ||
|
||
|
||
class TestDuckDBTableSchemaMethods(unittest.TestCase): | ||
def setUp(self): | ||
# Create a new duckdb file | ||
self.duckdb_conn = duckdb_differ.DuckDB(filepath=test_duckdb_filepath) | ||
|
||
def tearDown(self): | ||
# Optional: delete file after tests | ||
os.remove(test_duckdb_filepath) | ||
|
||
def test_normalize_table_path(self): | ||
self.assertEqual(self.duckdb_conn._normalize_table_path(("test_table",)), (None, "main", "test_table")) | ||
self.assertEqual( | ||
self.duckdb_conn._normalize_table_path(("test_schema", "test_table")), (None, "test_schema", "test_table") | ||
) | ||
self.assertEqual( | ||
self.duckdb_conn._normalize_table_path(("test_database", "test_schema", "test_table")), | ||
("test_database", "test_schema", "test_table"), | ||
) | ||
|
||
with self.assertRaises(ValueError): | ||
self.duckdb_conn._normalize_table_path(("test_database", "test_schema", "test_table", "extra")) | ||
|
||
def test_select_table_schema(self): | ||
db_path = ("test_table",) | ||
expected_sql = "SELECT column_name, data_type, datetime_precision, numeric_precision, numeric_scale FROM information_schema.columns WHERE table_name = 'test_table' AND table_schema = 'main' and table_catalog = current_catalog()" | ||
self.assertEqual(self.duckdb_conn.select_table_schema(db_path), expected_sql) | ||
|
||
db_path = ("custom_schema", "test_table") | ||
expected_sql = "SELECT column_name, data_type, datetime_precision, numeric_precision, numeric_scale FROM information_schema.columns WHERE table_name = 'test_table' AND table_schema = 'custom_schema' and table_catalog = current_catalog()" | ||
self.assertEqual(self.duckdb_conn.select_table_schema(db_path), expected_sql) | ||
|
||
db_path = ("custom_db", "custom_schema", "test_table") | ||
expected_sql = "SELECT column_name, data_type, datetime_precision, numeric_precision, numeric_scale FROM custom_db.information_schema.columns WHERE table_name = 'test_table' AND table_schema = 'custom_schema' and table_catalog = 'custom_db'" | ||
self.assertEqual(self.duckdb_conn.select_table_schema(db_path), expected_sql) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.