AIInterviewTraining logoAIInterview/Training
🗄️ Data & SQL Engineering
Core

Gaps and Islands (Sessionization)

Gaps-and-islands is the pattern for grouping consecutive rows into runs (islands) split by breaks (gaps), the machinery behind sessionization, streak detection, and merging contiguous ranges. The trick is to assign a group id that holds constant within a run, classically with window functions: ROW_NUMBER differences or LAG-based break flags fed into a running sum. AI, ML, and GenAI interviews probe it because sessionizing events (user sessions, activity streaks, contiguous time ranges) is a constant data task and a sharp test of window-function fluency.

a free account unlocks the core curriculum tier · no card
RELATED CONCEPTS
PRACTICE THIS IN REAL QUESTIONS
COMPANIES THAT ASSUME THIS
NEXT IN DATA & SQL ENGINEERINGChange Data Capture