I just had a neat idea, recently we added support ...
# daft-dev
c
I just had a neat idea, recently we added support for auto parsing of sql exprs for
where
ex:
df.where('a == 1')
what about adding that for
expr.cast
as well. so instead of
Copy code
daft.col('list').cast(daft.DataType.fixed_size_list(daft.DataType.int32(), 3))
you could just type:
Copy code
daft.col('list').cast('int[3]')
👀 1
j
ooo….
I have indeed struggled with needing to type out the full
daft.DataType.string()
I guess the tricky thing might be how we construct that mapping of
str
:
DataType
? This should also just be consistent with our SQL representation of types right
Dang this could be nice for UDFs too:
Copy code
@daft.udf(return_dtype="struct[foo: string, bar: int64]")
c
I guess the tricky thing might be how we construct that mapping of
str
:
DataType
? This should also just be consistent with our SQL representation of types right (edited)
I was thinking we'd just delegate directly to the sql engine like we do with
dataframe.where
👍 1
j
Makes sense, and I guess we just have like a
DataType.from_sql("…")
? Could be useful
👍 1
I just tried doing this because I got tired of typing
daft.DataType…
😭 Didn’t work though
c
We didn't add it yet. It would be a great first PR for someone looking to get involved in daft sql!
j
Cool, is there an open issue yet? I can file one if not
e
@jay Does anyone else do this with their daft imports?
from daft import col, DataFrame, DataType as da
j
hmm I do find
DataType
quite verbose yeah
e
It’s mostly because DataFrame gets prioritized in intellisense, so you end up having to write most of it