How would you partition a BigQuery table that only has string columns like id, name, and address?
Role: Data Scientist
Category: Data Manipulation (SQL/Python)
Difficulty: medium
Interview Round: Other
How would you apply partitioning on a table that only has string columns like `id`, `name`, and `address`?
Assume the table lives in BigQuery.
```hint Check the supported types
List the kinds of column BigQuery can partition a table on, then compare that list with the columns this table has.
```
```hint Follow the filter
Partitioning and clustering only save bytes when a query's filter touches the column the table is organized by. What will the queries on this table filter on?
```
### Clarifying Questions to Ask
- What do the common queries filter on: exact `id` lookups, searches by `name`, or full scans?
- How large is the table, and how quickly does it grow?
- Does old data ever need to expire or be rewritten by load date?
- Is the table reloaded in full each time, or appended to?
### What a Strong Answer Covers
- Which partitioning types BigQuery supports and why none of them applies to a string column directly
- Clustering as the alternative, including how it handles strings and why column order matters
- Ways to create a partition key when partitions are really needed, and what each one costs
- How query filters decide whether partitioning or clustering saves anything
- When each option is worth it, given table size, access pattern and lifecycle needs
### Follow-up Questions
- Most reads look up a single `id`. Write a query that prunes partitions on a table partitioned by a hashed bucket of `id`, and explain why `WHERE id = '...'` alone does not prune.
- `MOD(FARM_FINGERPRINT(id), 100)` can return negative values. What happens to those rows in an integer-range partitioned table?
- How would you choose between ingestion-time partitioning and adding a real date column such as `updated_at`?
- How would the answer change in Spark or Hive, where a table can be partitioned directly on a string column?
Overview: Asks how to organize a BigQuery table for efficient queries when it has only string columns such as id, name and address. Tests knowledge of BigQuery partitioning types, clustering, derived partition keys, and how query filters decide what gets pruned.