by david-pivonka · v0.0.1
Query and manipulate BigQuery data with dual tools: read-only SELECT queries and write operations (INSERT/UPDATE/DELETE).
This community listing does not yet include every recommended support, privacy, pricing, and permission disclosure. Review the available package permissions before installing.
Available inside your emploidai workspace after installation.
Available inside your emploidai workspace after installation.
Author: david-pivonka Version: 0.0.1 Type: Tool Plugin
The BigQuery plugin enables Dify applications to query and modify data in Google BigQuery directly. It provides secure, authenticated connections to BigQuery using Google Cloud service account credentials with separate tools for read and write operations.
Your Google Cloud service account must have at least these IAM roles:
roles/bigquery.user - To run queriesroles/bigquery.dataViewer - To read table dataOr specific dataset/table level permissions as needed.
dify-bigquery-plugin.difypkg file.difypkg fileThe plugin provides two tools:
The plugin requires the following credentials:
The complete JSON content of your Google Cloud service account key file. This includes:
{
"type": "service_account",
"project_id": "your-project-id",
"private_key_id": "...",
"private_key": "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n",
"client_email": "your-service-account@project.iam.gserviceaccount.com",
"client_id": "...",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "...",
"universe_domain": "googleapis.com"
}
How to obtain:
Override the project ID from the service account JSON if you want to query a different project.
The plugin provides two separate tools that can be used in Dify workflows:
Use this tool to execute SELECT queries and retrieve data from BigQuery.
In Dify Workflows:
Parameters:
Important: Only SELECT queries are allowed in this tool. Use the Mutation tool for data modifications.
Output:
data: Array of row datacolumns: Array of column namesUse this tool to execute INSERT, UPDATE, or DELETE queries to modify data in BigQuery.
In Dify Workflows:
Parameters:
Important: Only INSERT, UPDATE, DELETE queries are allowed in this tool. Use the Query tool for SELECT operations.
Output:
affected_rows: Number of rows modifiedsuccess: Boolean indicating successful executionSimple SELECT:
SELECT 1 as test_value, 'Hello BigQuery' as message
Query a Table:
SELECT
customer_id,
order_date,
total_amount
FROM `project.dataset.orders`
WHERE order_date >= '2024-01-01'
LIMIT 100
Note: Use max_fetched_rows parameter to limit results returned to Dify
Aggregation Query:
SELECT
product_category,
COUNT(*) as order_count,
SUM(total_amount) as total_revenue
FROM `project.dataset.orders`
GROUP BY product_category
ORDER BY total_revenue DESC
INSERT Data:
INSERT INTO `project.dataset.customers` (customer_id, name, email, created_at)
VALUES (12345, 'John Doe', 'john@example.com', CURRENT_TIMESTAMP())
UPDATE Data:
UPDATE `project.dataset.orders`
SET status = 'shipped', shipped_at = CURRENT_TIMESTAMP()
WHERE order_id = 98765 AND status = 'pending'
DELETE Data:
DELETE FROM `project.dataset.temp_data`
WHERE created_at < TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 30 DAY)
Query Tool Output:
Variables:
data: Array of row tuplescolumns: Array of column namesJSON Message:
{
"data": [
{
"column1": "value1",
"column2": "value2"
},
{
"column1": "value3",
"column2": "value4"
}
]
}
Mutation Tool Output:
Variables:
affected_rows: Number of rows modified (integer)JSON Message:
{
"affected_rows": 5,
"success": true
}
# Clone the repository
git clone https://github.com/david-pivonka/dify-bigquery-plugin.git
cd dify-bigquery-plugin
# Install dependencies
pip install -r requirements.txt
# Package the plugin
dify plugin package .
See TESTING.md for detailed testing instructions.
# Run the plugin for testing
dify plugin run ./dify-bigquery-plugin.difypkg --enable-logs
Error: "Invalid JSON in service_account_json"
Error: "Missing required fields in service account JSON"
Error: "Only SELECT operations are allowed" (from Query tool)
Error: "Only INSERT, UPDATE, DELETE operations are allowed" (from Mutation tool)
Query timeout or exceeded quota
The plugin is structured following Dify's plugin architecture:
dify-bigquery-plugin/
├── manifest.yaml # Plugin metadata
├── main.py # Plugin entry point
├── provider/
│ ├── bigquery.yaml # Provider configuration
│ └── bigquery.py # Credential validation
├── tools/
│ ├── bigquery_query.yaml # Query tool definition
│ ├── bigquery_query.py # Query tool implementation
│ ├── bigquery_mutation.yaml # Mutation tool definition
│ ├── bigquery_mutation.py # Mutation tool implementation
│ └── api.py # SQL type checking utilities
└── requirements.txt # Python dependencies
dify_plugin>=0.4.0,<0.7.0 - Dify plugin SDKgoogle-cloud-bigquery>=3.0.0 - Google BigQuery clientsqlglot>=26.11.1 - SQL parser and transpilersqlglotrs>=0.4.0 - Fast SQL parserSee LICENSE file for details.
For issues, questions, or contributions, please visit:
See PRIVACY.md for information about data handling and privacy practices.