Metadata-Version: 2.1
Name: bqemulatormanager
Version: 0.1.8
Summary: 
Author: gyuta
Author-email: kuroshiba0408@gmail.com
Requires-Python: >=3.8,<3.11
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Requires-Dist: db-dtypes (>=1.0.4,<2.0.0)
Requires-Dist: google-cloud-bigquery (==2.34.4)
Requires-Dist: psutil (>=5.9.3,<6.0.0)
Requires-Dist: pyyaml (>=6.0,<7.0)
Description-Content-Type: text/markdown

# BiqQueryEmulator Manager


this package is wrapper of [bigquery-emulator](https://github.com/goccy/bigquery-emulator) which provides us BigQuery mock working in local machine.

using this package, you can

- do unit test of your sql
- download the schema of big query, and use it to make test data

## usage
1. following [instruction](https://github.com/goccy/bigquery-emulator#install),  download `bigquery-emulator` command.

2. install this package. 
```
pip install bqemulatormanager
```

3. test your sql.
```python
import bqemulatormanager as bqem
import pandas as pd

manager = bqem.Manager(project='test', schema_path='resources/schema_example.yaml')

with manager:
    data = pd.DataFrame([
        {'id': 1, 'name': 'sato'},
        {'id': 2, 'name': 'yamada'}
    ])

    manager.load(data, 'dataset1.table_a')

    sql = 'SELECT id, name FROM `dataset1.table_a`'

    df = manager.query(sql)
print(df)
```

### automatically detect schema
When called `Manager.load`, `SchemaManager` search correspond table schema from `schema_path` (default is `master_schema.yaml`).

If schema definition canot be found, `SchemaManager` request it from BigQuery in production environmant and update master schema file.
