47fac22230
- .claude/CLAUDE.md - .claude/commands/subagentes.md - .claude/rules/INDEX.md - .mcp.json - bash/functions/cybersecurity/analyze_dns.md - bash/functions/cybersecurity/audit_http_headers.md - bash/functions/cybersecurity/audit_ssh_config.md - bash/functions/cybersecurity/check_firewall.md - bash/functions/cybersecurity/detect_suspicious_users.md - bash/functions/cybersecurity/encrypt_file.md - ... Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2.0 KiB
2.0 KiB
name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, params, output, tested, tests, test_file_path, file_path
| name | kind | lang | domain | version | purity | signature | description | tags | uses_functions | uses_types | returns | returns_optional | error_type | imports | params | output | tested | tests | test_file_path | file_path | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| bq_insert_rows | function | py | infra | 1.0.0 | impure | def bq_insert_rows(client: BQClient, dataset_id: str, table_id: str, rows: list[dict]) -> dict | Inserta filas en una tabla BigQuery usando streaming insert (insert_rows_json). Retorna el conteo de filas insertadas y errores por fila. |
|
false | error_go_core |
|
|
dict con {inserted: N filas insertadas sin error, errors: lista de errores por fila retornada por la API} | false | python/functions/bigquery/queries.py |
Ejemplo
from bigquery.client import bq_auth
from bigquery.queries import bq_insert_rows
client = bq_auth("my-project")
result = bq_insert_rows(client, "my_dataset", "events", [
{"event_id": "abc1", "user_id": 42, "ts": "2024-01-01T12:00:00Z", "action": "click"},
{"event_id": "abc2", "user_id": 99, "ts": "2024-01-01T12:01:00Z", "action": "view"},
])
print(f"Insertadas: {result['inserted']}")
if result["errors"]:
print("Errores:", result["errors"])
Notas
El streaming insert tiene disponibilidad casi inmediata pero no es transaccional. Las filas pueden aparecer duplicadas si el job se reintenta — BigQuery no garantiza exactamente-una-vez con insert_rows_json.
errors es la lista retornada directamente por la API. Cada elemento es un dict con
index (posicion de la fila fallida) y errors (lista de mensajes de error).
Para cargas masivas o garantias ACID, preferir bq_load_from_gcs o bq_load_from_file.