σμ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
  • 日本語
  • 中文
Apache Arrow skill›Module 3 · Between processes›Topic 3.1·~45 minAdvanced

Flight and ADBC concepts

Skill positionModule 3 of 3 · Topic 1 of 2
3.1 Flight and ADBC concepts
—Lab score— / 100Total XP—Streak—
Lecture0% read

3 min readCode examples: 3

  1. 01The idea in plain words
  2. 02Review the config before the first call
  3. 03Endpoints and tickets
  4. 04ADBC: bind parameters, never paste them
  5. 05What the tasks ask

Sharing memory works inside one machine. Between machines and processes the data has to travel, and a protocol that turns columns into rows and back for the trip throws away what Arrow bought you. Arrow Flight and ADBC are the two answers: Flight streams record batches over gRPC, and ADBC gives database access that returns Arrow instead of rows. This topic is about the decisions around them, which is where real pipelines go wrong.

01

The idea in plain words

Where we are. Topic 6 wrote batches to files and streams. A Flight server sends the same streams over a network. Nothing here needs a server: each function models one decision (is this config safe, how to split a dataset, how to answer a ticket, how to bind a parameter), so you can reason about them and check them without any infrastructure. The capstone then builds a pipeline from the pieces of the whole skill.

DefinitionArrow Flight

A protocol on gRPC for moving Arrow record batches between services. A client asks for a dataset and receives endpoints, each with locations and a ticket; it then fetches the tickets, in parallel if it wants, as streams of batches that never leave columnar form.

02

Review the config before the first call

Most Flight incidents are configuration, not code. A grpc:// location sends data, and any token, in clear text. A TLS connection with no token lets anyone in. A batch size of five million rows can exhaust memory on the client; one of ten rows spends its time on headers. No timeout means one stuck server hangs the pipeline. review_flight_config turns these rules of thumb into a checklist that returns codes you can act on or fail a deployment on.

main.pyPython
# Two configs: an unsafe one and a sound oneunsafe = {"location": "grpc://10.0.0.5:8815", "token": "s3cret", "max_batch_rows": 5_000_000, "timeout_s": None}sound = {"location": "grpc+tls://ticks.example:8815", "token": "s3cret", "max_batch_rows": 65_536, "timeout_s": 30}print("unsafe:", review_flight_config(unsafe))print("sound :", review_flight_config(sound))
unsafe: ['huge-batches', 'insecure-transport', 'no-timeout', 'token-in-clear']
sound : []
03

Endpoints and tickets

Splitting a dataset across endpoints is how Flight scales: ten servers each hold a range, and the client fetches all ten at once. plan_endpoints is the server's GetFlightInfo answer, a list of (location, start, stop). do_get is DoGet for one ticket: it slices that range and streams it as record batches. Fetching every ticket of the plan returns each row exactly once, in any order the client chooses.

main.pyPython
# Split the bars across two nodes, then serve one ticket as batches of at most 4,000 rowsplan = plan_endpoints(table.num_rows, 10000, ["node-a:8815", "node-b:8815"])for endpoint in plan:    print(endpoint)batches = do_get(table, plan[1][1:], 4000)print("batches for the second ticket:", [b.num_rows for b in batches])print("all tickets together:", sum(sum(b.num_rows for b in do_get(table, (s, e), 4000)) for _, s, e in plan), "rows of", table.num_rows)
('node-a:8815', 0, 10000)
('node-b:8815', 10000, 20000)
('node-a:8815', 20000, 30000)
('node-b:8815', 30000, 33493)
batches for the second ticket: [3397, 4000, 2603]
all tickets together: 33493 rows of 33493
04

ADBC: bind parameters, never paste them

An ADBC statement is SQL text with ? placeholders plus a separate list of values. The driver sends them apart, so a value can never be read as SQL, which is the definition of safe against injection, and the database can reuse its plan for the same text. bind_params checks the one thing a client can check before sending: the number of placeholders, ignoring question marks inside quoted text, equals the number of values. A hostile string stays a value.

main.pyPython
# A statement with two placeholders, one with a '?' inside text, and a count mismatchprint(bind_params("SELECT * FROM bars WHERE symbol = ? AND close > ?", ["KO", 50.0]))print(bind_params("SELECT 'why?' AS q, close FROM bars WHERE symbol = ?", ["JPM"]))print(bind_params("SELECT * FROM bars WHERE symbol = ?", ["x'; DROP TABLE bars; --"]))try:    bind_params("SELECT * FROM bars WHERE symbol = ? AND close > ?", ["KO"])except ValueError as error:    print("ValueError:", error)
('SELECT * FROM bars WHERE symbol = ? AND close > ?', ('KO', 50.0))
("SELECT 'why?' AS q, close FROM bars WHERE symbol = ?", ('JPM',))
('SELECT * FROM bars WHERE symbol = ?', ("x'; DROP TABLE bars; --",))
ValueError: 2 placeholders but 1 parameters
What a real Flight call needs on top

A real client also handles retries, server-side authentication, cancellation and back-pressure when the consumer is slower than the stream. The models here keep the decisions testable; pyarrow.flight (a desktop library, not in the browser) and the ADBC drivers carry them out over a network.

05

What the tasks ask

  1. 1
    `review_flight_config`Take the scheme from the location; collect the codes in a set and return it sorted.
  2. 2
    `plan_endpoints` and `do_get`range(0, num_rows, rows_per_endpoint) with locations[k % len(locations)]; table.slice(start, ...) then to_batches(max_chunksize=batch_rows).
  3. 3
    `bind_params`Walk the characters, tracking whether you are inside '...' or "..."; count ? outside quotes; raise ValueError if the count differs.

Key takeaways

  • Stay columnar over the wire Flight and ADBC move record batches without turning them into rows.
  • Split work with tickets Endpoints let many servers serve one dataset in parallel.
  • Bind, never paste Parameters travel apart from the SQL. Last: the capstone pipeline.
Quick check
Which statement is safe to send through an ADBC cursor?
Pick an answer.

Lab · what's graded

4 tasks · 100 pts
  • Review a client config: review_flight_config25 pts
  • Split into endpoints: plan_endpoints25 pts
  • Serve a ticket: do_get25 pts
  • Bind, do not paste: bind_params25 pts
Explorer · lab-8-1
▾ lab-8-1
▾ data
…
bash · in-browser
learner@quantcraft:~/lab-8-1$
Python not loaded yetPythonLn 1, Col 1Spaces: 4UTF-8

Reset this topic?

Everything in lab-8-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