Skip to content

Commit

Permalink
Clean-up and add changelog entries
Browse files Browse the repository at this point in the history
  • Loading branch information
jpschorr committed Mar 6, 2024
1 parent 2fcb1ad commit 4918820
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Changed
- Adds quotes to the attributes of PartiQL tuple's debug output so it can be read and transformed using Kotlin `partiql-cli`
- Changes the interface to `EvalPlan` to accept an `EvalContext`

### Added
- Add `partiql-extension-visualize` for visualizing AST and logical plan
- Add a `SessionContext` containing both a system-level and a user-level context object usable by expression evaluation

### Fixed
- Fixed `ORDER BY`'s ability to see into projection aliases
Expand Down
8 changes: 4 additions & 4 deletions partiql-eval/src/eval/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use petgraph::graph::NodeIndex;
use crate::error::{EvalErr, EvaluationError};
use partiql_catalog::context::{Bindings, SessionContext, SystemContext};
use petgraph::visit::EdgeRef;
use unicase::UniCase;

use crate::eval::evaluable::{EvalType, Evaluable};

Expand Down Expand Up @@ -66,8 +67,6 @@ impl EvalPlan {
/// Executes the plan while mutating its state by changing the inputs and outputs of plan
/// operators.
pub fn execute_mut<'c>(&mut self, ctx: &'c dyn EvalContext<'c>) -> Result<Evaluated, EvalErr> {
//let ctx: Box<dyn EvalContext> = Box::new(BasicContext::new(bindings));

// We are only interested in DAGs that can be used as execution plans, which leads to the
// following definition.
// A DAG is a directed, cycle-free graph G = (V, E) with a denoted root node v0 ∈ V such
Expand Down Expand Up @@ -157,7 +156,7 @@ pub struct BasicContext<'a> {
pub bindings: MapBindings<Value>,

pub sys: SystemContext,
pub user: HashMap<String, &'a (dyn Any)>, // TODO: Unicase the keys?
pub user: HashMap<UniCase<String>, &'a (dyn Any)>,

pub errors: RefCell<Vec<EvaluationError>>,
}
Expand All @@ -182,7 +181,8 @@ impl<'a> SessionContext<'a> for BasicContext<'a> {
}

fn user_context(&self, name: &str) -> Option<&(dyn Any)> {
self.user.get(name).copied()
let key = name.into();
self.user.get(&key).copied()
}
}
impl<'a> EvalContext<'a> for BasicContext<'a> {
Expand Down
2 changes: 1 addition & 1 deletion partiql/tests/user_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ pub(crate) fn evaluate(
};
let mut ctx = BasicContext::new(bindings, sys);
for (k, v) in ctx_vals {
ctx.user.insert(k.to_string(), *v);
ctx.user.insert(k.as_str().into(), *v);
}
if let Ok(out) = plan.execute_mut(&ctx) {
out.result
Expand Down

0 comments on commit 4918820

Please sign in to comment.