Part 6: Remove query-parser entirely.
This commit is contained in:
parent
47441f56dc
commit
d4166cc67c
23 changed files with 3 additions and 142 deletions
|
@ -58,9 +58,6 @@ path = "query"
|
||||||
[dependencies.mentat_query_algebrizer]
|
[dependencies.mentat_query_algebrizer]
|
||||||
path = "query-algebrizer"
|
path = "query-algebrizer"
|
||||||
|
|
||||||
[dependencies.mentat_query_parser]
|
|
||||||
path = "query-parser"
|
|
||||||
|
|
||||||
[dependencies.mentat_query_projector]
|
[dependencies.mentat_query_projector]
|
||||||
path = "query-projector"
|
path = "query-projector"
|
||||||
|
|
||||||
|
|
10
README.md
10
README.md
|
@ -133,12 +133,12 @@ To run tests use:
|
||||||
# Run tests for everything.
|
# Run tests for everything.
|
||||||
cargo test --all
|
cargo test --all
|
||||||
|
|
||||||
# Run tests for just the query-parser folder (specify the crate, not the folder),
|
# Run tests for just the query-algebrizer folder (specify the crate, not the folder),
|
||||||
# printing debug output.
|
# printing debug output.
|
||||||
cargo test -p mentat_query_parser -- --nocapture
|
cargo test -p mentat_query_algebrizer -- --nocapture
|
||||||
````
|
````
|
||||||
|
|
||||||
For most `cargo` commands you can pass the `-p` argument to run the command just on that package. So, `cargo build -p mentat_query_parser` will build just the "query-parser" folder.
|
For most `cargo` commands you can pass the `-p` argument to run the command just on that package. So, `cargo build -p mentat_query_algebrizer` will build just the "query-algebrizer" folder.
|
||||||
|
|
||||||
## What are all of these crates?
|
## What are all of these crates?
|
||||||
|
|
||||||
|
@ -189,10 +189,6 @@ Mentat has two main inputs: reads (queries) and writes (transacts). Just as `men
|
||||||
|
|
||||||
### Query processing
|
### Query processing
|
||||||
|
|
||||||
#### `mentat_query_parser`
|
|
||||||
|
|
||||||
This is a `combine` parser that uses `mentat_parser_utils` and `mentat_query` to turn a stream of EDN values into a more usable representation of a query.
|
|
||||||
|
|
||||||
#### `mentat_query_algebrizer`
|
#### `mentat_query_algebrizer`
|
||||||
|
|
||||||
This is the biggest piece of the query engine. It takes a parsed query, which at this point is _independent of a database_, and combines it with the current state of the schema and data. This involves translating keywords into attributes, abstract values into concrete values with a known type, and producing an `AlgebraicQuery`, which is a representation of how a query's Datalog semantics can be satisfied as SQL table joins and constraints over Mentat's SQL schema. An algebrized query is tightly coupled with both the disk schema and the vocabulary present in the store when the work is done.
|
This is the biggest piece of the query engine. It takes a parsed query, which at this point is _independent of a database_, and combines it with the current state of the schema and data. This involves translating keywords into attributes, abstract values into concrete values with a known type, and producing an `AlgebraicQuery`, which is a representation of how a query's Datalog semantics can be satisfied as SQL table joins and constraints over Mentat's SQL schema. An algebrized query is tightly coupled with both the disk schema and the vocabulary present in the store when the work is done.
|
||||||
|
|
|
@ -12,9 +12,5 @@ path = "../core"
|
||||||
[dependencies.mentat_query]
|
[dependencies.mentat_query]
|
||||||
path = "../query"
|
path = "../query"
|
||||||
|
|
||||||
# Only for tests.
|
|
||||||
[dev-dependencies.mentat_query_parser]
|
|
||||||
path = "../query-parser"
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
itertools = "0.7"
|
itertools = "0.7"
|
||||||
|
|
|
@ -86,8 +86,6 @@ impl ConjoiningClauses {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod testing {
|
mod testing {
|
||||||
extern crate mentat_query_parser;
|
|
||||||
|
|
||||||
use std::collections::BTreeSet;
|
use std::collections::BTreeSet;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
|
@ -751,8 +751,6 @@ fn union_types(into: &mut BTreeMap<Variable, ValueTypeSet>,
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod testing {
|
mod testing {
|
||||||
extern crate mentat_query_parser;
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
use mentat_core::{
|
use mentat_core::{
|
||||||
|
|
|
@ -651,8 +651,6 @@ impl ConjoiningClauses {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod testing {
|
mod testing {
|
||||||
extern crate mentat_query_parser;
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
|
@ -96,7 +96,6 @@ pub(crate) fn validate_not_join(not_join: &NotJoin) -> Result<()> {
|
||||||
mod tests {
|
mod tests {
|
||||||
extern crate mentat_core;
|
extern crate mentat_core;
|
||||||
extern crate mentat_query;
|
extern crate mentat_query;
|
||||||
extern crate mentat_query_parser;
|
|
||||||
|
|
||||||
use self::mentat_query::{
|
use self::mentat_query::{
|
||||||
Keyword,
|
Keyword,
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
extern crate mentat_core;
|
extern crate mentat_core;
|
||||||
extern crate mentat_query;
|
extern crate mentat_query;
|
||||||
extern crate mentat_query_algebrizer;
|
extern crate mentat_query_algebrizer;
|
||||||
extern crate mentat_query_parser;
|
|
||||||
|
|
||||||
mod utils;
|
mod utils;
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
extern crate mentat_core;
|
extern crate mentat_core;
|
||||||
extern crate mentat_query;
|
extern crate mentat_query;
|
||||||
extern crate mentat_query_algebrizer;
|
extern crate mentat_query_algebrizer;
|
||||||
extern crate mentat_query_parser;
|
|
||||||
|
|
||||||
mod utils;
|
mod utils;
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
extern crate mentat_core;
|
extern crate mentat_core;
|
||||||
extern crate mentat_query;
|
extern crate mentat_query;
|
||||||
extern crate mentat_query_algebrizer;
|
extern crate mentat_query_algebrizer;
|
||||||
extern crate mentat_query_parser;
|
|
||||||
|
|
||||||
mod utils;
|
mod utils;
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
extern crate mentat_core;
|
extern crate mentat_core;
|
||||||
extern crate mentat_query;
|
extern crate mentat_query;
|
||||||
extern crate mentat_query_algebrizer;
|
extern crate mentat_query_algebrizer;
|
||||||
extern crate mentat_query_parser;
|
|
||||||
|
|
||||||
mod utils;
|
mod utils;
|
||||||
|
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
[package]
|
|
||||||
name = "mentat_query_parser"
|
|
||||||
version = "0.0.1"
|
|
||||||
workspace = ".."
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
combine = "2.3.2"
|
|
||||||
error-chain = { git = "https://github.com/rnewman/error-chain", branch = "rnewman/sync" }
|
|
||||||
|
|
||||||
[dependencies.edn]
|
|
||||||
path = "../edn"
|
|
||||||
|
|
||||||
[dependencies.mentat_parser_utils]
|
|
||||||
path = "../parser-utils"
|
|
||||||
|
|
||||||
[dependencies.mentat_query]
|
|
||||||
path = "../query"
|
|
|
@ -1,2 +0,0 @@
|
||||||
See <https://github.com/mozilla/mentat/wiki/Querying> for a description of
|
|
||||||
what's going on in this crate, as well as `query` and `query-executor`.
|
|
|
@ -1,49 +0,0 @@
|
||||||
// Copyright 2018 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.
|
|
||||||
|
|
||||||
#![allow(dead_code)]
|
|
||||||
|
|
||||||
use edn;
|
|
||||||
|
|
||||||
use mentat_parser_utils::{
|
|
||||||
ValueParseError,
|
|
||||||
};
|
|
||||||
|
|
||||||
error_chain! {
|
|
||||||
types {
|
|
||||||
Error, ErrorKind, ResultExt, Result;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreign_links {
|
|
||||||
EdnParseError(edn::parse::ParseError);
|
|
||||||
}
|
|
||||||
|
|
||||||
errors {
|
|
||||||
DuplicateVariableError {
|
|
||||||
description("duplicate variable")
|
|
||||||
display("duplicates in variable list")
|
|
||||||
}
|
|
||||||
|
|
||||||
FindParseError(e: ValueParseError) {
|
|
||||||
description(":find parse error")
|
|
||||||
display(":find parse error")
|
|
||||||
}
|
|
||||||
|
|
||||||
UnknownLimitVar(var: edn::PlainSymbol) {
|
|
||||||
description("limit var not present in :in")
|
|
||||||
display("limit var {} not present in :in", var)
|
|
||||||
}
|
|
||||||
|
|
||||||
InvalidLimit(val: edn::Value) {
|
|
||||||
description("limit value not valid")
|
|
||||||
display("expected natural number, got {}", val)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
// 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.
|
|
||||||
|
|
||||||
#![allow(unused_imports)]
|
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
extern crate error_chain;
|
|
||||||
|
|
||||||
extern crate edn;
|
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
extern crate mentat_parser_utils;
|
|
||||||
|
|
||||||
mod errors;
|
|
||||||
|
|
||||||
pub use errors::{
|
|
||||||
Error,
|
|
||||||
ErrorKind,
|
|
||||||
Result,
|
|
||||||
ResultExt,
|
|
||||||
};
|
|
|
@ -29,10 +29,6 @@ path = "../query-algebrizer"
|
||||||
[dependencies.mentat_query_pull]
|
[dependencies.mentat_query_pull]
|
||||||
path = "../query-pull"
|
path = "../query-pull"
|
||||||
|
|
||||||
# Only for tests.
|
|
||||||
[dev-dependencies.mentat_query_parser]
|
|
||||||
path = "../query-parser"
|
|
||||||
|
|
||||||
[dependencies.mentat_query_sql]
|
[dependencies.mentat_query_sql]
|
||||||
path = "../query-sql"
|
path = "../query-sql"
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
extern crate mentat_core;
|
extern crate mentat_core;
|
||||||
extern crate mentat_query;
|
extern crate mentat_query;
|
||||||
extern crate mentat_query_algebrizer;
|
extern crate mentat_query_algebrizer;
|
||||||
extern crate mentat_query_parser;
|
|
||||||
extern crate mentat_query_projector;
|
extern crate mentat_query_projector;
|
||||||
|
|
||||||
use mentat_core::{
|
use mentat_core::{
|
||||||
|
|
|
@ -27,7 +27,3 @@ path = "../query-sql"
|
||||||
|
|
||||||
[dependencies.mentat_sql]
|
[dependencies.mentat_sql]
|
||||||
path = "../sql"
|
path = "../sql"
|
||||||
|
|
||||||
# Only for tests.
|
|
||||||
[dev-dependencies.mentat_query_parser]
|
|
||||||
path = "../query-parser"
|
|
||||||
|
|
|
@ -17,7 +17,3 @@ path = "../query"
|
||||||
|
|
||||||
[dependencies.mentat_query_algebrizer]
|
[dependencies.mentat_query_algebrizer]
|
||||||
path = "../query-algebrizer"
|
path = "../query-algebrizer"
|
||||||
|
|
||||||
# Only for tests.
|
|
||||||
[dev-dependencies.mentat_query_parser]
|
|
||||||
path = "../query-parser"
|
|
||||||
|
|
|
@ -18,10 +18,6 @@ path = "../query"
|
||||||
[dependencies.mentat_query_algebrizer]
|
[dependencies.mentat_query_algebrizer]
|
||||||
path = "../query-algebrizer"
|
path = "../query-algebrizer"
|
||||||
|
|
||||||
# Only for tests.
|
|
||||||
[dev-dependencies.mentat_query_parser]
|
|
||||||
path = "../query-parser"
|
|
||||||
|
|
||||||
[dependencies.mentat_query_projector]
|
[dependencies.mentat_query_projector]
|
||||||
path = "../query-projector"
|
path = "../query-projector"
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
extern crate mentat_core;
|
extern crate mentat_core;
|
||||||
extern crate mentat_query;
|
extern crate mentat_query;
|
||||||
extern crate mentat_query_algebrizer;
|
extern crate mentat_query_algebrizer;
|
||||||
extern crate mentat_query_parser;
|
|
||||||
extern crate mentat_query_projector;
|
extern crate mentat_query_projector;
|
||||||
extern crate mentat_query_translator;
|
extern crate mentat_query_translator;
|
||||||
extern crate mentat_sql;
|
extern crate mentat_sql;
|
||||||
|
|
|
@ -24,7 +24,6 @@ use mentat_core::{
|
||||||
use mentat_db;
|
use mentat_db;
|
||||||
use mentat_query;
|
use mentat_query;
|
||||||
use mentat_query_algebrizer;
|
use mentat_query_algebrizer;
|
||||||
use mentat_query_parser;
|
|
||||||
use mentat_query_projector;
|
use mentat_query_projector;
|
||||||
use mentat_query_pull;
|
use mentat_query_pull;
|
||||||
use mentat_query_translator;
|
use mentat_query_translator;
|
||||||
|
@ -46,7 +45,6 @@ error_chain! {
|
||||||
links {
|
links {
|
||||||
DbError(mentat_db::Error, mentat_db::ErrorKind);
|
DbError(mentat_db::Error, mentat_db::ErrorKind);
|
||||||
QueryError(mentat_query_algebrizer::Error, mentat_query_algebrizer::ErrorKind); // Let's not leak the term 'algebrizer'.
|
QueryError(mentat_query_algebrizer::Error, mentat_query_algebrizer::ErrorKind); // Let's not leak the term 'algebrizer'.
|
||||||
QueryParseError(mentat_query_parser::Error, mentat_query_parser::ErrorKind);
|
|
||||||
ProjectorError(mentat_query_projector::errors::Error, mentat_query_projector::errors::ErrorKind);
|
ProjectorError(mentat_query_projector::errors::Error, mentat_query_projector::errors::ErrorKind);
|
||||||
PullError(mentat_query_pull::errors::Error, mentat_query_pull::errors::ErrorKind);
|
PullError(mentat_query_pull::errors::Error, mentat_query_pull::errors::ErrorKind);
|
||||||
TranslatorError(mentat_query_translator::Error, mentat_query_translator::ErrorKind);
|
TranslatorError(mentat_query_translator::Error, mentat_query_translator::ErrorKind);
|
||||||
|
|
|
@ -25,7 +25,6 @@ extern crate mentat_core;
|
||||||
extern crate mentat_db;
|
extern crate mentat_db;
|
||||||
extern crate mentat_query;
|
extern crate mentat_query;
|
||||||
extern crate mentat_query_algebrizer;
|
extern crate mentat_query_algebrizer;
|
||||||
extern crate mentat_query_parser;
|
|
||||||
extern crate mentat_query_projector;
|
extern crate mentat_query_projector;
|
||||||
extern crate mentat_query_pull;
|
extern crate mentat_query_pull;
|
||||||
extern crate mentat_query_translator;
|
extern crate mentat_query_translator;
|
||||||
|
|
Loading…
Reference in a new issue