Skip to content

feat: Support Cypher function tolower() for strings #106

@prrao87

Description

@prrao87

Feature request

In the graph benchmark, other systems like Neo4j, Kuzu and Ladybug support lowercasing string names in Cypher to allow for case-insensitive matching on query patterns. This will help us write Cypher queries in lance-graph that are more in line with what users coming from other systems may expect.

Another point to note: currently, the behavior isn't ideal because it causes silent failure (see #107) - where the user is unaware that the binder ignored the tolower() function entirely. This could also be a larger issue with binding where not-implemented functions aren't throwing an error that may help inform the user.

Repro

The following query returns unexpected results.

import pyarrow as pa
from lance_graph import CypherQuery, GraphConfig


def main() -> None:
    cfg = GraphConfig.builder().with_node_label("Person", "name").build()
    datasets = {"Person": pa.table({"name": ["Alice", "BOB", "CaSeY"]})}

    query = """
        MATCH (p:Person)
        RETURN p.name AS name, tolower(p.name) AS lowered
        ORDER BY name
    """
    print("input:")
    print(query.strip())
    print("output:")
    try:
        result = CypherQuery(query).with_config(cfg).execute(datasets)
        print([f"{row['name']} -> {row['lowered']}" for row in result.to_pylist()])
    except Exception as exc:
        print(f"ERROR: {type(exc).__name__}: {exc}")


if __name__ == "__main__":
    main()

Expected:

Alice -> 'alice', BOB -> 'bob', CaSeY -> 'casey']

Actual

'Alice -> 0', 'BOB -> 0', 'CaSeY -> 0']

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions