When you pass a Series into daft.lit, it actually tries to use the series as a column, and if it does not match the length of a table, it fails. Instead, it should be treated as a singular list row and broadcasted, to be consistent with other literal types.
To Reproduce
>>> import daft
>>> df = daft.from_pydict({"foo": [1, 2, 3], "bar": ["a", "b", "c"]})
>>> s = daft.Series.from_pylist(["x", "y", "z"])
>>> df = df.with_column("baz", daft.lit(s))
>>> df.show()
╭───────┬──────┬──────╮
│ foo ┆ bar ┆ baz │
│ --- ┆ --- ┆ --- │
│ Int64 ┆ Utf8 ┆ Utf8 │
╞═══════╪══════╪══════╡
│ 1 ┆ a ┆ x │
├╌╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌┤
│ 2 ┆ b ┆ y │
├╌╌╌╌╌╌╌┼╌╌╌╌╌╌┼╌╌╌╌╌╌┤
│ 3 ┆ c ┆ z │
╰───────┴──────┴──────╯
we actually want to remove Series as a dependency in daft-dsl, so what we should do to further that while solving this issue is to create a new LiteralValue::List type that holds a vec of LiteralValue instead of a series. We can add functionality that converts to and from series, where the to_series implementation will return a ListArray series with the inner vec value.
Describe the bug
When you pass a Series into
daft.lit
, it actually tries to use the series as a column, and if it does not match the length of a table, it fails. Instead, it should be treated as a singular list row and broadcasted, to be consistent with other literal types.To Reproduce
Expected behavior
Component(s)
Expressions
Additional context
How we would implement this:
LiteralValue::List
type that holds a vec ofLiteralValue
instead of a series. We can add functionality that converts to and from series, where the to_series implementation will return a ListArray series with the inner vec value.