GCP Interview Questions
BigQuery uses a serverless , distributed architecture that separates storage and compute, allowing each to scale independently. Key architectural compon...
What is the architecture of BigQuery?
BigQuery uses a serverless , distributed architecture that separates storage and compute, allowing each to scale independently. Key architectural components: Dremel Execution Engine : The compute layer that processes SQL queries using a multi level serving tree. Queries are broken into smaller sub queries distributed across thousands of workers (called slots ) for massively parallel execution. Colossus (Distributed Storage) : BigQuery stores data in Google's Colossus distributed file system in a
What are the optimization techniques in BigQuery?
BigQuery performance can be significantly improved using several optimization techniques : 1. Partitioning Divides a table into segments based on a column (typically a DATE or TIMESTAMP column), an integer range , or ingestion time Queries that filter on the partition column scan only relevant partitions, reducing cost and latency 2. Clustering Sorts data within each partition by up to four columns Most effective on high cardinality columns used in WHERE , JOIN , or GROUP BY clauses 3. Column Pr
How to encrypt data in GCS?
Google Cloud Storage (GCS) provides multiple layers of encryption to protect data both at rest and in transit . Encryption at Rest (three options): Google Managed Encryption Keys (GMEK) : Enabled by default on all GCS objects. Google manages the AES 256 encryption keys automatically with no configuration required. Customer Managed Encryption Keys (CMEK) : You create and manage keys in Cloud KMS . You control rotation schedules and can revoke access by disabling the key. Customer Supplied Encrypt
How can you retrieve a deleted table in BigQuery?
BigQuery provides a time travel feature that allows you to recover a deleted table within a configurable window. Using Time Travel (up to 7 days): BigQuery retains deleted table data for up to 7 days by default (configurable per dataset). You can restore a deleted table by copying it from a snapshot at a specific timestamp . Using Table Snapshots: For critical tables, you can proactively create table snapshots that persist beyond the time travel window. Key Considerations: The time travel window
How can you prevent a table from being deleted in BigQuery?
There is no single "delete lock" on a BigQuery table, but several strategies can prevent accidental or unauthorized deletion : 1. IAM Permissions (Primary Defense) Restrict who holds the bigquery.tables.delete permission Use the principle of least privilege : assign roles/bigquery.dataViewer or roles/bigquery.dataEditor instead of roles/bigquery.dataOwner or roles/bigquery.admin Create a custom IAM role that excludes delete permissions 2. Table Snapshots Periodically create table snapshots so da
What are Materialized Views and Logical (Generic) Views in BigQuery?
BigQuery supports two types of views: Logical Views (standard views) and Materialized Views . They serve different purposes and have distinct performance and cost characteristics. Logical (Standard) Views: A saved SQL query that is executed every time the view is queried No data is stored the underlying query runs on each access Always returns fresh results since it reads directly from base tables Useful for access control (exposing a subset of columns/rows) and query simplification Materialized
What are slots in BigQuery?
Slots are BigQuery's unit of computational capacity . Each slot represents a virtual CPU used to execute SQL queries. How Slots Work: When you submit a query, BigQuery's Dremel execution engine breaks it into stages and distributes work across multiple slots Each slot performs a portion of the work: reading data from storage, filtering, aggregating, joining, and sorting BigQuery dynamically allocates slots based on query complexity and available resources Pricing Models: On Demand Pricing : You
What file formats are supported by BigQuery?
BigQuery supports several file formats for loading , exporting , and querying external data . Supported Formats for Loading Data: Format Description Best For CSV Comma separated values Simple flat files, legacy systems JSON (Newline Delimited) One JSON object per line Semi structured data, nested fields Avro Binary row based format with embedded schema Schema evolution, Hadoop ecosystem Parquet Columnar binary format Analytics workloads, Spark/Hive output ORC Optimized Row Columnar format Hive b