Google announces Logica: organizing your data queries, making them universally reusable and fun

You can read more about it at the Google Open Source blog post, Logica: organizing your data queries, making them universally reusable and fun.

They advocate for datalog-like language they developed internally at Google.

The reason?

Good programming is about creating small, understandable, reusable pieces of logic that can be tested, given names, and organized into packages which can later be used to construct more useful pieces of logic. SQL resists this workflow. Although you can encapsulate certain repeated computations into views and functions, the syntax and support for these can vary among implementations, the notions of packages and imports are generally nonexistent, and higher-level constructions (e.g. passing a function to a function) are impossible.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.


What was so wrong with LINQ? Reading this "diagonally" I have not seen anything here that LINQ hasn't solved.

Basic boolean algebra manipulations are easier w/ Horn clauses

My first job out of college was helping to design a system for analyzing facts. Most of the system was a matter of building a fact database, and then finding correlations between facts , and then asking if the contrapositive was true.

This is surprisingly simple way to decompose a problem, and that system sold for tens of millions of dollars despite being a very simple program that effectively just manipulated Horn clauses. Every definite clause was transformed by a contrapositive into a goal clause, and that was the whole program.

In this way, you can build surprisingly powerful systems from very basic set of facts.

That said, I have no idea if Logica is actually good at generating SQL for BigQUery. That would be an interesting blog post, and perhaps we can get the authors of Logica to write a guest blog post about it.

Logica is a datalog subset that compiles to SQL?

"Logica is a language of Datalog family that can be compiled to StandardSQL."

From the little I could understand it looks like a bastard mix of Datalog, SQL and Python, with no obvious purpose. But I probably missed something.

Does it implelement the relational algebra? SQL tries, and falls short.

Recursion? Negation? So many questions.

The motivating goal

The motivating goal is pretty clear. The language allows the construction of reusable query libraries. Compilation to SQL allows it to be used in production systems.

I'm really hoping that the SQLite and Postgres back-ends come up to production quality.