Skip to content

Commit

Permalink
support project dot dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
Amogh-Bharadwaj committed Jan 19, 2024
1 parent c978de3 commit 7d87cb3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
12 changes: 11 additions & 1 deletion flow/connectors/bigquery/bigquery.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
4 changes: 0 additions & 4 deletions ui/app/peers/create/[peerType]/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit 7d87cb3

Please sign in to comment.