From 42f03f55a2aae2076ff9a03543dd3ce718303920 Mon Sep 17 00:00:00 2001 From: Richard Newman Date: Fri, 3 Feb 2017 15:52:02 -0800 Subject: [PATCH] Stub out query algebrizer. --- Cargo.toml | 3 +++ query-algebrizer/Cargo.toml | 7 +++++++ query-algebrizer/README.md | 5 +++++ query-algebrizer/src/lib.rs | 24 ++++++++++++++++++++++++ src/lib.rs | 1 + 5 files changed, 40 insertions(+) create mode 100644 query-algebrizer/Cargo.toml create mode 100644 query-algebrizer/README.md create mode 100644 query-algebrizer/src/lib.rs diff --git a/Cargo.toml b/Cargo.toml index 12157818..e2e5e87a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,5 +34,8 @@ path = "query" [dependencies.mentat_query_parser] path = "query-parser" +[dependencies.mentat_query_algebrizer] +path = "query-algebrizer" + [dependencies.mentat_tx_parser] path = "tx-parser" diff --git a/query-algebrizer/Cargo.toml b/query-algebrizer/Cargo.toml new file mode 100644 index 00000000..7c976900 --- /dev/null +++ b/query-algebrizer/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "mentat_query_algebrizer" +version = "0.0.1" + +[dependencies] +[dependencies.mentat_query] + path = "../query" diff --git a/query-algebrizer/README.md b/query-algebrizer/README.md new file mode 100644 index 00000000..ca5f7496 --- /dev/null +++ b/query-algebrizer/README.md @@ -0,0 +1,5 @@ +This crate turns a parsed query, as defined by the `query` crate and produced by the `query-parser` crate, into an *algebrized tree*, also called a *query processor tree*. + +This is something of a wooly definition: a query algebrizer in a traditional relational database is the component that combines the schema — including column type constraints — with the query, resolving names, and that sort of thing. Much of that work is unnecessary in our model; for example, we don't need to resolve column aliases, deal with table names, or that sort of thing. But the similarity is strong enough to give us the name of this crate. + +The result of this process is traditionally handed to the *query optimizer* to yield an *execution plan*. In our case the execution plan is deterministically derived from the algebrized tree, and the real optimization (such as it is) takes place within the underlying SQLite database. diff --git a/query-algebrizer/src/lib.rs b/query-algebrizer/src/lib.rs new file mode 100644 index 00000000..d8342df2 --- /dev/null +++ b/query-algebrizer/src/lib.rs @@ -0,0 +1,24 @@ +// Copyright 2016 Mozilla +// +// Licensed under the Apache License, Version 2.0 (the "License"); you may not use +// this file except in compliance with the License. You may obtain a copy of the +// License at http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software distributed +// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, either express or implied. See the License for the +// specific language governing permissions and limitations under the License. + +extern crate mentat_query; +use mentat_query::{ + FindQuery, + SrcVar, + Variable, + WhereClause, +}; + +pub struct AlgebrizedQuery { +} + +pub fn algebrize(parsed: FindQuery) -> AlgebrizedQuery { + AlgebrizedQuery {} +} diff --git a/src/lib.rs b/src/lib.rs index 643adf6c..681aabaa 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -20,6 +20,7 @@ extern crate mentat_core; extern crate mentat_db; extern crate mentat_query; extern crate mentat_query_parser; +extern crate mentat_query_algebrizer; use rusqlite::Connection;