sql-testing-library 0.15.0__tar.gz → 0.17.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. {sql_testing_library-0.15.0 → sql_testing_library-0.17.0}/CHANGELOG.md +22 -0
  2. {sql_testing_library-0.15.0 → sql_testing_library-0.17.0}/PKG-INFO +6 -3
  3. {sql_testing_library-0.15.0 → sql_testing_library-0.17.0}/README.md +1 -0
  4. {sql_testing_library-0.15.0 → sql_testing_library-0.17.0}/pyproject.toml +4 -4
  5. {sql_testing_library-0.15.0 → sql_testing_library-0.17.0}/src/sql_testing_library/_adapters/athena.py +11 -2
  6. {sql_testing_library-0.15.0 → sql_testing_library-0.17.0}/src/sql_testing_library/_pytest_plugin.py +2 -0
  7. {sql_testing_library-0.15.0 → sql_testing_library-0.17.0}/src/sql_testing_library/_sql_utils.py +11 -6
  8. {sql_testing_library-0.15.0 → sql_testing_library-0.17.0}/LICENSE +0 -0
  9. {sql_testing_library-0.15.0 → sql_testing_library-0.17.0}/src/sql_testing_library/__init__.py +0 -0
  10. {sql_testing_library-0.15.0 → sql_testing_library-0.17.0}/src/sql_testing_library/_adapters/__init__.py +0 -0
  11. {sql_testing_library-0.15.0 → sql_testing_library-0.17.0}/src/sql_testing_library/_adapters/base.py +0 -0
  12. {sql_testing_library-0.15.0 → sql_testing_library-0.17.0}/src/sql_testing_library/_adapters/bigquery.py +0 -0
  13. {sql_testing_library-0.15.0 → sql_testing_library-0.17.0}/src/sql_testing_library/_adapters/duckdb.py +0 -0
  14. {sql_testing_library-0.15.0 → sql_testing_library-0.17.0}/src/sql_testing_library/_adapters/presto.py +0 -0
  15. {sql_testing_library-0.15.0 → sql_testing_library-0.17.0}/src/sql_testing_library/_adapters/redshift.py +0 -0
  16. {sql_testing_library-0.15.0 → sql_testing_library-0.17.0}/src/sql_testing_library/_adapters/snowflake.py +0 -0
  17. {sql_testing_library-0.15.0 → sql_testing_library-0.17.0}/src/sql_testing_library/_adapters/trino.py +0 -0
  18. {sql_testing_library-0.15.0 → sql_testing_library-0.17.0}/src/sql_testing_library/_core.py +0 -0
  19. {sql_testing_library-0.15.0 → sql_testing_library-0.17.0}/src/sql_testing_library/_exceptions.py +0 -0
  20. {sql_testing_library-0.15.0 → sql_testing_library-0.17.0}/src/sql_testing_library/_mock_table.py +0 -0
  21. {sql_testing_library-0.15.0 → sql_testing_library-0.17.0}/src/sql_testing_library/_sql_logger.py +0 -0
  22. {sql_testing_library-0.15.0 → sql_testing_library-0.17.0}/src/sql_testing_library/_types.py +0 -0
  23. {sql_testing_library-0.15.0 → sql_testing_library-0.17.0}/src/sql_testing_library/py.typed +0 -0
