σμimplied vol · KKmax(S−K,0)udβρᵢⱼfat tailsPnL · drawdownyield · TdSₜ = μSₜ dt + σSₜ dWₜC = S·N(d₁) − K·e⁻ʳᵀ·N(d₂)σₚ² = wᵀΣwd₁ = [ln(S/K) + (r + σ²⁄2)T] ⁄ σ√T∂V/∂t + ½σ²S²·∂²V/∂S² + rS·∂V/∂S − rV = 0Sharpe = (Rₚ − R_f) ⁄ σₚVaR₉₉ = μ − 2.33σρ = Cov(X,Y) ⁄ σₓσᵧE[Rₚ] = Σ wᵢ·E[Rᵢ]φ(x) = e^(−x²/2) ⁄ √2πE[Rᵢ] = R_f + βᵢ(E[Rₘ] − R_f)dXₜ = θ(μ − Xₜ)dt + σ dWₜσ²ₜ = ω + α·ε²ₜ₋₁ + β·σ²ₜ₋₁C − P = S − K·e⁻ʳᵀΔ = ∂V/∂S Γ = ∂²V/∂S²p = (e^(rΔt) − d) ⁄ (u − d)rₜ = ln(Pₜ ⁄ Pₜ₋₁)E[Xₜ₊₁ | ℱₜ] = Xₜf* = (bp − q) ⁄ bz = (x − μ) ⁄ σP(N=k) = λᵏe^(−λ) ⁄ k!Θ = −∂V/∂Tν = S·φ(d₁)·√Tmin wᵀΣw s.t. wᵀμ = μ*∫Σ∂∞λ
uantCraft AcademyRoadmapsSkills
Ctrl K
AO
+1.2k Learners
LoginJoin ↗
RoadmapsSkills
AO
+1.2k Learners
Login
  • English
  • Français
  • Español
  • العربية
  • Português
  • Deutsch
  • 日本語
  • 中文
σμimplied vol · KKmax(S−K,0)udβρᵢⱼfat tailsPnL · drawdownyield · TdSₜ = μSₜ dt + σSₜ dWₜC = S·N(d₁) − K·e⁻ʳᵀ·N(d₂)σₚ² = wᵀΣwd₁ = [ln(S/K) + (r + σ²⁄2)T] ⁄ σ√T∂V/∂t + ½σ²S²·∂²V/∂S² + rS·∂V/∂S − rV = 0Sharpe = (Rₚ − R_f) ⁄ σₚVaR₉₉ = μ − 2.33σρ = Cov(X,Y) ⁄ σₓσᵧE[Rₚ] = Σ wᵢ·E[Rᵢ]φ(x) = e^(−x²/2) ⁄ √2πE[Rᵢ] = R_f + βᵢ(E[Rₘ] − R_f)dXₜ = θ(μ − Xₜ)dt + σ dWₜσ²ₜ = ω + α·ε²ₜ₋₁ + β·σ²ₜ₋₁C − P = S − K·e⁻ʳᵀΔ = ∂V/∂S Γ = ∂²V/∂S²p = (e^(rΔt) − d) ⁄ (u − d)rₜ = ln(Pₜ ⁄ Pₜ₋₁)E[Xₜ₊₁ | ℱₜ] = Xₜf* = (bp − q) ⁄ bz = (x − μ) ⁄ σP(N=k) = λᵏe^(−λ) ⁄ k!Θ = −∂V/∂Tν = S·φ(d₁)·√Tmin wᵀΣw s.t. wᵀμ = μ*∫Σ∂∞λ
uantCraft AcademyRoadmapsSkills
Ctrl K
AO
+1.2k Learners
LoginJoin ↗
RoadmapsSkills
AO
+1.2k Learners
Login
  • English
  • Français
  • Español
  • العربية
  • Português
  • Deutsch
  • 日本語
  • 中文
Parquet skill›Module 2 · Reading less›Topic 2.1·~50 minIntermediate

Predicate pushdown and column pruning

Skill positionModule 2 of 3 · Topic 1 of 2
2.1 Predicate pushdown and column pruning
—Lab score— / 100Total XP—Streak—
Lecture0% read

3 min readCode examples: 3

  1. 01The idea in plain words
  2. 02Let the reader do it
  3. 03The same decision by hand
  4. 04It only works on sorted data
  5. 05What the tasks ask

The fastest byte to read is the one you never read. Column pruning drops the columns a query does not name; predicate pushdown drops the row groups a filter cannot match. Together they let a query over decades of prices touch a few percent of the file, and the footer is all it needs to decide.

01

The idea in plain words

