Skip to content
1 change: 1 addition & 0 deletions src/graph/spo/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,4 +345,5 @@ mod tests {
convergence_dist
);
}

}
42 changes: 42 additions & 0 deletions src/query/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,48 @@ impl From<datafusion::error::DataFusionError> for QueryError {
}
}

impl From<crate::graph::spo::sparse::SpoError> for QueryError {
fn from(source: crate::graph::spo::sparse::SpoError) -> Self {
Self::SpoError {
message: source.to_string(),
location: Location::new(file!(), line!(), column!()),
}
}
}

impl From<crate::query::lance_parser::error::GraphError> for QueryError {
fn from(source: crate::query::lance_parser::error::GraphError) -> Self {
use crate::query::lance_parser::error::GraphError;
match source {
GraphError::ParseError { message, position, location } => Self::ParseError {
message,
position,
location,
},
GraphError::PlanError { message, location } => Self::PlanError {
message,
location,
},
GraphError::ExecutionError { message, location } => Self::ExecutionError {
message,
location,
},
GraphError::ConfigError { message, location } => Self::PlanError {
message,
location,
},
GraphError::UnsupportedFeature { feature, location } => Self::UnsupportedFeature {
feature,
location,
},
GraphError::InvalidPattern { message, location } => Self::InvalidPattern {
message,
location,
},
}
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
3 changes: 0 additions & 3 deletions src/query/lance_parser/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,23 +79,20 @@ pub fn exec_err_at(message: String) -> GraphError {
/// ```ignore
/// let err = lance_plan_err!("Cannot join {} to {}", left, right);
/// ```
#[macro_export]
macro_rules! lance_plan_err {
($($arg:tt)*) => {
$crate::query::lance_parser::error::plan_err_at(format!($($arg)*))
};
}

/// Create a ConfigError with zero-cost location capture.
#[macro_export]
macro_rules! lance_config_err {
($($arg:tt)*) => {
$crate::query::lance_parser::error::config_err_at(format!($($arg)*))
};
}

/// Create an ExecutionError with zero-cost location capture.
#[macro_export]
macro_rules! lance_exec_err {
($($arg:tt)*) => {
$crate::query::lance_parser::error::exec_err_at(format!($($arg)*))
Expand Down
12 changes: 10 additions & 2 deletions src/query/lance_parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,16 @@ pub mod parameter_substitution;
pub mod parser;
pub mod semantic;

// Re-export the main entry points
pub use ast::*;
// Re-export the main entry points.
// NOTE: ast::CypherQuery deliberately excluded to avoid collision with
// cypher.rs::CypherQuery. Use lance_parser::ast::CypherQuery if needed.
pub use ast::{
ArithmeticOperator, BooleanExpression, ComparisonOperator, DistanceMetric,
FunctionType, GraphPattern, LengthRange, MatchClause, NodePattern, OrderByClause,
OrderByItem, PathPattern, PathSegment, PropertyRef, PropertyValue, ReadingClause,
RelationshipDirection, RelationshipPattern, ReturnClause, ReturnItem, SortDirection,
UnwindClause, ValueExpression, WhereClause, WithClause, classify_function,
};
pub use error::{GraphError, Result};
pub use parameter_substitution::ParamValue;
pub use parser::parse_cypher_query;
12 changes: 6 additions & 6 deletions src/spo/spo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ impl FieldCloseness {
}
}

resonant.sort_by(|a, b| b.3.partial_cmp(&a.3).unwrap());
resonant.sort_by(|a, b| b.3.partial_cmp(&a.3).unwrap_or(std::cmp::Ordering::Equal));

Self {
similarity,
Expand Down Expand Up @@ -709,7 +709,7 @@ impl CellStorage {
self.triples
.iter()
.map(|(fp, idx)| (*idx, query.similarity(fp)))
.max_by(|a, b| a.1.partial_cmp(&b.1).unwrap())
.max_by(|a, b| a.1.partial_cmp(&b.1).unwrap_or(std::cmp::Ordering::Equal))
}

/// Find all matching above threshold
Expand Down Expand Up @@ -860,7 +860,7 @@ impl SPOCrystal {
}

// Deduplicate and sort
results.sort_by(|a, b| b.1.partial_cmp(&a.1).unwrap());
results.sort_by(|a, b| b.1.partial_cmp(&a.1).unwrap_or(std::cmp::Ordering::Equal));
results.dedup_by(|a, b| a.0 == b.0);
results
}
Expand Down Expand Up @@ -895,7 +895,7 @@ impl SPOCrystal {
}
}

results.sort_by(|a, b| b.1.partial_cmp(&a.1).unwrap());
results.sort_by(|a, b| b.1.partial_cmp(&a.1).unwrap_or(std::cmp::Ordering::Equal));
results.dedup_by(|a, b| a.0 == b.0);
results
}
Expand Down Expand Up @@ -930,7 +930,7 @@ impl SPOCrystal {
}
}

results.sort_by(|a, b| b.1.partial_cmp(&a.1).unwrap());
results.sort_by(|a, b| b.1.partial_cmp(&a.1).unwrap_or(std::cmp::Ordering::Equal));
results.dedup_by(|a, b| a.0 == b.0);
results
}
Expand Down Expand Up @@ -978,7 +978,7 @@ impl SPOCrystal {
}
}

results.sort_by(|a, b| b.1.partial_cmp(&a.1).unwrap());
results.sort_by(|a, b| b.1.partial_cmp(&a.1).unwrap_or(std::cmp::Ordering::Equal));
results
}

Expand Down
Loading
Loading