Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save taufiqibrahim/81df3e22adf85be4d23da33d3bc9f373 to your computer and use it in GitHub Desktop.
Save taufiqibrahim/81df3e22adf85be4d23da33d3bc9f373 to your computer and use it in GitHub Desktop.
# Create Pub/Sub schema
gcloud pubsub schemas create mysql.inventory.addresses-schema \
--type=AVRO \
--definition='{"type":"record","name":"MysqlInventoryAddressesSchema","fields":[{"type":"int","optional":false,"name":"id"},{"type":"int","optional":false,"name":"customer_id"},{"type":"string","optional":false,"name":"street"},{"type":"string","optional":false,"name":"city"},{"type":"string","optional":false,"name":"state"},{"type":"string","optional":false,"name":"zip"},{"type":"string","optional":false,"name":"type"},{"type":"string","optional":true,"name":"__op"},{"type":"string","optional":true,"name":"__table"},{"type":"long","optional":true,"name":"__source_ts_ms"},{"type":"string","optional":true,"name":"__deleted"}]}'
# Describe schema
gcloud pubsub schemas describe mysql.inventory.addresses-schema
# Create Pub/Sub topic with schema
gcloud pubsub topics create mysql.inventory.addresses --message-encoding=json --schema=mysql.inventory.addresses-schema
# Create BigQuery subscription
gcloud pubsub subscriptions create mysql.inventory.addresses-bq-sub --topic mysql.inventory.addresses --bigquery-table=$PROJECT_ID.$BQ_DATASET.mysql_inventory_addresses --use-topic-schema
# Run containers
docker-compose down -v
docker-compose up
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment