Sign in to run and submit your work
Reading is open to everyone. Running code and saving drafts need an account so your work is yours and comes back on your next visit.
or
CODE WORKSPACE
Before a query runs, the planner decides which partition folders to open. Reading them all is correct and slow; skipping one that could contain a matching row is fast and wrong, and the wrongness is invisible — the query returns fewer rows with no error.
Write plan_partition_scan(partitions, filters). Each partition carries the values of its partition columns.
Function to write
plan_partition_scan(partitions: list[dict], filters: list[dict]) -> dictA dict with the partitions to scan, the ones skipped with the filter that excluded them, and the filters that pruned nothing.
How to approach it
Ask whether a filter proves the partition irrelevant; when in doubt, keep it.
Sample cases
+ 2 held back until you submit
a filtered query
A range filter, a set filter, a filter on a non-partition column, and a partition with no values at all.
Input
Argument 1
[
{
'path': 'events/dt=2026-03-01/region=EMEA',
'values': {
'dt': '2026-03-01',
'region': 'EMEA'
}
},
{
'path': 'events/dt=2026-03-02/region=EMEA',
'values': {
'dt': '2026-03-02',
'region': 'EMEA'
}
},
{
'path': 'events/dt=2026-03-02/region=APAC',
'values': {
'dt': '2026-03-02',
'region': 'APAC'
}
},
{
'path': 'events/dt=2026-03-05/region=NA',
'values': {
'dt': '2026-03-05',
'region': 'NA'
}
},
{
'path': 'events/legacy',
'values': {}
}
]Argument 2
[
{
'column': 'dt',
'op': '>=',
'value': '2026-03-02'
},
{
'column': 'region',
'op': 'in',
'value': [
'EMEA',
'APAC'
]
},
{
'column': 'user_id',
'op': '=',
'value': 'u1'
}
]Returns
{
'scan': [
'events/dt=2026-03-02/region=APAC',
'events/dt=2026-03-02/region=EMEA',
'events/legacy'
],
'skipped': [
{
'path': 'events/dt=2026-03-01/region=EMEA',
'column': 'dt',
'op': '>='
},
{
'path': 'events/dt=2026-03-05/region=NA',
'column': 'region',
'op': 'in'
}
],
'unpruned_filters': [
'user_id'
]
}no filters
An unfiltered query reads everything, which is the correct and expensive answer.
Input
Argument 1
[
{
'path': 'events/dt=2026-03-01/region=EMEA',
'values': {
'dt': '2026-03-01',
'region': 'EMEA'
}
},
{
'path': 'events/dt=2026-03-02/region=EMEA',
'values': {
'dt': '2026-03-02',
'region': 'EMEA'
}
},
{
'path': 'events/dt=2026-03-02/region=APAC',
'values': {
'dt': '2026-03-02',
'region': 'APAC'
}
},
{
'path': 'events/dt=2026-03-05/region=NA',
'values': {
'dt': '2026-03-05',
'region': 'NA'
}
},
{
'path': 'events/legacy',
'values': {}
}
]Argument 2
[] (empty list)
Returns
{
'scan': [
'events/dt=2026-03-01/region=EMEA',
'events/dt=2026-03-02/region=APAC',
'events/dt=2026-03-02/region=EMEA',
'events/dt=2026-03-05/region=NA',
'events/legacy'
],
'skipped': [],
'unpruned_filters': []
}no partitions
An empty table scans nothing, and every filter is reported as unpruned.
Input
Argument 1
[] (empty list)
Argument 2
[
{
'column': 'dt',
'op': '>=',
'value': '2026-03-02'
},
{
'column': 'region',
'op': 'in',
'value': [
'EMEA',
'APAC'
]
},
{
'column': 'user_id',
'op': '=',
'value': 'u1'
}
]Returns
{
'scan': [],
'skipped': [],
'unpruned_filters': [
'dt',
'region',
'user_id'
]
}Constraints
unpruned_filters when no partition has it at all.=, !=, in, >=, <=, > and <. Compare as text when one side is a string and the other is not, so a comparison never raises.scan sorted by path, skipped sorted by path, and unpruned_filters sorted by column.Worked example
The filter dt >= 2026-03-02 prunes the March 1st partition, and region in (EMEA, APAC) prunes the NA one. Three filters, two prunes — and the third filter, on user_id, prunes nothing at all, because user_id is not in the partition path. Treating a missing partition column as a failed match would skip every partition and return an empty result set for a query that has matching rows.
events/legacy has no partition values. It predates the partitioning scheme, and nothing about the filters can prove it holds no matching rows — so it is read. That is the asymmetry at the centre of pruning: the planner may only skip what it can prove is irrelevant, and the absence of information is never a proof.
What this tests
Soundness as an explicit design goal. Every rule here is written so that uncertainty resolves towards reading more, because the cost of a false skip is a silently wrong answer and the cost of a false read is some IO.
plan_partition_scan(partitions: list[dict], filters: list[dict]) -> dictSubmit for review to find out what your query gets right, what it gets wrong, and how it compares with the best working query for this exercise.
This scenario runs a full workspace — editor, canvas and results side by side. It needs a laptop or desktop to be usable. Open this page on a bigger screen to start building.