Daft icon indicating copy to clipboard operation
Daft copied to clipboard

SQL: support dot notation for struct accessor

Open jaychia opened this issue 1 year ago • 1 comments

Describe the bug

image

It seems that in a filter our SQL parser treats accessing . as accessing a table instead of my intention which is to treat it as accessing a struct field

To Reproduce

No response

Expected behavior

No response

Component(s)

SQL

Additional context

No response

jaychia avatar Oct 01 '24 17:10 jaychia

@jaychia currently our struct access only supports bracket notation, not dot notation.

give this a try!

import daft


df = daft.from_pydict(
    {
        "source": [{"database": "db1", "table": "table1"}, {"database": "db2", "table": "table2"}],
        "size": [{"depth": 3}, {"depth": 4}]
    }
)

daft.sql("select source['database'] from df WHERE size['depth'] != 3").collect()

universalmind303 avatar Oct 01 '24 19:10 universalmind303

Closed, but we need better docs around this I think

jaychia avatar Oct 14 '24 23:10 jaychia