Data Engineering for ML
ML Engineer path · lesson 66 of 80Watch a row-major read touch every column to return four of them, price the same file as CSV and Parquet, and see stateful stream processing reuse 29 days of work a batch job throws away every night.
| Format | Binary / text | Human-readable | Example uses |
|---|---|---|---|
| JSON | Text | Yes | Everywhere |
| CSV | Text | Yes | Everywhere |
| Parquet | Binary | No | Hadoop, Amazon Redshift |
| Avro | Binary primary | No | Hadoop |
| Protobuf | Binary primary | No | Google, TensorFlow (TFRecord) |
| Pickle | Binary | No | Python, PyTorch serialization |
1000000 as text takes 7 characters = 7 bytes; as an int32 it takes 32 bits = 4 bytes. The book's worked case: interviews.csv, 17,654 rows × 10 columns, went from 14 MB as CSV to 6 MB as Parquet. AWS reports Parquet is up to 2× faster to unload and consumes up to 6× less storage in S3 than text formats.0.12345678901232323 arbitrarily rounded to 0.12345678901. For a feature store that is silent data corruption, and it will not show up until a model trained on the rounded values behaves slightly differently from one trained on the originals.Key insight
Modern computers process sequential data far more efficiently than nonsequential data, which is the whole reason layout matters. The choice is not about the file extension — it is a prediction about how the data will be read, made at the moment you write it.
Row-major or column-major?
Sort each trait into the storage layout it describes.
Tap a piece, then tap where it goes — or drag it. Tap the tray to take one back.
Row-major
Drop items hereColumn-major
Drop items hereTest your knowledge
CSV is row-major, which means consecutive elements in a row are:
The short version
A filing cabinet versus a card index. If you usually want everything about one person, file by person. If you usually want one field about everyone, file by field. Choose wrong and every query walks past ninety-nine things it did not want.
In more depth
Data Engineering for ML
Row-major vs column-major
CSV is row-major (consecutive elements in a row are adjacent in memory); Parquet is column-major. Modern computers process sequential data far more efficiently than nonsequential data.
Text vs binary
1000000 as text = 7 characters = 7 bytes; as int32 = 4 bytes. interviews.csv (17,654 × 10) went from 14 MB as CSV to 6 MB as Parquet. AWS: Parquet is up to 2× faster to unload and 6× less storage in S3. CSV also serialises floats poorly — 0.12345678901232323 → "0.12345678901".
Structured vs unstructured
"Structured data means that the code that writes the data has to assume the structure. Unstructured data means that the code that reads the data has to assume the structure."
Data lakes store raw data before processing; data warehouses store data already processed. A lakehouse is the hybrid (Databricks, Snowflake). ETL transforms before loading; ELT stores raw first — fast arrival, but less attractive as data grows.
OLTP and OLAP are going stale
ACID: Atomicity (payment fails ⇒ no driver assigned) · Consistency · Isolation (two users can't book the same driver) · Durability. Non-ACID systems are sometimes called BASE.
Three reasons the terms are dated: the separation was a technology limitation that is closing (CockroachDB, Iceberg, DuckDB); storage and processing are now decoupled (BigQuery, Snowflake); and "online" is overloaded — it now means online (immediately available), nearline (made online quickly without human intervention), offline (requires human intervention).
Three modes of dataflow
"Request-driven architecture works well for systems that rely more on logic than on data. Event-driven architecture works better for systems that are data-heavy."
Batch vs stream
Batch features are static (a driver's rating); streaming features are dynamic (drivers available right now). Most problems need both.
Stream processing's real strength is stateful computation: for engagement over a 30-day trial, a batch job recomputes 30 days every day, while a stream job computes only the new data and joins it with the older computation. Engines: Flink, KSQL, Spark Streaming. "Batch is a special case of streaming."
Interview Questions
References & Further Reading
Love this visualization?
Sign up to track your progress, earn achievements, use the AI assistant, and access your personal learning dashboard.
100% free • No credit card required