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

Resolve nested column names in SQL functions #125

Closed
ilongin opened this issue Jul 22, 2024 · 2 comments
Closed

Resolve nested column names in SQL functions #125

ilongin opened this issue Jul 22, 2024 · 2 comments
Assignees

Comments

@ilongin
Copy link
Contributor

ilongin commented Jul 22, 2024

We do have decorator that resolves nested column / signal names in DataChain method arguments (e.g file.name -> file__name), but it doesn't work if columns are arguments to a SQL function.

Example that doesn't work, but should if this is fixed:

from datachain.sql.functions.string import length
from datachain.lib.dc import C, DataChain

names = ["aa.txt", "aaa.txt", "a.txt", "aaaaaa.txt", "aa.txt"]
dc = DataChain.from_values(file=[File(name=name) for name in names])
dc = dc.order_by(length(C("file.name")))   # this works if file__name is set instead.

assert dc.collect_one("file.name") == ["a.txt", "aa.txt", "aa.txt", "aaa.txt", "aaaaaa.txt"]
@rlamy
Copy link
Contributor

rlamy commented Jul 22, 2024

This will become even more important after #101, since accessing the file name will require something like name(C("file.path")).

@ilongin ilongin self-assigned this Jul 30, 2024
@ilongin
Copy link
Contributor Author

ilongin commented Jul 30, 2024

Looks like this already works as C from datachain.lib.dc resolves name by replacing . to __ automatically so no additional changes needed and I'm closing the issue.

@ilongin ilongin closed this as completed Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants