From 6c155f754009c10567c7da24c455a414d79ec806 Mon Sep 17 00:00:00 2001 From: Magnus Bakken <10287813+magbak@users.noreply.github.com> Date: Sat, 27 Jan 2024 07:24:13 +0100 Subject: [PATCH] Some fixes --- triplestore/src/sparql/lazy_aggregate.rs | 2 +- triplestore/src/sparql/lazy_expressions.rs | 2 +- triplestore/src/sparql/lazy_graph_patterns.rs | 2 +- .../src/sparql/lazy_graph_patterns/extend.rs | 2 +- .../src/sparql/lazy_graph_patterns/filter.rs | 2 +- .../src/sparql/lazy_graph_patterns/group.rs | 2 +- .../src/sparql/lazy_graph_patterns/join.rs | 2 +- .../sparql/lazy_graph_patterns/left_join.rs | 2 +- .../src/sparql/lazy_graph_patterns/minus.rs | 2 +- .../sparql/lazy_graph_patterns/order_by.rs | 2 +- .../src/sparql/lazy_graph_patterns/project.rs | 2 +- .../src/sparql/lazy_graph_patterns/pvalues.rs | 20 ++++++++++--------- .../src/sparql/lazy_graph_patterns/union.rs | 2 +- .../src/sparql/lazy_graph_patterns/values.rs | 2 +- triplestore/src/sparql/lazy_order.rs | 2 +- 15 files changed, 25 insertions(+), 23 deletions(-) diff --git a/triplestore/src/sparql/lazy_aggregate.rs b/triplestore/src/sparql/lazy_aggregate.rs index 5e8a6c5..bd9d5fa 100644 --- a/triplestore/src/sparql/lazy_aggregate.rs +++ b/triplestore/src/sparql/lazy_aggregate.rs @@ -1,7 +1,7 @@ use super::Triplestore; use crate::sparql::errors::SparqlError; use oxrdf::Variable; -use polars_core::frame::DataFrame; + use query_processing::aggregates::{ avg, count_with_expression, count_without_expression, group_concat, max, min, sample, sum, AggregateReturn, diff --git a/triplestore/src/sparql/lazy_expressions.rs b/triplestore/src/sparql/lazy_expressions.rs index f6eb50f..9eb5780 100644 --- a/triplestore/src/sparql/lazy_expressions.rs +++ b/triplestore/src/sparql/lazy_expressions.rs @@ -4,7 +4,7 @@ use std::collections::HashMap; use crate::sparql::errors::SparqlError; use oxrdf::vocab::xsd; use polars::prelude::{col, Expr, LiteralValue, Operator}; -use polars_core::frame::DataFrame; + use query_processing::exists_helper::rewrite_exists_graph_pattern; use query_processing::expressions::{ binary_expression, bound, coalesce_expression, exists, func_expression, if_expression, diff --git a/triplestore/src/sparql/lazy_graph_patterns.rs b/triplestore/src/sparql/lazy_graph_patterns.rs index ab3ab84..7c40fb0 100644 --- a/triplestore/src/sparql/lazy_graph_patterns.rs +++ b/triplestore/src/sparql/lazy_graph_patterns.rs @@ -17,7 +17,7 @@ mod values; use super::Triplestore; use crate::sparql::errors::SparqlError; use log::{debug, info}; -use polars_core::frame::DataFrame; + use representation::query_context::{Context, PathEntry}; use representation::solution_mapping::{EagerSolutionMappings, SolutionMappings}; use spargebra::algebra::GraphPattern; diff --git a/triplestore/src/sparql/lazy_graph_patterns/extend.rs b/triplestore/src/sparql/lazy_graph_patterns/extend.rs index 79e1f26..6594af9 100644 --- a/triplestore/src/sparql/lazy_graph_patterns/extend.rs +++ b/triplestore/src/sparql/lazy_graph_patterns/extend.rs @@ -2,7 +2,7 @@ use super::Triplestore; use crate::sparql::errors::SparqlError; use log::debug; use oxrdf::Variable; -use polars_core::frame::DataFrame; + use query_processing::graph_patterns::extend; use representation::query_context::{Context, PathEntry}; use representation::solution_mapping::{EagerSolutionMappings, SolutionMappings}; diff --git a/triplestore/src/sparql/lazy_graph_patterns/filter.rs b/triplestore/src/sparql/lazy_graph_patterns/filter.rs index a364919..af273ab 100644 --- a/triplestore/src/sparql/lazy_graph_patterns/filter.rs +++ b/triplestore/src/sparql/lazy_graph_patterns/filter.rs @@ -1,7 +1,7 @@ use super::Triplestore; use crate::sparql::errors::SparqlError; use log::debug; -use polars_core::frame::DataFrame; + use query_processing::graph_patterns::filter; use representation::query_context::{Context, PathEntry}; use representation::solution_mapping::{EagerSolutionMappings, SolutionMappings}; diff --git a/triplestore/src/sparql/lazy_graph_patterns/group.rs b/triplestore/src/sparql/lazy_graph_patterns/group.rs index 717d988..2e6884f 100644 --- a/triplestore/src/sparql/lazy_graph_patterns/group.rs +++ b/triplestore/src/sparql/lazy_graph_patterns/group.rs @@ -2,7 +2,7 @@ use super::Triplestore; use crate::sparql::errors::SparqlError; use log::debug; use oxrdf::Variable; -use polars_core::frame::DataFrame; + use query_processing::aggregates::AggregateReturn; use query_processing::graph_patterns::{group_by, prepare_group_by}; use representation::query_context::{Context, PathEntry}; diff --git a/triplestore/src/sparql/lazy_graph_patterns/join.rs b/triplestore/src/sparql/lazy_graph_patterns/join.rs index 3743124..deb7254 100644 --- a/triplestore/src/sparql/lazy_graph_patterns/join.rs +++ b/triplestore/src/sparql/lazy_graph_patterns/join.rs @@ -1,7 +1,7 @@ use super::Triplestore; use crate::sparql::errors::SparqlError; use log::debug; -use polars_core::frame::DataFrame; + use representation::query_context::{Context, PathEntry}; use representation::solution_mapping::{EagerSolutionMappings, SolutionMappings}; use std::collections::HashMap; diff --git a/triplestore/src/sparql/lazy_graph_patterns/left_join.rs b/triplestore/src/sparql/lazy_graph_patterns/left_join.rs index 1587e34..cc74c1b 100644 --- a/triplestore/src/sparql/lazy_graph_patterns/left_join.rs +++ b/triplestore/src/sparql/lazy_graph_patterns/left_join.rs @@ -1,7 +1,7 @@ use super::Triplestore; use crate::sparql::errors::SparqlError; use log::debug; -use polars_core::frame::DataFrame; + use query_processing::graph_patterns::{filter, left_join}; use representation::query_context::{Context, PathEntry}; use representation::solution_mapping::{EagerSolutionMappings, SolutionMappings}; diff --git a/triplestore/src/sparql/lazy_graph_patterns/minus.rs b/triplestore/src/sparql/lazy_graph_patterns/minus.rs index c02bacf..5d37e18 100644 --- a/triplestore/src/sparql/lazy_graph_patterns/minus.rs +++ b/triplestore/src/sparql/lazy_graph_patterns/minus.rs @@ -1,7 +1,7 @@ use super::Triplestore; use crate::sparql::errors::SparqlError; use log::debug; -use polars_core::frame::DataFrame; + use query_processing::graph_patterns::minus; use representation::query_context::{Context, PathEntry}; use representation::solution_mapping::{EagerSolutionMappings, SolutionMappings}; diff --git a/triplestore/src/sparql/lazy_graph_patterns/order_by.rs b/triplestore/src/sparql/lazy_graph_patterns/order_by.rs index afea513..fc78dd6 100644 --- a/triplestore/src/sparql/lazy_graph_patterns/order_by.rs +++ b/triplestore/src/sparql/lazy_graph_patterns/order_by.rs @@ -1,7 +1,7 @@ use super::Triplestore; use crate::sparql::errors::SparqlError; use log::debug; -use polars_core::frame::DataFrame; + use query_processing::graph_patterns::order_by; use representation::query_context::{Context, PathEntry}; use representation::solution_mapping::{EagerSolutionMappings, SolutionMappings}; diff --git a/triplestore/src/sparql/lazy_graph_patterns/project.rs b/triplestore/src/sparql/lazy_graph_patterns/project.rs index b582a5a..8239de7 100644 --- a/triplestore/src/sparql/lazy_graph_patterns/project.rs +++ b/triplestore/src/sparql/lazy_graph_patterns/project.rs @@ -2,7 +2,7 @@ use super::Triplestore; use crate::sparql::errors::SparqlError; use log::debug; use oxrdf::Variable; -use polars_core::frame::DataFrame; + use query_processing::graph_patterns::project; use representation::query_context::{Context, PathEntry}; use representation::solution_mapping::{EagerSolutionMappings, SolutionMappings}; diff --git a/triplestore/src/sparql/lazy_graph_patterns/pvalues.rs b/triplestore/src/sparql/lazy_graph_patterns/pvalues.rs index 75a6993..8f13aa8 100644 --- a/triplestore/src/sparql/lazy_graph_patterns/pvalues.rs +++ b/triplestore/src/sparql/lazy_graph_patterns/pvalues.rs @@ -2,17 +2,14 @@ use super::Triplestore; use crate::sparql::errors::SparqlError; use oxrdf::Variable; use polars::prelude::IntoLazy; -use polars_core::frame::DataFrame; + use query_processing::graph_patterns::join; use representation::query_context::Context; use representation::solution_mapping::{EagerSolutionMappings, SolutionMappings}; -use representation::sparql_to_polars::{ - polars_literal_values_to_series, sparql_literal_to_polars_literal_value, - sparql_named_node_to_polars_literal_value, -}; -use representation::RDFNodeType; -use spargebra::term::GroundTerm; -use std::collections::HashMap; + + + +use std::collections::{HashMap, HashSet}; impl Triplestore { pub(crate) fn lazy_pvalues( @@ -29,7 +26,12 @@ impl Triplestore { rdf_node_types, }) = parameters.get(bindings_name) { - //Todo! Check that variables are in df.. + let mapping_vars:HashSet<_> = mappings.get_column_names().into_iter().collect(); + let expected_vars: HashSet<_> = variables.iter().map(|x|x.as_str()).collect(); + if mapping_vars != expected_vars { + todo!("Handle mismatching variables in PValues") + } + SolutionMappings { mappings: mappings.clone().lazy(), rdf_node_types: rdf_node_types.clone(), diff --git a/triplestore/src/sparql/lazy_graph_patterns/union.rs b/triplestore/src/sparql/lazy_graph_patterns/union.rs index cbcf956..2155990 100644 --- a/triplestore/src/sparql/lazy_graph_patterns/union.rs +++ b/triplestore/src/sparql/lazy_graph_patterns/union.rs @@ -1,7 +1,7 @@ use super::Triplestore; use crate::sparql::errors::SparqlError; use log::debug; -use polars_core::frame::DataFrame; + use query_processing::graph_patterns::union; use representation::query_context::{Context, PathEntry}; use representation::solution_mapping::{EagerSolutionMappings, SolutionMappings}; diff --git a/triplestore/src/sparql/lazy_graph_patterns/values.rs b/triplestore/src/sparql/lazy_graph_patterns/values.rs index 9e689d1..b1e7565 100644 --- a/triplestore/src/sparql/lazy_graph_patterns/values.rs +++ b/triplestore/src/sparql/lazy_graph_patterns/values.rs @@ -5,7 +5,7 @@ use polars::prelude::IntoLazy; use polars_core::frame::DataFrame; use query_processing::graph_patterns::join; use representation::query_context::Context; -use representation::solution_mapping::{EagerSolutionMappings, SolutionMappings}; +use representation::solution_mapping::{SolutionMappings}; use representation::sparql_to_polars::{ polars_literal_values_to_series, sparql_literal_to_polars_literal_value, sparql_named_node_to_polars_literal_value, diff --git a/triplestore/src/sparql/lazy_order.rs b/triplestore/src/sparql/lazy_order.rs index 82d2558..15128db 100644 --- a/triplestore/src/sparql/lazy_order.rs +++ b/triplestore/src/sparql/lazy_order.rs @@ -1,6 +1,6 @@ use super::Triplestore; use crate::sparql::errors::SparqlError; -use polars_core::frame::DataFrame; + use representation::query_context::{Context, PathEntry}; use representation::solution_mapping::{EagerSolutionMappings, SolutionMappings}; use spargebra::algebra::OrderExpression;