diff --git a/CHANGELOG.md b/CHANGELOG.md index c6add45..157eceb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,6 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - ## [Unreleased] ### Added @@ -17,6 +16,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +## [0.5.4] +**Full Changelog**: https://github.com/DeepLcom/sql-mock/compare/v0.5.3...v0.5.4 + +### Added + +### Changed + +* Clickhouse: Remove numpy dependency + +### Fixed + ## [0.5.3] **Full Changelog**: https://github.com/DeepLcom/sql-mock/compare/v0.5.2...v0.5.3 @@ -114,7 +124,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [0.1.2] - 2023-10-26 Initial version. -[Unreleased]: https://github.com/DeepLcom/sql-mock/compare/v0.5.3...HEAD +[Unreleased]: https://github.com/DeepLcom/sql-mock/compare/v0.5.4...HEAD +[0.5.4]: https://github.com/DeepLcom/sql-mock/releases/tag/v0.5.4 [0.5.3]: https://github.com/DeepLcom/sql-mock/releases/tag/v0.5.3 [0.5.2]: https://github.com/DeepLcom/sql-mock/releases/tag/v0.5.2 [0.5.1]: https://github.com/DeepLcom/sql-mock/releases/tag/v0.5.1 diff --git a/poetry.lock b/poetry.lock index fcbbe02..316556c 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1233,51 +1233,6 @@ files = [ [package.dependencies] setuptools = "*" -[[package]] -name = "numpy" -version = "1.26.3" -description = "Fundamental package for array computing in Python" -optional = true -python-versions = ">=3.9" -files = [ - {file = "numpy-1.26.3-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:806dd64230dbbfaca8a27faa64e2f414bf1c6622ab78cc4264f7f5f028fee3bf"}, - {file = "numpy-1.26.3-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:02f98011ba4ab17f46f80f7f8f1c291ee7d855fcef0a5a98db80767a468c85cd"}, - {file = "numpy-1.26.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6d45b3ec2faed4baca41c76617fcdcfa4f684ff7a151ce6fc78ad3b6e85af0a6"}, - {file = "numpy-1.26.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bdd2b45bf079d9ad90377048e2747a0c82351989a2165821f0c96831b4a2a54b"}, - {file = "numpy-1.26.3-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:211ddd1e94817ed2d175b60b6374120244a4dd2287f4ece45d49228b4d529178"}, - {file = "numpy-1.26.3-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:b1240f767f69d7c4c8a29adde2310b871153df9b26b5cb2b54a561ac85146485"}, - {file = "numpy-1.26.3-cp310-cp310-win32.whl", hash = "sha256:21a9484e75ad018974a2fdaa216524d64ed4212e418e0a551a2d83403b0531d3"}, - {file = "numpy-1.26.3-cp310-cp310-win_amd64.whl", hash = "sha256:9e1591f6ae98bcfac2a4bbf9221c0b92ab49762228f38287f6eeb5f3f55905ce"}, - {file = "numpy-1.26.3-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:b831295e5472954104ecb46cd98c08b98b49c69fdb7040483aff799a755a7374"}, - {file = "numpy-1.26.3-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:9e87562b91f68dd8b1c39149d0323b42e0082db7ddb8e934ab4c292094d575d6"}, - {file = "numpy-1.26.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8c66d6fec467e8c0f975818c1796d25c53521124b7cfb760114be0abad53a0a2"}, - {file = "numpy-1.26.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f25e2811a9c932e43943a2615e65fc487a0b6b49218899e62e426e7f0a57eeda"}, - {file = "numpy-1.26.3-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:af36e0aa45e25c9f57bf684b1175e59ea05d9a7d3e8e87b7ae1a1da246f2767e"}, - {file = "numpy-1.26.3-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:51c7f1b344f302067b02e0f5b5d2daa9ed4a721cf49f070280ac202738ea7f00"}, - {file = "numpy-1.26.3-cp311-cp311-win32.whl", hash = "sha256:7ca4f24341df071877849eb2034948459ce3a07915c2734f1abb4018d9c49d7b"}, - {file = "numpy-1.26.3-cp311-cp311-win_amd64.whl", hash = "sha256:39763aee6dfdd4878032361b30b2b12593fb445ddb66bbac802e2113eb8a6ac4"}, - {file = "numpy-1.26.3-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:a7081fd19a6d573e1a05e600c82a1c421011db7935ed0d5c483e9dd96b99cf13"}, - {file = "numpy-1.26.3-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:12c70ac274b32bc00c7f61b515126c9205323703abb99cd41836e8125ea0043e"}, - {file = "numpy-1.26.3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7f784e13e598e9594750b2ef6729bcd5a47f6cfe4a12cca13def35e06d8163e3"}, - {file = "numpy-1.26.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5f24750ef94d56ce6e33e4019a8a4d68cfdb1ef661a52cdaee628a56d2437419"}, - {file = "numpy-1.26.3-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:77810ef29e0fb1d289d225cabb9ee6cf4d11978a00bb99f7f8ec2132a84e0166"}, - {file = "numpy-1.26.3-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8ed07a90f5450d99dad60d3799f9c03c6566709bd53b497eb9ccad9a55867f36"}, - {file = "numpy-1.26.3-cp312-cp312-win32.whl", hash = "sha256:f73497e8c38295aaa4741bdfa4fda1a5aedda5473074369eca10626835445511"}, - {file = "numpy-1.26.3-cp312-cp312-win_amd64.whl", hash = "sha256:da4b0c6c699a0ad73c810736303f7fbae483bcb012e38d7eb06a5e3b432c981b"}, - {file = "numpy-1.26.3-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:1666f634cb3c80ccbd77ec97bc17337718f56d6658acf5d3b906ca03e90ce87f"}, - {file = "numpy-1.26.3-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:18c3319a7d39b2c6a9e3bb75aab2304ab79a811ac0168a671a62e6346c29b03f"}, - {file = "numpy-1.26.3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0b7e807d6888da0db6e7e75838444d62495e2b588b99e90dd80c3459594e857b"}, - {file = "numpy-1.26.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b4d362e17bcb0011738c2d83e0a65ea8ce627057b2fdda37678f4374a382a137"}, - {file = "numpy-1.26.3-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:b8c275f0ae90069496068c714387b4a0eba5d531aace269559ff2b43655edd58"}, - {file = "numpy-1.26.3-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:cc0743f0302b94f397a4a65a660d4cd24267439eb16493fb3caad2e4389bccbb"}, - {file = "numpy-1.26.3-cp39-cp39-win32.whl", hash = "sha256:9bc6d1a7f8cedd519c4b7b1156d98e051b726bf160715b769106661d567b3f03"}, - {file = "numpy-1.26.3-cp39-cp39-win_amd64.whl", hash = "sha256:867e3644e208c8922a3be26fc6bbf112a035f50f0a86497f98f228c50c607bb2"}, - {file = "numpy-1.26.3-pp39-pypy39_pp73-macosx_10_9_x86_64.whl", hash = "sha256:3c67423b3703f8fbd90f5adaa37f85b5794d3366948efe9a5190a5f3a83fc34e"}, - {file = "numpy-1.26.3-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:46f47ee566d98849323f01b349d58f2557f02167ee301e5e28809a8c0e27a2d0"}, - {file = "numpy-1.26.3-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:a8474703bffc65ca15853d5fd4d06b18138ae90c17c8d12169968e998e448bb5"}, - {file = "numpy-1.26.3.tar.gz", hash = "sha256:697df43e2b6310ecc9d95f05d5ef20eacc09c7c4ecc9da3f235d39e71b7da1e4"}, -] - [[package]] name = "packaging" version = "23.2" @@ -2323,11 +2278,11 @@ cffi = ["cffi (>=1.11)"] [extras] bigquery = ["google-cloud-bigquery"] -clickhouse = ["clickhouse-connect", "numpy"] +clickhouse = ["clickhouse-connect"] redshift = ["boto3", "redshift-connector"] snowflake = ["snowflake-connector-python"] [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "3265f3748db0a7a4d3c5c6115832427f5578b091fe90dce604e66929766357d6" +content-hash = "088fa7cd113e3ae8fa9eb8e67d02aa26aea6d7db5234f99b2614313d1df59573" diff --git a/pyproject.toml b/pyproject.toml index 55a1e84..34d3900 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [tool.poetry] name = "sql-mock" -version = "0.5.3" +version = "0.5.4" description = "Simplify the testing of SQL data models and queries by allowing users to mock input data and create tests for various scenarios. It provides a consistent and convenient way to test the execution of your query without the need to process a massive amount of data." repository = "https://github.com/DeepLcom/sql-mock" readme = "README.md" @@ -44,7 +44,6 @@ sqlglot = "^20.5.0" # Clickhouse specific clickhouse-connect = {version = "^0.7.0", optional = true} -numpy = {version = "^1.26.3", optional = true} # Google Bigquery specific google-cloud-bigquery = {version ="^3.11.4", optional = true} @@ -58,7 +57,7 @@ snowflake-connector-python = "^3.6.0" [tool.poetry.extras] bigquery = ["google-cloud-bigquery"] -clickhouse = ["clickhouse-connect", "numpy"] +clickhouse = ["clickhouse-connect"] redshift = ["redshift-connector", "boto3"] snowflake = ["snowflake-connector-python"] diff --git a/src/sql_mock/clickhouse/table_mocks.py b/src/sql_mock/clickhouse/table_mocks.py index 29888a5..396e07c 100644 --- a/src/sql_mock/clickhouse/table_mocks.py +++ b/src/sql_mock/clickhouse/table_mocks.py @@ -23,5 +23,5 @@ def _get_results(self, query: str) -> list[dict]: password=self.settings.password, port=self.settings.port, ) as client: - res = client.query_df(query) - return res.to_dict("records") + res = client.query(query, use_none=True) + return [dict(zip(res.column_names, row)) for row in res.result_rows] diff --git a/tests/sql_mock/clickhouse/test_table_mocks.py b/tests/sql_mock/clickhouse/test_table_mocks.py index d4623b5..c750be7 100644 --- a/tests/sql_mock/clickhouse/test_table_mocks.py +++ b/tests/sql_mock/clickhouse/test_table_mocks.py @@ -59,12 +59,13 @@ def test_get_results(mocker): mock_query_result = [{"column1": "value1", "column2": 42}] query = "SELECT 1, 2" - mock_dataframe = mocker.MagicMock() - mock_dataframe.to_dict.return_value = mock_query_result - mock_client.return_value.__enter__.return_value.query_df.return_value = mock_dataframe + mock_result = mocker.MagicMock() + mock_result.result_rows = [("value1", 42)] + mock_result.column_names = ("column1", "column2") + mock_client.return_value.__enter__.return_value.query.return_value = mock_result instance = ClickHouseTableMock() result = instance._get_results(query=query) assert result == mock_query_result - mock_client.return_value.__enter__.return_value.query_df.assert_called_once_with(query) + mock_client.return_value.__enter__.return_value.query.assert_called_once_with(query)