Skip to content

Commit

Permalink
Fix: Added "is_public" to cloud_datasets.tabular_datasets table (#501)
Browse files Browse the repository at this point in the history
  • Loading branch information
happyhuman committed Oct 7, 2022
1 parent 1ca6bd6 commit 802cff6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ resource "google_bigquery_table" "_cloud_datasets_tabular_datasets" {
"name": "num_tables",
"description": "Number of tables contained in this dataset",
"type": "INTEGER"
}
},
{
"name": "is_public",
"description": "Whether or not the dataset is public to all users",
"type": "BOOLEAN"
}
]
EOF
depends_on = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"dataset_id",
"description",
"num_tables",
"is_public",
]

TABLES_COLUMNS = [
Expand Down Expand Up @@ -148,6 +149,7 @@ class DatasetInfo:
dataset_id: str = None
description: str = None
num_tables: int = None
is_public: bool = None

def __init__(
self,
Expand All @@ -161,6 +163,10 @@ def __init__(
self.description = np.nan
self.created_at = dataset_reference.created
self.modified_at = dataset_reference.modified
entries = list(dataset_reference.access_entries)
self.is_public = any(
map(lambda e: e.entity_id in {"allAuthenticatedUsers", "allUsers"}, entries)
)

def __repr__(self) -> str:
return f"{self.project_id}.{self.dataset_id}"
Expand Down Expand Up @@ -344,7 +350,7 @@ def main(
extractor.write_datasets_to_bq(tabular_dataset_table_name, extracted)
extractor.write_tables_to_bq(tables_table_name, extracted)
extractor.write_tables_fields_to_bq(tables_fields_table_name, extracted)
logging.info("Total time to run this function: ", time.time() - st)
logging.info("Total time to run this function: %s", time.time() - st)


if __name__ == "__main__":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ resources:
"name": "num_tables",
"description": "Number of tables contained in this dataset",
"type": "INTEGER"
},
{
"name": "is_public",
"description": "Whether or not the dataset is public to all users",
"type": "BOOLEAN"
}
]
- type: bigquery_table
Expand Down

0 comments on commit 802cff6

Please sign in to comment.