{"id":16643625,"url":"https://github.com/takegue/pytest-sql-bigquery","last_synced_at":"2025-10-30T12:30:23.461Z","repository":{"id":44202717,"uuid":"160193564","full_name":"takegue/pytest-sql-bigquery","owner":"takegue","description":"test suits for bigquery sql","archived":false,"fork":false,"pushed_at":"2022-12-08T01:27:41.000Z","size":62,"stargazers_count":4,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-02T08:31:46.704Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/takegue.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-12-03T13:16:49.000Z","updated_at":"2021-06-09T03:43:00.000Z","dependencies_parsed_at":"2023-01-24T21:30:26.281Z","dependency_job_id":null,"html_url":"https://github.com/takegue/pytest-sql-bigquery","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takegue%2Fpytest-sql-bigquery","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takegue%2Fpytest-sql-bigquery/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takegue%2Fpytest-sql-bigquery/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takegue%2Fpytest-sql-bigquery/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/takegue","download_url":"https://codeload.github.com/takegue/pytest-sql-bigquery/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238961198,"owners_count":19559439,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-12T08:09:10.327Z","updated_at":"2025-10-30T12:30:18.168Z","avatar_url":"https://github.com/takegue.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Pytest plugin for Bigquery SQL\n\npytest-sql-bigquery is pytest-plugin which provides a sql-unitest-framework for BigQuery.\nThis plugin adopts an end-to-end approch that runnning SQL test on SQL engines.\n\n## Yet anthoer approch to tst SQL code\n\nSee following SQL codes:\n\n```sql\nwith dataset as (\n    select 1\n    union all select 2\n)\n, __check_sample as (\n    select 'test' as label, count(1) as actual, 2 as expected from dataset \n)\n\nselect * from dataset\n```\n\nThis code is minimal example including test case.\n`__check_sample` is a test case which makes sure the `dataset` view has just 2 record.\n\n\nOur idea is very simple: \"Verify SQL code by SQL-self.\"\n\nThis plugin generate SQL test codes from SQL and executed them on SQL-engine such as BigQuery.\n\nThe advantages of this approch are \n\n- SQL codes owns specification itself\n- Provide portability of logic and its test codes. \n- Free to hard-mocking database system\n\n\n# Get Started\n\n## Requirements\n\n- Python \u003e= 3.7\n- sqlparse\n- google-cloud-bigquery (For BigQuery integration)\n\n- BigQuery (Google Cloud Project)\n\n## Install\n\n```\npip install pytest-bigquery-sql\n```\n\nThen, set up `confidist.py` for pytest settings.\n\n```python\nimport pytest\n\nfrom pytest_sql_bigquery.integrations.pytest import SQLReaderForChecking\n\nclass ChainPytestFile(pytest.File):\n\n    def __init__(self, path, parent, chains, **kwargs):\n        super().__init__(path, parent, **kwargs)\n        self.chains = chains\n\n    def collect(self):\n        for interpreter in self.chains:\n            yield from interpreter.collect()\n\ndef pytest_collect_file(parent, path):\n    if path.ext == \".sql\":\n        return ChainPytestFile(\n            path, parent,\n            [\n                SQLReaderForChecking(path, parent),\n            ])\n```\n\nRun test for `examples/sql` directory\n\n```\npytest run -vv examples/sql \n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftakegue%2Fpytest-sql-bigquery","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftakegue%2Fpytest-sql-bigquery","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftakegue%2Fpytest-sql-bigquery/lists"}