Skip to content

Commit

Permalink
Update dataManager.js (#665)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Servidio authored Jan 9, 2023
1 parent 433c99e commit 0db4c82
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions api/v1/src/datasets/dataManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,12 @@ async function createView(view, overrideSql) {

let viewCreated = createViewResult && createViewResult.success;
console.log("Authorizing view objects for access from other datasets");

// https://github.com/GoogleCloudPlatform/datashare-toolkit/issues/655
if (view.accessControl && view.accessControl.enabled === true && cfg.cdsDatasetId !== view.datasetId) {
await bigqueryUtil.shareAuthorizeView(cfg.cdsDatasetId, view.projectId, view.datasetId, view.name, viewCreated);
}

if (Object.prototype.hasOwnProperty.call(view, 'source') && view.source !== null) {
let source = view.source;
// https://github.com/GoogleCloudPlatform/datashare-toolkit/pull/409
Expand All @@ -581,9 +587,6 @@ async function createView(view, overrideSql) {
// but have access to one or more tables or views, in which case authorizing views at the dataset level is required
// if and when selecting data from another object within the same dataset for which a user does not have direct permission.
await bigqueryUtil.shareAuthorizeView(source.datasetId, view.projectId, view.datasetId, view.name, viewCreated);
if (view.accessControl && view.accessControl.enabled === true && cfg.cdsDatasetId !== view.datasetId) {
await bigqueryUtil.shareAuthorizeView(cfg.cdsDatasetId, view.projectId, view.datasetId, view.name, viewCreated);
}
}
else if (Object.prototype.hasOwnProperty.call(view, 'custom') && view.custom !== null) {
// Custom sql
Expand Down

0 comments on commit 0db4c82

Please sign in to comment.