Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Meta Engineering 6 min read Case study mediumAdept

Enabling static analysis of SQL queries at Meta

UPM (Unified Programming Model) is Meta's standalone library that parses SQL into a semantic tree, a typed intermediate representation decoupled from any single query engine, so infrastructure teams can build linters, query rewriters and lineage tools without reimplementing analysis per dialect. It acts as a pluggable SQL front end exposing one Presto-superset dialect across Presto, Spark and the in-house XStream, either feeding the tree directly to engines or rendering it back to a target dialect. User-defined semantic column types (e.g. TimestampMilliseconds, UserID) let the typechecker catch unit and ID-mismatch errors in UNIONs and JOINs before execution. A lineage tool consumes semantic trees from all recurring queries to build a warehouse-wide column-level lineage graph.

Assumes: SQLabstract syntax treesdata warehouses

Related posts

  • Composable data management at Meta

    Meta Engineering easyNovice

    Meta has been decomposing its many monolithic data engines (ETL, interactive, streaming, ML preprocessing) into reusable components: language frontend, IR, optimizer, execution library and runtime. Velox, its open-source engine- and dialect-agnostic execution library, is the centerpiece. It uses columnar/vectorized execution, compressed execution via encodings, lazy materialization and adaptive filter/join ordering, and has delivered 3-10x efficiency gains in Presto (Prestissimo) and about 3x in Spark via Gluten. To restore interoperability, Meta upstreamed StringView, ListView and Run-End-Encoding into Apache Arrow. Next steps are the Nimble file format for wide AI/ML tables and hardware-accelerated data systems.

  • Policy Zones: How Meta enforces purpose limitation at scale in batch processing systems

    Meta Engineering mediumAdept

    Meta's Policy Zones, part of its Privacy Aware Infrastructure, applies information flow control to enforce purpose limitation across an exabyte-scale data warehouse. Datasets and loggers carry Governable Data Annotations such as MESSAGING_DATA, and downstream data must be at least as restrictive as its sources. A SQL parser (UPM) turns queries from processors like Presto into semantic trees. A Policy Evaluation Service checks each flow and issues a cryptographically signed token that the Warehouse Permission Service validates at access time. Policy Zone Manager tooling handles label creep through reclassification, letting the system run across millions of datasets, tens of millions of daily flows and trillions of consent checks per hour.

  • Introducing Velox: An open source unified execution engine

    Meta Engineering hardMaster

    Velox is Meta's open source C++ execution engine that unifies the data-plane components (expression evaluation, aggregation, joins, sorting, I/O, resource management) shared by engines like Presto, Spark and PyTorch's TorchArrow. It takes an optimized plan as input and runs it on a single host. It uses an Arrow-compatible columnar vector layout with multiple encodings, vectorized expression evaluation with dictionary peeling and common subexpression elimination, and runtime optimizations such as dynamic filter pushdown and adaptive prefetching. Replacing Presto Java workers with the Velox-based Prestissimo gave up to an order of magnitude speedup on CPU-bound TPC-H queries and 6-7x average speedups on production interactive workloads. Spark integrates Velox through Intel's Gluten via JNI using Arrow and Substrait.

  • PostgREST v10: EXPLAIN and Improved Relationship Detection

    Supabase mediumAdept

    PostgREST v10 adds HTTP-level EXPLAIN support: requests with the `application/vnd.pgrst.plan` media type, or supabase-js's `explain()` transform, return the PostgreSQL execution plan for reads, writes and RPC, which helps verify that RLS policies are applied and gives you the pg_stat_statements query identifier. Relationship detection also improves. One-to-one relationships are inferred from unique or primary keys on foreign keys, and "computed relationships" use inlinable SQL functions to define joins on views and materialized views that lack foreign keys. A breaking change now requires a join table's primary key to include both foreign key columns before it is detected as many-to-many. EXPLAIN is gated behind `db-plan-enabled` and intended only for development.

  • What’s New in ClickHouse 22.1

    ClickHouse mediumAdept

    ClickHouse 22.1 adds schema inference for table functions like url, s3, file and hdfs, detecting format and compression from the file extension and reading column types from self-describing formats such as Native, Parquet, Avro and ORC. For Parquet it uses range requests to fetch only the footer metadata. Other additions include experimental parallel query processing across replicas with dynamic work distribution, ZooKeeper-path-based cluster service discovery, and automatic sparse column serialization for mostly-default columns, selected from statistics gathered on insert and merge. The release also brings live CPU/memory usage in clickhouse-client, Hive and Azure Blob Storage integrations, and Cramér's V and Theil's U functions.

The quest for software engineering knowledge.

Look:
Layout: