arrow_graph/sql/
extension.rs

1use datafusion::execution::context::SessionContext;
2use crate::error::Result;
3use crate::sql::graph_functions::register_all_graph_functions;
4use crate::sql::window_functions::register_window_functions;
5
6pub struct GraphSqlExtension;
7
8impl GraphSqlExtension {
9    pub fn new() -> Self {
10        Self
11    }
12    
13    /// Register all graph SQL functions and window functions with DataFusion context
14    pub fn register_functions(&self, ctx: &mut SessionContext) -> Result<()> {
15        // Register scalar functions
16        register_all_graph_functions(ctx)
17            .map_err(|e| crate::error::GraphError::algorithm(format!("Failed to register graph functions: {}", e)))?;
18        
19        // Register window functions
20        register_window_functions(ctx)
21            .map_err(|e| crate::error::GraphError::algorithm(format!("Failed to register window functions: {}", e)))?;
22        
23        Ok(())
24    }
25}
26
27impl Default for GraphSqlExtension {
28    fn default() -> Self {
29        Self::new()
30    }
31}