feat: add BigQuery Python functions and BQClient type

Funciones CRUD completas para BigQuery: auth, datasets, tables, queries,
jobs, routines, load/export. Tipo BQClient como wrapper del SDK oficial.
This commit is contained in:
2026-04-07 18:45:02 +02:00
parent c9f28aa603
commit 9f5e6791db
33 changed files with 2720 additions and 0 deletions
@@ -0,0 +1,59 @@
---
name: bq_create_dataset
kind: function
lang: py
domain: infra
version: "1.0.0"
purity: impure
signature: "def bq_create_dataset(client: BQClient, dataset_id: str, location: str = 'US', description: str = '', labels: dict[str, str] | None = None, default_table_expiration_ms: int = 0) -> dict"
description: "Crea un dataset en Google BigQuery con ubicacion, descripcion y labels. Usa client._client.create_dataset() del SDK oficial."
tags: [bigquery, gcp, dataset, create, google-cloud, python]
uses_functions: []
uses_types: []
returns: []
returns_optional: false
error_type: "error_go_core"
imports: [google-cloud-bigquery]
params:
- name: client
desc: "instancia autenticada de BQClient"
- name: dataset_id
desc: "nombre del dataset dentro del proyecto (sin prefijo de proyecto)"
- name: location
desc: "ubicacion geografica del dataset: US, EU, us-central1, europe-west1, etc."
- name: description
desc: "descripcion opcional del dataset"
- name: labels
desc: "dict de labels key-value para categorizar el dataset"
- name: default_table_expiration_ms
desc: "tiempo de expiracion por defecto para tablas en milisegundos; 0 = sin expiracion"
output: "dict con dataset_id, project, full_id, location, description, labels, created, modified, default_table_expiration_ms"
tested: false
tests: []
test_file_path: ""
file_path: "python/functions/bigquery/datasets.py"
---
## Ejemplo
```python
from bigquery.client import bq_auth
from bigquery.datasets import bq_create_dataset
client = bq_auth("my-project")
ds = bq_create_dataset(
client,
"analytics",
location="EU",
description="Data warehouse principal",
labels={"env": "prod", "team": "data"},
)
print(ds["full_id"], ds["location"])
# my-project.analytics EU
```
## Notas
Lanza `google.api_core.exceptions.Conflict` (409) si el dataset ya existe.
El `full_id` tiene formato `{project}.{dataset_id}` y puede usarse directamente como referencia en otras llamadas al SDK.
`default_table_expiration_ms` aplica a todas las tablas nuevas del dataset; las tablas existentes no se ven afectadas.