Home / Companies / Cockroach Labs / Blog / Post Details
Content Deep Dive

Revisiting SQL typing in CockroachDB

Blog post from Cockroach Labs

Post Details
Company
Date Published
Author
Nathan VanBenschoten
Word Count
6,547
Company Posts That Month
4
Language
English
Hacker News Points
-
Summary

CockroachDB's journey to adopting a SQL interface led to unexpected challenges in language design, particularly in creating a robust and efficient type system for SQL queries. Initially, the team implemented a "bottom-up" type system, which was simple but revealed limitations such as lack of context consideration and rigid type handling, prompting a redesign. They explored the Hindley-Milner type system, known for its generality and efficiency, but ultimately found it unnecessary due to SQL's unique client-server architecture and the dynamic nature of database schemas. Instead, CockroachDB developed a new system named "Summer," which uses a bottom-to-top approach with bi-directional type inference, allowing the context to influence type determination. This system avoids implicit type coercions, focuses on exact arithmetic for constant literals, and enhances flexibility without sacrificing clarity. Summer's design supports efficient query optimization and performance, aligning with CockroachDB’s goal of creating a more intuitive and powerful SQL experience.

Trends Found in this Post
Trend Post Mentions Total Month Mentions Posts Companies MoM
Serverless 5 19 5 3 -83%