Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: BQ integration #1

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make the Bigquery integration compatible with the new internal API.
  • Loading branch information
bilus committed Sep 7, 2022
commit 599dd0704f8a5ed43fa70f55eafc520f2cc2f60e
30 changes: 16 additions & 14 deletions packages/server/src/integrations/bigQuery.ts
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
import {
DatasourceFieldTypes,
DatasourceFieldType,
Integration,
QueryTypes,
QueryType,
SqlQuery,
} from "../definitions/datasource"
Table,
} from "@budibase/types"

import { BigQuery, BigQueryOptions } from "@google-cloud/bigquery"
import { Table } from "../definitions/common"

const SCHEMA: Integration = {
docs: "https://cloud.google.com/bigquery/docs",
datasource: {
projectId: {
type: DatasourceFieldTypes.STRING,
type: DatasourceFieldType.STRING,
required: true,
},
datasetId: {
type: DatasourceFieldTypes.STRING,
type: DatasourceFieldType.STRING,
required: true,
},
apiEndpoint: {
type: DatasourceFieldTypes.STRING,
type: DatasourceFieldType.STRING,
required: false,
},
email: {
type: DatasourceFieldTypes.STRING,
type: DatasourceFieldType.STRING,
required: true,
},
privateKey: {
type: DatasourceFieldTypes.STRING,
type: DatasourceFieldType.STRING,
required: true,
},
},
query: {
create: {
type: QueryTypes.SQL,
type: QueryType.SQL,
},
read: {
type: QueryTypes.SQL,
type: QueryType.SQL,
},
update: {
type: QueryTypes.SQL,
type: QueryType.SQL,
},
delete: {
type: QueryTypes.SQL,
type: QueryType.SQL,
},
},
friendlyName: "BigQuery",
Expand Down Expand Up @@ -85,6 +85,8 @@ class BigQueryIntegration {
}

async createDatasetIfDoesNotExist() {
// TODO: To prevent a race condition, try to create dataset first, only
// return if error creating because it already exists.
try {
const existingDataset = await this.client.dataset(this.datasetId).get()
if (!existingDataset) {
Expand Down Expand Up @@ -130,7 +132,7 @@ class BigQueryIntegration {
}
}

module.exports = {
export default {
schema: SCHEMA,
integration: BigQueryIntegration,
}