In the previous module, we created a Dataplex Lake with a Dataproc Metastore Service, and Dataplex Zones with discovery enabled.
In this module, we will register assets into the Dataplex Zones created.
Lab A: Register assets in BigQuery
Lab B: Register assets in Cloud Storage
Completion of prior modules
20 minutes or less
In this lab sub-module, we will create a BigQuery dataset, load some data into a BigQuery table in the dataset we created and register the dataset as an asset into the Dataplex raw zone we created. We will use the Chicago Crimes public dataset in BigQuery for this lab sub-module.
Paste into Cloud Shell-
PROJECT_ID=`gcloud config list --format "value(core.project)" 2>/dev/null`
PROJECT_NBR=`gcloud projects describe $PROJECT_ID | grep projectNumber | cut -d':' -f2 | tr -d "'" | xargs`
UMSA_FQN="lab-sa@${PROJECT_ID}.iam.gserviceaccount.com"
LOCATION="us-central1"
METASTORE_NM="lab-dpms-$PROJECT_NBR"
LAKE_NM="oda-lake"
DATA_RAW_ZONE_NM="oda-raw-zone"
DATA_RAW_SENSITIVE_ZONE_NM="oda-raw-sensitive-zone"
DATA_CURATED_ZONE_NM="oda-curated-zone"
DATA_PRODUCT_ZONE_NM="oda-product-zone"
MISC_RAW_ZONE_NM="oda-misc-zone"
CRIMES_ASSET="chicago-crimes"
CRIMES_STAGING_DS="oda_crimes_staging_ds"
Paste this command in Cloud Shell to list BQ datasets-
bq ls --format=pretty
These datasets got created automatically by Dataplex when you created zones in the prior module.
Author's results-
+----------------------+
| datasetId |
+----------------------+
| oda_consumption_zone |
| oda_curated_zone |
| oda_misc_zone |
| oda_raw_zone |
+----------------------+
Note that these datasets were automatically created and each of them map to a Dataplex zone we created in the previous module.
bq --location=$LOCATION_MULTI mk \
--dataset \
$PROJECT_ID:$CRIMES_STAGING_DS
Lets list BQ datasets again-
bq ls --format=pretty
You should see the new dataset created-
Author's results-
+-----------------------+
| datasetId |
+-----------------------+
| oda_crimes_staging_ds | <-- We just created this
| oda_curated_zone | <-- Auto-created by Dataplex when we created zones
| oda_misc_zone | <-- Auto-created by Dataplex when we created zones
| oda_product_zone | <-- Auto-created by Dataplex when we created zones
| oda_raw_zone | <-- Auto-created by Dataplex when we created zones
+-----------------------+
Paste this command in Cloud Shell to create a table-
bq --location=$LOCATION_MULTI query \
--use_legacy_sql=false \
"CREATE OR REPLACE TABLE $CRIMES_STAGING_DS.crimes_staging AS SELECT * FROM bigquery-public-data.chicago_crime.crime"
Reload the BQ UI, you should see the table created. Query the table-
SELECT * FROM `oda_crimes_staging_ds.crimes_staging` LIMIT 1000
Paste this command in Cloud Shell to register contents of BQ datasets (currently empty) into corressponding zones-
gcloud dataplex assets create $CRIMES_ASSET \
--location=$LOCATION \
--lake=$LAKE_NM \
--zone=$DATA_RAW_ZONE_NM \
--resource-type=BIGQUERY_DATASET \
--resource-name=projects/$PROJECT_ID/datasets/$CRIMES_STAGING_DS \
--discovery-enabled \
--discovery-schedule="0 * * * *" \
--display-name 'Chicago Crimes'
Review the various tabs of the asset registered.
The physical BigQuery table is called an entity in this case, and is listed.
In this lab sub-module, we will simply add the storage buckets created via Terraform with datasets in them, into the raw zone, and curated zone, depending on format.
The following are the raw data assets to be registered into the Dataplex Raw Zone called oda-raw-zone. The data assets are located at -
GCS Path: gs://raw-data-PROJECT_NBR
| Domain Use Case | Type | Format | GCS directory |
|---|---|---|---|
| Chicago Crimes Analytics | Reference Data | CSV | chicago-crimes |
| Icecream Sales Forecasting | Transactional Data | CSV | icecream-sales-forecasting |
| Telco Customer Churn Prediction | Training Data | CSV | telco-customer-churn-prediction/machine_learning_training |
| Telco Customer Churn Prediction | Scoring Data | CSV | telco-customer-churn-prediction/machine_learning_scoring |
| Cell Tower Anomaly Detection | Reference Data | CSV | cell_tower_anomaly_detection/reference_data |
| Cell Tower Anomaly Detection | Transactional Data | CSV | cell_tower_anomaly_detection/transactions_data |
To register the data assets, we will merely register the buckets and the data assets will automatically get discovered and entities registered. We will review entities created in the next lab module.
gcloud dataplex assets create misc-datasets \
--location=$LOCATION \
--lake=$LAKE_NM \
--zone=$DATA_RAW_ZONE_NM \
--resource-type=STORAGE_BUCKET \
--resource-name=projects/$PROJECT_ID/buckets/raw-data-$PROJECT_NBR \
--discovery-enabled \
--discovery-schedule="0 * * * *" \
--display-name 'Miscellaneous Datasets'
Navigate to Dataplex UI -> Manage -> ODA-LAKE -> ODA-RAW-ZONE -> Assets & familiarize yourself with the various tabs and entries.
The following are the raw data assets to be registered into the Dataplex Raw Zone called oda-raw-sensitive-zone. The data assets are located at -
GCS Path: gs://raw-data-sensitive-PROJECT_NBR
| Domain Use Case | Format | GCS directory |
|---|---|---|
| Banking - Customer Master Data | CSV | banking/customers_raw/customers |
| Banking - Credit Card Customer Customer | CSV | banking/customers_raw/credit_card_customers |
To register the data assets, we will merely register the buckets and the data assets will automatically get discovered and entities registered. We will review entities created in the next lab module.
gcloud dataplex assets create banking-datasets \
--location=$LOCATION \
--lake=$LAKE_NM \
--zone=$DATA_RAW_SENSITIVE_ZONE_NM \
--resource-type=STORAGE_BUCKET \
--resource-name=projects/$PROJECT_ID/buckets/raw-data-sensitive-$PROJECT_NBR \
--discovery-enabled \
--discovery-schedule="0 * * * *" \
--csv-delimiter="|" \
--display-name 'Banking Datasets'
Navigate to Dataplex UI -> Manage -> ODA-LAKE -> ODA-RAW-SENSITIVE-ZONE -> Assets & familiarize yourself with the various tabs and entries.
The following are the curated data assets to be registered into the Dataplex Curated Zone called oda-curated-zone. The data assets are located at -
GCS Path: gs://curated-data-PROJECT_NBR
| Domain Use Case | Format | GCS directory |
|---|---|---|
| Retail Transactions Anomaly Detection | Parquet | retail-transactions-anomaly-detection/ |
| Cell Tower Anomaly Detection | Parquet |
To register the data assets, we will merely register the buckets and the data assets will automatically get discovered and entities registered. We will review entities created in the next lab module.
gcloud dataplex assets create misc-datasets \
--location=$LOCATION \
--lake=$LAKE_NM \
--zone=$DATA_CURATED_ZONE_NM \
--resource-type=STORAGE_BUCKET \
--resource-name=projects/$PROJECT_ID/buckets/curated-data-$PROJECT_NBR \
--discovery-enabled \
--discovery-schedule="0 * * * *" \
--display-name 'Miscellaneous Datasets'
Navigate to Dataplex UI -> Manage -> ODA-LAKE -> ODA-CURATED-ZONE -> Assets & familiarize yourself with the various tabs and entries.
The following are the notebook assets to be registered into the Dataplex Raw Zone called oda-misc-zone. The notebook assets are located at -
GCS Path: gs://raw-notebook-PROJECT_NBR
| Domain Use Case | Format | GCS directory |
|---|---|---|
| Chicago Crimes Analytics | .pynb | chicago-crimes-analysis |
| Icecream Sales Forecasting | .pynb | icecream-sales-forecasting |
| Retail Transactions Anomaly Detection | .ipynb | retail-transactions-anomaly-detection |
| Telco Customer Churn Prediction | .pynb | telco-customer-churn-prediction |
To see the listing in Cloud Shell, paste the below command-
gsutil ls gs://raw-notebook-$PROJECT_NBR
The author's output is:
gs://raw-notebook-36819656457/chicago-crimes-analysis/
gs://raw-notebook-36819656457/icecream-sales-forecasting/
gs://raw-notebook-36819656457/retail-transactions-anomaly-detection/
gs://raw-notebook-36819656457/telco-customer-churn-prediction/
To register the notebook assets, we will merely register the buckets and the notebook assets will automatically get discovered and entities registered. We will review entities created in the next lab module.
gcloud dataplex assets create notebooks \
--location=$LOCATION \
--lake=$LAKE_NM \
--zone=$MISC_RAW_ZONE_NM \
--resource-type=STORAGE_BUCKET \
--resource-name=projects/$PROJECT_ID/buckets/raw-notebook-$PROJECT_NBR \
--display-name 'Analytics Notebooks'
Navigate to Dataplex UI -> Manage -> ODA-LAKE -> ODA-MISC-ZONE -> Assets & familiarize yourself with the various tabs and entries.
The following are the code assets to be registered into the Dataplex Raw Zone called oda-misc-zone. The code assets are located at -
GCS Path: gs://raw-code-PROJECT_NBR
To see the listing in Cloud Shell, paste the below command-
gsutil ls -r gs://raw-code-$PROJECT_NBR
The author's output is:
gs://raw-code-36819656457/retail-transactions-anomaly-detection/retail-transactions-anomaly-detection.sql
To register the notebook assets, we will merely register the buckets and the notebook assets will automatically get discovered and entities registered. We will review entities created in the next lab module.
gcloud dataplex assets create code-assets \
--location=$LOCATION \
--lake=$LAKE_NM \
--zone=$MISC_RAW_ZONE_NM \
--resource-type=STORAGE_BUCKET \
--resource-name=projects/$PROJECT_ID/buckets/raw-code-$PROJECT_NBR \
--display-name 'Code Assets'
Navigate to Dataplex UI -> Manage -> ODA-LAKE -> ODA-MISC-ZONE -> Assets & familiarize yourself with the various tabs and entries.
This concludes the lab module. Proceed to the next module.












