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

UI for BigQuery Peer #620

Merged
merged 11 commits into from
Nov 8, 2023
7 changes: 7 additions & 0 deletions flow/cmd/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,13 @@ func (h *FlowRequestHandler) CreatePeer(
}
sfConfig := sfConfigObject.SnowflakeConfig
encodedConfig, encodingErr = proto.Marshal(sfConfig)
case protos.DBType_BIGQUERY:
bqConfigObject, ok := config.(*protos.Peer_BigqueryConfig)
if !ok {
return wrongConfigResponse, nil
}
bqConfig := bqConfigObject.BigqueryConfig
encodedConfig, encodingErr = proto.Marshal(bqConfig)
case protos.DBType_SQLSERVER:
sqlServerConfigObject, ok := config.(*protos.Peer_SqlserverConfig)
if !ok {
Expand Down
9 changes: 8 additions & 1 deletion flow/connectors/bigquery/bigquery.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,13 @@ func NewBigQueryConnector(ctx context.Context, config *protos.BigqueryConfig) (*
return nil, fmt.Errorf("failed to create BigQuery client: %v", err)
}

datasetID := config.GetDatasetId()
_, checkErr := client.Dataset(datasetID).Metadata(ctx)
if checkErr != nil {
log.Errorf("failed to get dataset metadata: %v", checkErr)
return nil, fmt.Errorf("failed to get dataset metadata: %v", checkErr)
}

storageClient, err := bqsa.CreateStorageClient(ctx)
if err != nil {
return nil, fmt.Errorf("failed to create Storage client: %v", err)
Expand All @@ -174,7 +181,7 @@ func NewBigQueryConnector(ctx context.Context, config *protos.BigqueryConfig) (*
ctx: ctx,
bqConfig: config,
client: client,
datasetID: config.GetDatasetId(),
datasetID: datasetID,
storageClient: storageClient,
}, nil
}
Expand Down
7 changes: 7 additions & 0 deletions ui/app/api/peers/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ const constructPeer = (
type: DBType.SNOWFLAKE,
snowflakeConfig: config as SnowflakeConfig,
};
case 'BIGQUERY':
return {
name,
type: DBType.BIGQUERY,
bigqueryConfig: config as BigqueryConfig,
};
default:
return;
}
Expand Down Expand Up @@ -76,6 +82,7 @@ export async function POST(request: Request) {
return new Response(JSON.stringify(response));
} else if (mode === 'create') {
const req: CreatePeerRequest = { peer };
console.log('/peer/create req:', req);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be removed?

const createStatus: CreatePeerResponse = await fetch(
`${flowServiceAddr}/v1/peers/create`,
{
Expand Down
8 changes: 6 additions & 2 deletions ui/app/dto/PeersDTO.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { PostgresConfig, SnowflakeConfig } from '@/grpc_generated/peers';
import {
BigqueryConfig,
PostgresConfig,
SnowflakeConfig,
} from '@/grpc_generated/peers';

export type UValidatePeerResponse = {
valid: boolean;
Expand Down Expand Up @@ -27,7 +31,7 @@ export type UDropPeerResponse = {
errorMessage: string;
};

export type PeerConfig = PostgresConfig | SnowflakeConfig;
export type PeerConfig = PostgresConfig | SnowflakeConfig | BigqueryConfig;
export type CatalogPeer = {
id: number;
name: string;
Expand Down
Loading
Loading