Skip to content

Commit c49c050

Browse files
ex172000claude
andauthored
fix(simple-executor): return consistent column names using dot notation (#84)
* fix(simple-executor): return consistent column names using dot notation Update simple executor to return Cypher dot notation (e.g., p.name) instead of double underscore format (e.g., p__name) for column names. This ensures consistency with the DataFusion executor output. Changes: - Add to_cypher_column_name() function to convert to dot notation - Update apply_return_with_qualifier() to apply conversion for final output - Add unit tests for the new function - Preserve explicit user-provided aliases Fixes #30 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * cargo fmt --------- Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent cf358f4 commit c49c050

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,33 @@
11
// SPDX-License-Identifier: Apache-2.0
22
// SPDX-FileCopyrightText: Copyright The Lance Authors
33

4+
/// Qualify a column name for internal DataFusion operations.
5+
/// Returns format: `alias__property` (e.g., "p__name").
6+
/// Note: This is for internal use only. Final output uses Cypher dot notation.
47
pub(super) fn qualify_alias_property(alias: &str, property: &str) -> String {
58
format!("{}__{}", alias, property)
69
}
10+
11+
/// Convert to Cypher-style column name for query results.
12+
/// Returns format: `alias.property` (e.g., "p.name").
13+
/// This matches the output format used by the DataFusion executor.
14+
pub(super) fn to_cypher_column_name(alias: &str, property: &str) -> String {
15+
format!("{}.{}", alias, property)
16+
}
17+
18+
#[cfg(test)]
19+
mod tests {
20+
use super::*;
21+
22+
#[test]
23+
fn test_qualify_alias_property() {
24+
assert_eq!(qualify_alias_property("p", "name"), "p__name");
25+
assert_eq!(qualify_alias_property("person", "age"), "person__age");
26+
}
27+
28+
#[test]
29+
fn test_to_cypher_column_name() {
30+
assert_eq!(to_cypher_column_name("p", "name"), "p.name");
31+
assert_eq!(to_cypher_column_name("c", "company_name"), "c.company_name");
32+
}
33+
}

rust/lance-graph/src/simple_executor/clauses.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ pub(super) fn apply_return_with_qualifier(
3737
let mut e = datafusion::logical_expr::col(col_name);
3838
if let Some(a) = &item.alias {
3939
e = e.alias(a);
40+
} else {
41+
let cypher_name =
42+
super::aliases::to_cypher_column_name(&prop.variable, &prop.property);
43+
e = e.alias(cypher_name);
4044
}
4145
proj.push(e);
4246
}

0 commit comments

Comments
 (0)