keboola / storage-driver-bigquery
Keboola BigQuery 驱动器
v7.8.3
2024-08-23 07:26 UTC
Requires
- php: ^8.1
- ext-json: *
- google/apiclient: ^2.12.1
- google/apiclient-services: 0.282.0
- google/cloud-bigquery: ^1.23
- google/cloud-bigquery-analyticshub: ^0.1.0
- google/cloud-billing: ^1.4
- google/cloud-resource-manager: ^0.6.1
- google/cloud-service-usage: ^0.2.7
- google/protobuf: ^3.21
- keboola/db-import-export: >=2.7.0
- keboola/php-file-storage-utils: ^0.2.5
- keboola/retry: ^0.5.1
- keboola/storage-driver-common: ^6.9
- keboola/table-backend-utils: >=2.8.0
- psr/log: ^1.1|^2.0|^3.0
- react/async: ^3.0
- symfony/polyfill-php80: ^1.26
Requires (Dev)
- brianium/paratest: ^6.10
- google/cloud-bigquery-connection: ^1.5
- keboola/coding-standard: ^15.0
- keboola/phpunit-retry-annotations: ^0.5.0
- php-parallel-lint/php-parallel-lint: ^1.3
- phpstan/phpstan: ^1.8
- phpstan/phpstan-phpunit: ^1.1
- phpstan/phpstan-symfony: ^1.2
- phpunit/phpunit: ^9.5
- symfony/finder: ^5.4
- symfony/lock: ^6.3
- dev-main
- v7.8.3
- v7.8.2
- v7.8.1
- v7.8.0
- v7.7.2
- v7.7.1
- v7.7.0
- v7.6.0
- v7.5.0
- v7.4.3
- v7.4.2
- v7.4.1
- v7.4.0
- v7.3.0
- v7.2.4
- v7.2.3
- v7.2.2
- v7.2.1
- v7.2.0
- v7.1.1
- v7.1.0
- v7.0.1
- v7.0.0
- v6.0.1
- v6.0.0
- v5.5.1
- v5.5.0
- v5.4.0
- v5.3.4
- v5.3.3
- v5.3.2
- v5.3.1
- v5.3.0
- v5.2.17
- v5.2.16
- v5.2.15
- v5.2.14
- v5.2.13
- v5.2.12
- v5.2.11
- v5.2.10
- v5.2.9
- v5.2.8
- v5.2.7
- v5.2.6
- v5.2.5
- v5.2.4
- v5.2.3
- v5.2.2
- v5.2.1
- v5.2.0
- v5.1.3
- v5.1.2
- v5.1.1
- v5.1.0
- v5.0.0
- v4.0.1
- v4.0.0
- v3.4.1
- v3.4.0
- v3.3.0
- v3.2.0
- v3.1.1
- v3.1.0
- v3.0.5
- v3.0.4
- v3.0.3
- v3.0.2
- v3.0.1
- v3.0.0
- v2.14.0
- v2.13.1
- v2.13.0
- v2.12.0
- v2.11.0
- v2.10.0
- v2.9.0
- v2.8.0
- v2.7.0
- v2.6.0
- v2.5.0
- v2.4.0
- v2.3.0
- v2.2.0
- v2.1.0
- v2.0.0
- v1.2.0
- v1.1.0
- v1.0.0
- v0.1.1
- v0.1
- dev-ct-1482-test-link-ex-bucket-to-dest-project
- dev-ct-1482-view-in-dest-project
- dev-ct-1482-link-using-source-prj-cred
- dev-ct-1482-manual-add-subscriber
- dev-zajca-fix-throwexception
- dev-tf-test-bq-monorepo
- dev-big-245-fix-creating-job-query
- dev-big-123-filter-out-ws-dataset-from-other-ws
- dev-BIG-113-array_conversion
- dev-roman-create-exchanger-when-creating-project
This package is auto-updated.
Last update: 2024-09-18 05:51:12 UTC
README
Keboola 高级 Big Query 存储后端驱动程序
安装依赖项。
docker compose run --rm dev composer install
设置 Big Query
安装 Google Cloud 客户端(通过 Brew),初始化它并登录到 生成默认凭据。
使用 Terraform 模板 准备后端。在 KBC Team Dev(id: 431160969986) 文件夹中创建子文件夹,并将文件夹填充到 terraform 命令中。
- 从 连接存储库 获取缺少的部分(组织 ID 和账单 ID)。
- (可选)将
bq-storage-backend-init.tf
从项目目录移出,以便新的文件将位于 git 之外 - 运行
terraform init
- 运行
terraform apply -var folder_id=[folder_id] -var billing_account_id=[billing_id] -var backend_prefix=<your prefix, eg. kbc-js> -var file_storage_backend_region=<desired region>
(例如 us-central1 区域)- 可选地设置
terraform.tfvars
文件,其中预定义了terraform.tfvars.dist
文件中的变量
- 可选地设置
- 已创建新密钥文件
principal_key.json
和big_query_key.json
- 通过运行
php SetBQVars.php
并停止,或手动提取来设置来自principal_key.json
和big_query_key.json
的环境变量。 - 打开
principal_key.json
,将private_key
的内容设置为变量BQ_SECRET
,并将其从 json 文件中删除(整个条目)- 注意:即使带有引号和新行,也只需简单复制粘贴整个内容 -> 你的 .env 将如下所示
BQ_SECRET="-----BEGIN PRIVATE KEY-----XXXXZQ==\n-----END PRIVATE KEY-----\n"
- 注意:即使带有引号和新行,也只需简单复制粘贴整个内容 -> 你的 .env 将如下所示
- 删除其余密钥文件(不包括
private_key
条目)中的换行符,并将其设置为变量BQ_PRINCIPAL
传递给.env
- 您可以使用
awk -v RS= '{$1=$1}1' principal_key.json
将密钥转换为字符串
- 您可以使用
- 删除
big_query_key.json
密钥文件中的换行符,并将其设置为变量BQ_KEY_FILE
传递给.env
- 您可以使用
awk -v RS= '{$1=$1}1' big_query_key.json
将密钥转换为字符串
- 您可以使用
最后,您的 .env
文件应如下所示...
# the id is printed by terraform at the end and it is just the numbers after `folders/` BQ_PRINCIPAL=<the content of the principal_key.json key file as single line without private_key entry> BQ_SECRET=<private_key from principal_key.json key file (taken from BQ_PRINCIPAL)> BQ_FOLDER_ID=<TF output file_storage_bucket_id : the id of the created folder, just the number, without /folders prefix> BQ_BUCKET_NAME=<TF output file_storage_bucket_id : bucket id created in main project> # choose different BQ_STACK_PREFIX than you Terraform prefix otherwise project created by Terraform will be deleted . e.g. local :) BQ_STACK_PREFIX=local BQ_KEY_FILE=<big_query_key.json file owned by main service acc>
全部完成。现在您可以尝试运行 composer loadGcs
脚本并执行测试。
docker compose run --rm dev composer loadGcs
构建 Docker 镜像
docker compose build
Xdebug
要使用 xdebug 运行,请使用 dev-xdebug
容器而不是 dev
测试
使用以下命令运行测试。
# This will run all tests docker compose run --rm dev composer tests # This will run all tests in parallel docker compose run --rm dev composer paratest # This will run import tests in parallel docker compose run --rm dev composer paratest-import # This will run export tests in parallel docker compose run --rm dev composer paratest-export # This will run all tests in parallel excluding import and export docker compose run --rm dev composer paratest-other
要禁用重试,请复制 phpunit-retry.xml.dist
cp phpunit-retry.xml.dist phpunit-retry.xml
代码质量检查
#run all bellow but not tests docker compose run --rm dev composer check #phplint docker compose run --rm dev composer phplint #phpcs docker compose run --rm dev composer phpcs #phpcbf docker compose run --rm dev composer phpcbf #phpstan docker compose run --rm dev composer phpstan
完整的 CI 工作流程
此命令将运行所有检查并运行测试
docker compose run --rm dev composer ci
使用
项目 ID:您的项目的全局唯一标识符。此库创建项目 ID 作为 CreateProjectCommand
中的 stackPrefix
和 projectId
的组合
项目 ID 是用于区分您的项目与 Google Cloud 中所有其他项目的唯一字符串。您可以使用 Google Cloud 控制台生成项目 ID,或者您可以自己选择。您只能在创建项目时修改项目 ID。
项目 ID 要求
- 长度必须是6到30个字符。
- 只能包含小写字母、数字和短横线。
- 必须以字母开头。
- 不能以短横线结尾。
- 不能正在使用或之前已使用;这包括已删除的项目。
- 不能包含受限制的字符串,例如
google
和ssl
。
许可证
MIT许可证,请参阅LICENSE文件。