Eventual-Inc / Daft

Distributed data engine for Python/SQL designed for the cloud, powered by Rust
https://getdaft.io
Apache License 2.0
2.34k stars 164 forks source link

add flag to enable/disable implicit coercions #3338

Open universalmind303 opened 2 days ago

universalmind303 commented 2 days ago

Is your feature request related to a problem?

currently daft allows implicit coercions for various ops eq, neq, .... A lot of these implicit rules are not well documented, and depending on the application, they may be undesired.

I would like a strict mode that disables all implicit type coercions.

Describe the solution you'd like

py

import daft
from daft import col

df = daft.from_pydict({
    'i64': [1, 2, 3, 4, 5],
})
df = df.select(col('i64').cast(daft.DataType.int64()))
df.where(col('i64') > daft.lit(2).cast(daft.DataType.float64())).collect() # works

# set `allow_implicit_coercion = False`

df.where(col('i64') > daft.lit(2).cast(daft.DataType.float64())) # fails
df.where(col('i64') > daft.lit(2).cast(daft.DataType.int64())) # works

sql

SET allow_implicit_coercion = false; 
select * from tbl where date_col == '2020-01-01' -- fails
select * from tbl where date_col == cast('2020-01-01' as date) -- works
SET allow_implicit_coercion = true; 
select * from tbl where date_col == '2020-01-01' -- works

Describe alternatives you've considered

No response

Additional Context

No response

Would you like to implement a fix?

No