ArcticDB icon indicating copy to clipboard operation
ArcticDB copied to clipboard

Fix #1148: Show clearer error message for mismatched types in QueryBuilder

Open muhammadhamzasajjad opened this issue 1 year ago • 0 comments
trafficstars

Reference Issues/PRs

Fixes #1148. previously if a type was mismatched in the QueryBuilder as follows

df1 = pd.DataFrame({"col1": [1, 2, 3], "col2": [2, 3, 4], "col3": [4, 5, 6], "col_str": ["1", "2", "3"]})
sym = "symbol"
lib.write(sym, df1)
q = QueryBuilder()
q = q[q["col1" + 1]  == "3"]
lib.read(sym, query_builder=q)

it would show an unclear message with UTF_DYNAMIC64 type shown for strings

arcticdb_ext.exceptions.InternalException: E_ASSERTION_FAILURE Cannot compare TD<type=UTF_DYNAMIC64, dim=0> to TD<type=UINT32, dim=0> (possible categorical?)

Now the error is much clearer where column names are generated according to the query and STRING type is shown for strings

arcticdb_ext.exceptions.InternalException: E_ASSERTION_FAILURE Cannot compare (col1 + 1) TD<type=INT64, dim=0> to TD<type=STRING, dim=0>

For a more complex query like q = q[1 + q["col1"] * q["col2"] - q["col3"] == q["col_str"]] it will show column name ((1 + (col1 * col2)) - col3) in the error message which allows the user to better understand the error.

What does this implement or fix?

Any other comments?

Checklist

Checklist for code changes...
  • [x] Have you updated the relevant docstrings, documentation and copyright notice?
  • [ ] Is this contribution tested against all ArcticDB's features?
  • [ ] Do all exceptions introduced raise appropriate error messages?
  • [ ] Are API changes highlighted in the PR description?
  • [x] Is the PR labelled as enhancement or bug so it appears in autogenerated release notes?

muhammadhamzasajjad avatar May 08 '24 16:05 muhammadhamzasajjad