Where we are. Topic 1 pruned columns, topic 2 introduced row groups and topic 3 compressed them. This topic puts the row group's statistics to work. Partitioned folders (next topic) apply the same idea one level up, skipping whole files instead of row groups.

DefinitionPredicate pushdown

Handing a filter down to the file reader so it can use the stored minimum and maximum of each row group to skip groups that cannot match, instead of reading everything and filtering afterwards.

02

Let the reader do it

filters=[("date", ">=", since)] on pq.read_table is the one-line version. The file below is sorted by date and cut into row groups of 2,000 rows, so each group covers a narrow slice of time and the recent ones are the only ones that can hold 2026. Filtering after the read (table.filter(...)) gives the same rows but fetches every group first.

main.pyPython
# A file sorted by date, in row groups of 2,000 rows, then a filtered readby_date = table.sort_by("date")pq.write_table(by_date, "by_date.parquet", row_group_size=2000)print("row groups:", pq.ParquetFile("by_date.parquet").metadata.num_row_groups)print("rows since 2026-01-01:", read_since("by_date.parquet", date(2026, 1, 1)).num_rows)
row groups: 17
rows since 2026-01-01: 800
03

The same decision by hand

Doing it yourself shows what the reader does. For each row group, read the minimum and maximum of the column from the footer. If the maximum is below your range or the minimum above it, no row in that group can match and it is dropped. Otherwise it is kept, but it may still hold rows that do not match, so the rows inside must be filtered afterwards.

main.pyPython
# Which row groups can hold 2020, how many rows that is, and the exact rows after reading only thoselow, high = date(2020, 1, 1), date(2020, 12, 31)print("groups to read:", groups_to_read("by_date.parquet", "date", low, high))print("rows scanned:", rows_scanned("by_date.parquet", "date", low, high), "of", by_date.num_rows)print("rows in 2020:", pushdown_table("by_date.parquet", "date", low, high).num_rows)
groups to read: [12, 13]
rows scanned: 4000 of 33493
rows in 2020: 1265
04

It only works on sorted data

The statistics only help when row groups cover narrow ranges. The original table lists one stock after another, so every row group spans a different stock's whole history and every group's range includes 2020. Same data, same filter, far less to skip. Sorting before writing is the cheapest speed-up Parquet has.

main.pyPython
# The same 2020 filter on a file written in the original order, one stock after anotherpq.write_table(table, "by_stock.parquet", row_group_size=2000)print("sorted by date :", rows_scanned("by_date.parquet", "date", low, high), "rows scanned")print("sorted by stock:", rows_scanned("by_stock.parquet", "date", low, high), "rows scanned of", table.num_rows)
sorted by date : 4000 rows scanned
sorted by stock: 19493 rows scanned of 33493
Statistics skip, they do not select

A kept row group only means it might hold a match. The reader still has to look at the rows inside, which is why pushdown_table filters after reading the kept groups. Never use the statistics alone as the answer: a group whose range overlaps yours can be entirely outside it, like a gap between two dates.

05

What the tasks ask

  1. 1
    `read_since`pq.read_table(path, filters=[("date", ">=", since)]); no .filter afterwards.
  2. 2
    `groups_to_read` and `rows_scanned`Keep a group when stats.min <= high and stats.max >= low (or it has no statistics); add up its num_rows.
  3. 3
    `pushdown_table`ParquetFile.read_row_groups(groups), then filter the rows with pc.and_(pc.greater_equal(...), pc.less_equal(...)).

Key takeaways

  • The footer decides what to read Min and max per row group let a reader drop whole blocks unread.
  • Sort before you write Narrow ranges per group are what make the statistics useful.
  • Keep, then filter A kept group may still hold non-matching rows. Next: skipping whole files with partitions.
Quick check
A file holds one stock after another, each in date order, and is split into row groups. A query asks for dates in 2020. Why can the reader skip so few row groups?
Pick an answer.

Lab · what's graded

4 tasks · 100 pts
  • Let the reader filter: read_since25 pts
  • Which groups can match: groups_to_read25 pts
  • Count the rows still scanned: rows_scanned25 pts
  • Read only those groups: pushdown_table25 pts
Explorer · lab-4-1
▾ lab-4-1
▾ data
…
bash · in-browser
learner@quantcraft:~/lab-4-1$
Python not loaded yetPythonLn 1, Col 1Spaces: 4UTF-8

Reset this topic?

Everything in lab-4-1 goes back to the starter files and the terminal is cleared. Your current solution will be lost — this can't be undone.

Will be reset
  • main.py → starter code
  • Terminal history and test output
  • Unsubmitted changes
Will be kept
  • Best lab score
  • Your XP and streak
  • Lecture progress and notes