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

Fix: Added "is_public" to tabular_datasets table #501

Merged
merged 7 commits into from
Oct 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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