map.get with no rows #3890
-
During dataframe operations if there are no rows after filtering, and I use map.get, I get a The only way I found to avoid the exception is to check Is there a better way to avoid the exception which avoids materialising the dataframe? Is it possible that map.get can avoid throwing the exception in case of no rows Sample: import pyarrow as pa
import daft
data = pa.array([[("a", 1)], [("a", 2)]], type=pa.map_(pa.string(), pa.int64()))
table = pa.table({"map_col": data})
df = daft.from_arrow(table)
df = df.where(df["map_col"].map.get("a") == 3)
if df.count_rows() > 0: # exception is thrown without this check
df = df.with_column("a", df["map_col"].map.get("a"))
df.show() Stacktrace:
I noticed struct.get doesn't throw the exception: import daft
df = daft.from_pydict({
"data": [
{"a": 1},
{"a": 2}
]
})
df = df.where(df["data"].struct.get("a") == 3)
df = df.with_column("a", df["data"].struct.get("a"))
df.show() |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
this definitely looks like a bug. I opened up an issue and a subsequent PR to address this. |
Beta Was this translation helpful? Give feedback.
this definitely looks like a bug. I opened up an issue and a subsequent PR to address this.