Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Automatically alias column names in Kùzu result when using a.* #3846

Open
prrao87 opened this issue Jul 17, 2024 · 0 comments
Open
Labels
feature New features or missing components of existing features

Comments

@prrao87
Copy link
Member

prrao87 commented Jul 17, 2024

API

Python

Description

Tried on version 0.4.3dev57.

When we return all properties in a MATCH query and we want to unpack the results into a DataFrame, the convention is to use the .* syntax as follows:

conn.execute("COPY Item FROM df")
result = conn.execute("MATCH (n:Item) RETURN n.*")
print(result.get_as_pl())
┌─────────────────────────────────┬──────────┬──────────┬─────────────┬────────────┬────────────────────────────────┐
│ n.id                            ┆ n.amount ┆ n.counts ┆ n.birthdate ┆ n.is_valid ┆ n.comment                      │
│ ---                             ┆ ---      ┆ ---      ┆ ---         ┆ ---        ┆ ---                            │
│ str                             ┆ f64      ┆ i64      ┆ date        ┆ bool       ┆ str                            │
╞═════════════════════════════════╪══════════╪══════════╪═════════════╪════════════╪════════════════════════════════╡
│ a68a8af4-4a53-4420-9cb8-4a3e1f… ┆ 3.635742 ┆ 89       ┆ 1990-01-01  ┆ true       ┆ This is a test.                │
│ 55cfb01c-8cfc-4e3f-8408-05f362… ┆ 9.381905 ┆ 57       ┆ 2001-03-27  ┆ false      ┆ This is another "test".        │
│ 9cddb5ae-e1d8-4382-b364-19b67e… ┆ 1.668131 ┆ 29       ┆ 2004-02-29  ┆ true       ┆ This is (yet) another \test\.  │
└─────────────────────────────────┴──────────┴──────────┴─────────────┴────────────┴────────────────────────────────┘

The returned Pandas/Polars DataFrame will have header columns that always contain the variable name to which we bound the node type in the MATCH statement (n.id, n.counts, etc).

Here's how the same thing done in DuckDB will look:

conn.execute("INSERT INTO item SELECT * from df")
result = conn.execute("SELECT * FROM item")
print(res.pl())
┌─────────────────────────────────┬──────────┬────────┬────────────┬──────────┬────────────────────────────────┐
│ id                              ┆ amount   ┆ counts ┆ birthdate  ┆ is_valid ┆ comment                        │
│ ---                             ┆ ---      ┆ ---    ┆ ---        ┆ ---      ┆ ---                            │
│ str                             ┆ f64      ┆ i32    ┆ date       ┆ bool     ┆ str                            │
╞═════════════════════════════════╪══════════╪════════╪════════════╪══════════╪════════════════════════════════╡
│ a68a8af4-4a53-4420-9cb8-4a3e1f… ┆ 3.635742 ┆ 89     ┆ 1990-01-01 ┆ true     ┆ This is a test.                │
│ 55cfb01c-8cfc-4e3f-8408-05f362… ┆ 9.381905 ┆ 57     ┆ 2001-03-27 ┆ false    ┆ This is another "test".        │
│ 9cddb5ae-e1d8-4382-b364-19b67e… ┆ 1.668131 ┆ 29     ┆ 2004-02-29 ┆ true     ┆ This is (yet) another \test\.  │
└─────────────────────────────────┴──────────┴────────┴────────────┴──────────┴────────────────────────────────┘

The column names are as per the input CSV file, which is convenient for downstream use.

Desired outcome

Is it possible to automatically alias the column headers in Kùzu when using a.* to output all properties as tuples? This would make downstream usage so much easier as the user can just rely on the DataFrame column names being identical to the input CSV/DataFrames upstream.

@prrao87 prrao87 added the feature New features or missing components of existing features label Jul 17, 2024
@prrao87 prrao87 changed the title Feature: Return collected results from a.* with only properties Feature: Automatically alias column names in Kùzu result when using a.* Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New features or missing components of existing features
Projects
None yet
Development

No branches or pull requests

1 participant