@@ -5,6 +5,28 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## 0.17.0 (2025-11-20)
9
+
10
+ ### Feat
11
+
12
+ - **athena**: add option to specify workgroup (#127)
13
+ - add CI code quality checks for all PRs (#129)
14
+
15
+ ### Fix
16
+
17
+ - correct workflow condition to allow push events after merge (#130)
18
+ - skip integration tests for fork PRs due to secret restrictions (#128)
19
+
20
+ ## 0.16.0 (2025-08-20)
21
+
22
+ ### Feat
23
+
24
+ - upgrade mocksmith to 6.0.1 (#122)
25
+
26
+ ### Fix
27
+
28
+ - upgrade snowflake-connector-python to >=3.13.1 for critical security vulnerabilities (#123)
29
+
8
30
  ## 0.15.0 (2025-07-27)
9
31
 
10
32
  ### Feat
@@ -1,8 +1,9 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: sql-testing-library
3
- Version: 0.15.0
3
+ Version: 0.17.0
4
4
  Summary: A powerful Python framework for unit testing SQL queries across BigQuery, Snowflake, Redshift, Athena, Trino, and DuckDB with mock data
5
5
  License: MIT
6
+ License-File: LICENSE
6
7
  Keywords: sql,testing,unit-testing,mock-data,database-testing,bigquery,snowflake,redshift,athena,trino,duckdb,data-engineering,etl-testing,sql-validation,query-testing
7
8
  Author: Gurmeet Saran
8
9
  Author-email: gurmeetx@gmail.com
@@ -24,6 +25,7 @@ Classifier: Programming Language :: Python :: 3.10
24
25
  Classifier: Programming Language :: Python :: 3.11
25
26
  Classifier: Programming Language :: Python :: 3.12
26
27
  Classifier: Programming Language :: Python :: 3.13
28
+ Classifier: Programming Language :: Python :: 3.14
27
29
  Classifier: Programming Language :: Python :: Implementation :: CPython
28
30
  Classifier: Topic :: Database
29
31
  Classifier: Topic :: Database :: Database Engines/Servers
@@ -40,7 +42,7 @@ Provides-Extra: redshift
40
42
  Provides-Extra: snowflake
41
43
  Provides-Extra: trino
42
44
  Requires-Dist: db-dtypes (>=1.4.3,<2.0.0)
43
- Requires-Dist: docutils (>=0.21.2,<0.22.0)
45
+ Requires-Dist: docutils (>=0.21.2,<0.23.0)
44
46
  Requires-Dist: pandas (>=1.0.0)
45
47
  Requires-Dist: pydantic (>=2.0.0)
46
48
  Requires-Dist: sqlglot (>=26.0.0)
@@ -66,6 +68,7 @@ A powerful Python framework for unit testing SQL queries with mock data injectio
66
68
  [![Redshift Integration](https://github.com/gurmeetsaran/sqltesting/actions/workflows/redshift-integration.yml/badge.svg)](https://github.com/gurmeetsaran/sqltesting/actions/workflows/redshift-integration.yml)
67
69
  [![Trino Integration](https://github.com/gurmeetsaran/sqltesting/actions/workflows/trino-integration.yml/badge.svg)](https://github.com/gurmeetsaran/sqltesting/actions/workflows/trino-integration.yml)
68
70
  [![Snowflake Integration](https://github.com/gurmeetsaran/sqltesting/actions/workflows/snowflake-integration.yml/badge.svg)](https://github.com/gurmeetsaran/sqltesting/actions/workflows/snowflake-integration.yml)
71
+ [![DuckDB Integration](https://github.com/gurmeetsaran/sqltesting/actions/workflows/duckdb-integration.yml/badge.svg)](https://github.com/gurmeetsaran/sqltesting/actions/workflows/duckdb-integration.yml)
69
72
  [![GitHub license](https://img.shields.io/github/license/gurmeetsaran/sqltesting)](https://github.com/gurmeetsaran/sqltesting/blob/master/LICENSE)
70
73
  [![Pepy Total Downloads](https://img.shields.io/pepy/dt/sql-testing-library?label=PyPI%20Downloads)](https://pepy.tech/projects/sql-testing-library)
71
74
  [![codecov](https://codecov.io/gh/gurmeetsaran/sqltesting/branch/master/graph/badge.svg?token=CN3G5X5ZA5)](https://codecov.io/gh/gurmeetsaran/sqltesting)
@@ -8,6 +8,7 @@ A powerful Python framework for unit testing SQL queries with mock data injectio
8
8
  [![Redshift Integration](https://github.com/gurmeetsaran/sqltesting/actions/workflows/redshift-integration.yml/badge.svg)](https://github.com/gurmeetsaran/sqltesting/actions/workflows/redshift-integration.yml)
9
9
  [![Trino Integration](https://github.com/gurmeetsaran/sqltesting/actions/workflows/trino-integration.yml/badge.svg)](https://github.com/gurmeetsaran/sqltesting/actions/workflows/trino-integration.yml)
10
10
  [![Snowflake Integration](https://github.com/gurmeetsaran/sqltesting/actions/workflows/snowflake-integration.yml/badge.svg)](https://github.com/gurmeetsaran/sqltesting/actions/workflows/snowflake-integration.yml)
11
+ [![DuckDB Integration](https://github.com/gurmeetsaran/sqltesting/actions/workflows/duckdb-integration.yml/badge.svg)](https://github.com/gurmeetsaran/sqltesting/actions/workflows/duckdb-integration.yml)
11
12
  [![GitHub license](https://img.shields.io/github/license/gurmeetsaran/sqltesting)](https://github.com/gurmeetsaran/sqltesting/blob/master/LICENSE)
12
13
  [![Pepy Total Downloads](https://img.shields.io/pepy/dt/sql-testing-library?label=PyPI%20Downloads)](https://pepy.tech/projects/sql-testing-library)
13
14
  [![codecov](https://codecov.io/gh/gurmeetsaran/sqltesting/branch/master/graph/badge.svg?token=CN3G5X5ZA5)](https://codecov.io/gh/gurmeetsaran/sqltesting)
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
4
4
 
5
5
  [tool.poetry]
6
6
  name = "sql-testing-library"
7
- version = "0.15.0"
7
+ version = "0.17.0"
8
8
  description = "A powerful Python framework for unit testing SQL queries across BigQuery, Snowflake, Redshift, Athena, Trino, and DuckDB with mock data"
9
9
  authors = ["Gurmeet Saran <gurmeetx@gmail.com>", "Kushal Thakkar <kushal.thakkar@gmail.com>"]
10
10
  maintainers = ["Gurmeet Saran <gurmeetx@gmail.com>", "Kushal Thakkar <kushal.thakkar@gmail.com>"]
@@ -74,7 +74,7 @@ sqlglot = ">=26.0.0"
74
74
  pydantic = ">=2.0.0"
75
75
  pandas = ">=1.0.0"
76
76
  typing-extensions = {version = ">=4.5.0", python = "<3.10"}
77
- docutils = ">=0.21.2,<0.22.0"
77
+ docutils = ">=0.21.2,<0.23.0"
78
78
  db-dtypes = "^1.4.3"
79
79
 
80
80
  [tool.poetry.group.bigquery.dependencies]
@@ -90,7 +90,7 @@ psycopg2-binary = ">=2.9.0"
90
90
  trino = ">=0.322.0"
91
91
 
92
92
  [tool.poetry.group.snowflake.dependencies]
93
- snowflake-connector-python = ">=3.0.0"
93
+ snowflake-connector-python = ">=3.13.1"
94
94
 
95
95
  [tool.poetry.group.duckdb.dependencies]
96
96
  duckdb = ">=0.8.0"
@@ -120,8 +120,8 @@ twine = ">=4.0.0"
120
120
  ruff = ">=0.0.287"
121
121
  pre-commit = ">=3.5.0"
122
122
  commitizen = ">=3.0.0"
123
- mocksmith = {version = ">=3.0.3", extras = ["mock", "pydantic"]}
124
123
  faker = ">=18.0.0" # Explicit dependency to ensure it's installed in CI
124
+ mocksmith = ">=6.0.1"
125
125
 
126
126
  [tool.poetry.plugins.pytest11]
127
127
  sql_testing = "sql_testing_library._pytest_plugin"
@@ -44,6 +44,7 @@ class AthenaAdapter(PrestoBaseAdapter):
44
44
  database: str,
45
45
  s3_output_location: str,
46
46
  region: str = "us-west-2",
47
+ workgroup: Optional[str] = None,
47
48
  aws_access_key_id: Optional[str] = None,
48
49
  aws_secret_access_key: Optional[str] = None,
49
50
  ) -> None:
@@ -58,6 +59,7 @@ class AthenaAdapter(PrestoBaseAdapter):
58
59
  self.database = database
59
60
  self.s3_output_location = s3_output_location
60
61
  self.region = region
62
+ self.workgroup = workgroup
61
63
 
62
64
  # Initialize Athena client
63
65
  if aws_access_key_id and aws_secret_access_key:
@@ -79,11 +81,18 @@ class AthenaAdapter(PrestoBaseAdapter):
79
81
  """Execute query and return results as DataFrame."""
80
82
  import pandas as pd
81
83
 
84
+ query_params: dict[str, Any] = {
85
+ "QueryExecutionContext": {"Database": self.database},
86
+ "ResultConfiguration": {"OutputLocation": self.s3_output_location},
87
+ }
88
+
89
+ if self.workgroup is not None:
90
+ query_params["WorkGroup"] = self.workgroup
91
+
82
92
  # Start query execution
83
93
  response = self.client.start_query_execution(
84
94
  QueryString=query,
85
- QueryExecutionContext={"Database": self.database},
86
- ResultConfiguration={"OutputLocation": self.s3_output_location},
95
+ **query_params,
87
96
  )
88
97
 
89
98
  query_execution_id = response["QueryExecutionId"]
@@ -86,6 +86,7 @@ class SQLTestDecorator:
86
86
  database = adapter_config.get("database")
87
87
  s3_output_location = adapter_config.get("s3_output_location")
88
88
  region = adapter_config.get("region", "us-west-2")
89
+ workgroup = adapter_config.get("workgroup")
89
90
  aws_access_key_id = adapter_config.get("aws_access_key_id")
90
91
  aws_secret_access_key = adapter_config.get("aws_secret_access_key")
91
92
 
@@ -98,6 +99,7 @@ class SQLTestDecorator:
98
99
  database=database,
99
100
  s3_output_location=s3_output_location,
100
101
  region=region,
102
+ workgroup=workgroup,
101
103
  aws_access_key_id=aws_access_key_id,
102
104
  aws_secret_access_key=aws_secret_access_key,
103
105
  )
@@ -1,5 +1,6 @@
1
1
  """SQL utility functions for escaping and formatting values."""
2
2
 
3
+ import inspect
3
4
  import json
4
5
  from dataclasses import is_dataclass
5
6
  from datetime import date, datetime
@@ -469,14 +470,16 @@ def format_sql_value(value: Any, column_type: Type, dialect: str = "standard") -
469
470
  else:
470
471
  return escape_sql_string(str(value))
471
472
 
472
- # Handle numeric types
473
- elif column_type in (int, float):
474
- return str(value)
475
-
476
- # Handle boolean types
473
+ # Handle boolean types (must come before numeric since bool is subclass of int)
477
474
  elif column_type is bool:
478
475
  return "TRUE" if value else "FALSE"
479
476
 
477
+ # Handle numeric types
478
+ elif column_type in (int, float) or (
479
+ inspect.isclass(column_type) and issubclass(column_type, (int, float))
480
+ ):
481
+ return str(value)
482
+
480
483
  # Handle date types
481
484
  elif column_type is date:
482
485
  if dialect == "bigquery":
@@ -508,7 +511,9 @@ def format_sql_value(value: Any, column_type: Type, dialect: str = "standard") -
508
511
  return f"TIMESTAMP '{value}'"
509
512
 
510
513
  # Handle decimal types
511
- elif column_type == Decimal:
514
+ elif column_type == Decimal or (
515
+ inspect.isclass(column_type) and issubclass(column_type, Decimal)
516
+ ):
512
517
  if dialect == "bigquery":
513
518
  # BigQuery needs explicit NUMERIC casting for decimals
514
519
  return f"NUMERIC '{value}'"