Normalize Workbook Filters Into A Canonical Query Cache Key

Last updated: November 29, 2026

Quick Overview

Two users apply the same filters to a dataset in different orders, with duplicate values or overlapping ranges. Write a function that merges ANDed list and range filters per column into one canonical form, detects filters that can match nothing, and hashes the result into a cache key.

Sigma Computing
Coding & Algorithms
Software Engineer
Sigma Computing
November 29, 2026
Software Engineer
Phone Screen
Coding & Algorithms
Easy

0

0

0 solved


Two users apply the same filters to a dataset in different orders, with duplicate values or overlapping ranges. Write a function that merges ANDed list and range filters per column into one canonical form, detects filters that can match nothing, and hashes the result into a cache key.

Because every Sigma interaction becomes a warehouse query that costs the customer money, result caching only pays off if equivalent requests map to the same key. The interviewer checks set and interval intersection, determinism, and spotting the always-empty case.

What the Interviewer Expects
  • Treat filters on the same column as ANDed and intersect them
  • Intersect value lists as sets and ranges by max of lows and min of highs
  • Make column names case-insensitive and sort everything for determinism
  • Return a sentinel for impossible filters so no query runs at all
  • Hash a stable serialization (sorted keys, fixed separators)
Key Topics to Cover
canonicalization
set intersection
interval intersection
caching
hashing
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would OR groups or NOT IN filters change the normal form?
  • Why should the cache key also include the user's row-level security attributes?
  • How do you invalidate cached results when the underlying warehouse table changes?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Filters look like {'column': 'Region', 'op': 'in', 'values': [...]} or {'column': 'amount', 'op': 'range', 'lo': 10, 'hi': 100} with either bound optional. All filters are ANDed. Output a canonica...

High-Level Design

Group by lower-cased column. For in, intersect sets. For ranges, tighten bounds. Then per column: if lo > hi, the whole filter set is empty. If there is a value list, apply the range to it and dro...


Submit Your Answer
Markdown supported

Related Questions