Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions rust/lance-graph/src/simple_executor/aliases.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,33 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright The Lance Authors

/// Qualify a column name for internal DataFusion operations.
/// Returns format: `alias__property` (e.g., "p__name").
/// Note: This is for internal use only. Final output uses Cypher dot notation.
pub(super) fn qualify_alias_property(alias: &str, property: &str) -> String {
format!("{}__{}", alias, property)
}

/// Convert to Cypher-style column name for query results.
/// Returns format: `alias.property` (e.g., "p.name").
/// This matches the output format used by the DataFusion executor.
pub(super) fn to_cypher_column_name(alias: &str, property: &str) -> String {
format!("{}.{}", alias, property)
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_qualify_alias_property() {
assert_eq!(qualify_alias_property("p", "name"), "p__name");
assert_eq!(qualify_alias_property("person", "age"), "person__age");
}

#[test]
fn test_to_cypher_column_name() {
assert_eq!(to_cypher_column_name("p", "name"), "p.name");
assert_eq!(to_cypher_column_name("c", "company_name"), "c.company_name");
}
}
4 changes: 4 additions & 0 deletions rust/lance-graph/src/simple_executor/clauses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ pub(super) fn apply_return_with_qualifier(
let mut e = datafusion::logical_expr::col(col_name);
if let Some(a) = &item.alias {
e = e.alias(a);
} else {
let cypher_name =
super::aliases::to_cypher_column_name(&prop.variable, &prop.property);
e = e.alias(cypher_name);
}
proj.push(e);
}
Expand Down
Loading