Skip to content

Commit

Permalink
Update for partiql-lang-rust v0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
jpschorr committed Jun 17, 2024
1 parent f8ee92a commit 40f3b07
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 59 deletions.
98 changes: 49 additions & 49 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ readme = "../README.md"
keywords = ["sql", "parser", "query", "compilers", "cli"]
categories = ["database", "compilers", "parser-implementations"]
exclude = [
"**/.git/**",
"**/.github/**",
"**/.travis.yml",
"**/.appveyor.yml",
"**/.git/**",
"**/.github/**",
"**/.travis.yml",
"**/.appveyor.yml",
]
edition = "2021"
version = "0.6.0"
version = "0.7.0"


[[bin]]
Expand All @@ -26,30 +26,30 @@ bench = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
partiql-parser = "0.6"
partiql-catalog = "0.6"
partiql-source-map = "0.6"
partiql-ast = "0.6"
partiql-ast-passes = "0.6"
partiql-logical-planner = "0.6"
partiql-logical = "0.6"
partiql-value = "0.6"
partiql-eval = "0.6"
partiql-extension-ion = "0.6"
partiql-extension-ion-functions = "0.6"
partiql-parser = "0.7"
partiql-catalog = "0.7"
partiql-source-map = "0.7"
partiql-ast = "0.7"
partiql-ast-passes = "0.7"
partiql-logical-planner = "0.7"
partiql-logical = "0.7"
partiql-value = "0.7"
partiql-eval = "0.7"
partiql-extension-ion = "0.7"
partiql-extension-ion-functions = "0.7"

once_cell = "1"

rustyline = "13"
rustyline = "14.0.0"
syntect = "5.*"
owo-colors = "4"
supports-color = "2"
supports-unicode = "2"
supports-hyperlinks = "2"
termbg = "0.4.*"
supports-color = "3"
supports-unicode = "3"
supports-hyperlinks = "3"
termbg = "0.5"
shellexpand = "3"

itertools = "0.12"
itertools = "0.13"

console = "0.15"
indicatif = "0.17"
Expand All @@ -58,58 +58,58 @@ dialoguer = "0.11"
comfy-table = "7"

directories = "5"
config = "0.13"
config = "0.14"

thiserror = "1.*"
miette = { version ="5.*", features = ["fancy"] }
miette = { version = "7", features = ["fancy"] }
clap = { version = "4.4", features = ["derive", "wrap_help", "help", "usage", "error-context"] }

uuid = {version="1.3", features=["v4"]}
uuid = { version = "1.3", features = ["v4"] }
tracing = "0.1"
tracing-subscriber = "0.3"
tracing-appender = "0.2"

ion-rs = "0.18"

# serde
serde = { version ="1.*", features = ["derive"], optional = true }
serde_json = { version ="1.*", optional = true }
serde = { version = "1.*", features = ["derive"], optional = true }
serde_json = { version = "1.*", optional = true }

### Dependencies for the `visualize` feature
viuer = { version = "0.7", features = ["sixel"], optional = true }
image = { version ="0.24.*", optional = true }
graphviz-sys = { version ="0.1.3", optional = true }
resvg = { version = "0.37", optional = true }
usvg = { version = "0.37", optional = true }
graphviz-sys = { version = "0.1.3", optional = true }
image = { version = "0.24", optional = true }
resvg = { version = "0.42", optional = true }
usvg = { version = "0.42", optional = true }
tiny-skia = { version = "0.11", optional = true }
strum = { version = "0.25", features = ["derive"], optional = true }
dot-writer = { version = "0.1.*", optional = true }
strum = { version = "0.26", features = ["derive"], optional = true }
dot-writer = { version = "0.1", optional = true }



[features]
default = []

serde = [
"dep:serde",
"dep:serde_json",
"partiql-parser/serde",
"partiql-source-map/serde",
"partiql-ast/serde",
"partiql-logical/serde",
"partiql-value/serde",
"dep:serde",
"dep:serde_json",
"partiql-parser/serde",
"partiql-source-map/serde",
"partiql-ast/serde",
"partiql-logical/serde",
"partiql-value/serde",
]

visualize = [
"serde",
"dep:viuer",
"dep:image",
"dep:graphviz-sys",
"dep:resvg",
"dep:usvg",
"dep:tiny-skia",
"dep:strum",
"dep:dot-writer",
"serde",
"dep:viuer",
"dep:image",
"dep:graphviz-sys",
"dep:resvg",
"dep:usvg",
"dep:tiny-skia",
"dep:strum",
"dep:dot-writer",
]

[profile.dev.build-override]
Expand Down
17 changes: 11 additions & 6 deletions src/evaluate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ use crate::error::{CLIError, CLIErrors};

use partiql_catalog::{Extension, PartiqlCatalog};
use partiql_eval::env::basic::MapBindings;
use partiql_eval::eval::{EvalPlan, Evaluated};
use partiql_eval::eval::{BasicContext, EvalPlan, Evaluated};
use partiql_eval::plan::EvaluationMode;
use partiql_extension_ion::decode::IonDecoderConfig;
use partiql_extension_ion::Encoding;
use partiql_extension_ion_functions::IonExtension;
use partiql_logical::{BindingsOp, LogicalPlan};
use partiql_parser::Parsed;
use partiql_value::Value;
use partiql_value::{DateTime, Value};
use std::fs;
use std::path::Path;
use partiql_catalog::context::SystemContext;

pub struct Compiler {
catalog: PartiqlCatalog,
Expand Down Expand Up @@ -55,10 +56,14 @@ impl Compiler {
&self,
query: &Parsed,
mut eval_plan: EvalPlan,
globals: MapBindings<Value>,
bindings: MapBindings<Value>,
) -> Result<Evaluated, CLIErrors> {
let sys = SystemContext {
now: DateTime::from_system_now_utc(),
};
let ctx = BasicContext::new(bindings, sys);
eval_plan
.execute_mut(globals)
.execute_mut(&ctx)
.map_err(|err| CLIErrors::from((query.text, err)))
}
}
Expand Down Expand Up @@ -104,8 +109,8 @@ pub fn get_bindings(environment: &Option<String>) -> Result<MapBindings<Value>,
let mut decoder = partiql_extension_ion::decode::IonDecoderBuilder::new(
IonDecoderConfig::default().with_mode(Encoding::PartiqlEncodedAsIon),
)
.build(reader)
.expect("expected ion file");
.build(reader)
.expect("expected ion file");
let env = decoder
.next()
.expect("expected single environment value in ion stream")
Expand Down
6 changes: 2 additions & 4 deletions src/visualize/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use partiql_ast::ast::{AstNode, Expr, TopLevelQuery};
use partiql_logical::{BindingsOp, LogicalPlan};
use serde::Serialize;
use tiny_skia::Transform;
use usvg::TreeParsing;

/// Convert an AST into JSON
#[inline]
Expand Down Expand Up @@ -144,10 +143,9 @@ where
let mut opt = usvg::Options::default();

let rtree = usvg::Tree::from_data(svg_data.as_bytes(), &opt).unwrap();
let pixmap_size = rtree.size.to_int_size();
let pixmap_size = rtree.size().to_int_size();
let mut pixmap = tiny_skia::Pixmap::new(pixmap_size.width(), pixmap_size.height()).unwrap();
let rtree = resvg::Tree::from_usvg(&rtree);
rtree.render(Transform::default(), &mut pixmap.as_mut());
resvg::render(&rtree, Transform::default(), &mut pixmap.as_mut());
pixmap.encode_png().expect("png encoding failed")
}

Expand Down

0 comments on commit 40f3b07

Please sign in to comment.