Test sql function with different engines.
(
sqlite_engine: sa.Engine, duckdb_connection: duckdb.DuckDBPyConnection
)
| 102 | |
| 103 | @pytest.mark.skipif(not HAS_SQLALCHEMY, reason="SQLAlchemy not installed") |
| 104 | def test_sql_with_different_engines( |
| 105 | sqlite_engine: sa.Engine, duckdb_connection: duckdb.DuckDBPyConnection |
| 106 | ) -> None: |
| 107 | """Test sql function with different engines.""" |
| 108 | import pandas as pd |
| 109 | import polars as pl |
| 110 | |
| 111 | # Test with SQLAlchemy engine |
| 112 | result = sql("SELECT * FROM test ORDER BY id", engine=sqlite_engine) |
| 113 | assert isinstance(result, (pd.DataFrame, pl.DataFrame)) |
| 114 | assert len(result) == 3 |
| 115 | |
| 116 | # Test with DuckDB connection |
| 117 | result = sql("SELECT * FROM test ORDER BY id", engine=duckdb_connection) |
| 118 | assert isinstance(result, (pd.DataFrame, pl.DataFrame)) |
| 119 | assert len(result) == 3 |
| 120 | |
| 121 | # Test with default DuckDB |
| 122 | # df = pd.DataFrame({"id": [1, 2], "name": ["Alice", "Bob"]}) |
| 123 | # with patch.dict(globals(), {"df": df}): |
| 124 | # result = sql("SELECT * FROM df") |
| 125 | # assert isinstance(result, (pd.DataFrame, pl.DataFrame)) |
| 126 | # assert len(result) == 2 |
| 127 | |
| 128 | |
| 129 | def test_sql_with_invalid_engine() -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…