From 7d87cb319da57704433115902e681b66f460ed4f Mon Sep 17 00:00:00 2001 From: Amogh-Bharadwaj Date: Fri, 12 Jan 2024 23:34:22 +0530 Subject: [PATCH] support project dot dataset --- flow/connectors/bigquery/bigquery.go | 12 +++++++++++- ui/app/peers/create/[peerType]/schema.ts | 4 ---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/flow/connectors/bigquery/bigquery.go b/flow/connectors/bigquery/bigquery.go index 7177e4bb42..aed73f7b6b 100644 --- a/flow/connectors/bigquery/bigquery.go +++ b/flow/connectors/bigquery/bigquery.go @@ -148,12 +148,22 @@ func NewBigQueryConnector(ctx context.Context, config *protos.BigqueryConfig) (* return nil, fmt.Errorf("failed to create BigQueryServiceAccount: %v", err) } + datasetID := config.GetDatasetId() + datasetParts := strings.Split(datasetID, ".") + if len(datasetParts) > 2 { + return nil, + fmt.Errorf("invalid dataset ID: %s. Ensure that it is just a single string or string1.string2", datasetID) + } + if len(datasetParts) == 2 { + datasetID = datasetParts[1] + bqsa.ProjectID = datasetParts[0] + } + client, err := bqsa.CreateBigQueryClient(ctx) if err != nil { return nil, fmt.Errorf("failed to create BigQuery client: %v", err) } - datasetID := config.GetDatasetId() _, checkErr := client.Dataset(datasetID).Metadata(ctx) if checkErr != nil { slog.ErrorContext(ctx, "failed to get dataset metadata", slog.Any("error", checkErr)) diff --git a/ui/app/peers/create/[peerType]/schema.ts b/ui/app/peers/create/[peerType]/schema.ts index 6a21892f39..0b8f552e09 100644 --- a/ui/app/peers/create/[peerType]/schema.ts +++ b/ui/app/peers/create/[peerType]/schema.ts @@ -227,10 +227,6 @@ export const bqSchema = z.object({ }) .min(1, { message: 'Dataset ID must be non-empty' }) .max(1024, 'DatasetID must be less than 1025 characters') - .regex( - /^[\w]+$/, - 'Dataset ID must only contain numbers, letters, and underscores' - ), }); export const chSchema = z.object({