Repository: modin-project/modin

Issue:
[omnisci] Exception when indexing dataframe with condition
### System information
- **OS Platform and Distribution (e.g., Linux Ubuntu 16.04)**:

Ubuntu 20.04.1 LTS

- **Modin version** (`modin.__version__`):

0.10.2+26.gda2ad792

- **Python version**:

Python 3.9.7

- **Code we can use to reproduce**:

```python
import numpy as np
import modin.pandas as pd

MULTIPLIER = 1000000

df = pd.DataFrame({
    "f1": [np.float(1)] * MULTIPLIER,
    "f2": [np.float(2)] * MULTIPLIER,
    "s": ["abc"] * MULTIPLIER,
    "i": [10] * MULTIPLIER,
    "t": [pd.to_datetime("2021")] * MULTIPLIER
})

print(df.dtypes)
df2 = df[(df.f1 < 10) & (df.f2 > 300)]
print(df2)
```

<!--
You can obtain the Modin version with

python -c "import modin; print(modin.__version__)"
-->

### Describe the problem
<!-- Describe the problem clearly here. -->

Code above produces exception while Pandas and Modin on Ray work correctly:
```
Traceback (most recent call last):
  File "/nfs/site/proj/scripting_tools/gashiman/tests/omnisci_query.py", line 15, in <module>
    df2 = df[(df.f1 < 10) & (df.f2 > 300)]
  File "/localdisk/gashiman/modin/modin/pandas/base.py", line 2923, in __getitem__
    return self._getitem(key)
  File "/localdisk/gashiman/modin/modin/pandas/dataframe.py", line 2988, in _getitem
    query_compiler=self._query_compiler.getitem_array(key._query_compiler)
  File "/localdisk/gashiman/modin/modin/experimental/backends/omnisci/query_compiler.py", line 96, in method_wrapper
    return method(self, *args, **kwargs)
  File "/localdisk/gashiman/modin/modin/experimental/backends/omnisci/query_compiler.py", line 231, in getitem_array
    raise KeyError(
KeyError: "['__reduced__'] not index"
```

### Source code / logs
<!-- Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached. Try to provide a reproducible test case that is the bare minimum necessary to generate the problem. -->



Discussion:

Resolving patch:
diff --git a/modin/experimental/backends/omnisci/query_compiler.py b/modin/experimental/backends/omnisci/query_compiler.py
--- a/modin/experimental/backends/omnisci/query_compiler.py
+++ b/modin/experimental/backends/omnisci/query_compiler.py
@@ -218,11 +218,8 @@ def getitem_column_array(self, key, numeric=False):
 
     def getitem_array(self, key):
         if isinstance(key, type(self)):
-            try:
-                new_modin_frame = self._modin_frame.filter(key._modin_frame)
-                return self.__constructor__(new_modin_frame, self._shape_hint)
-            except NotImplementedError:
-                key = key.to_pandas()
+            new_modin_frame = self._modin_frame.filter(key._modin_frame)
+            return self.__constructor__(new_modin_frame, self._shape_hint)
 
         if is_bool_indexer(key):
             return self.default_to_pandas(lambda df: df[key])
@@ -613,6 +610,12 @@ def lt(self, other, **kwargs):
     def ne(self, other, **kwargs):
         return self._bin_op(other, "ne", **kwargs)
 
+    def __and__(self, other, **kwargs):
+        return self._bin_op(other, "and", **kwargs)
+
+    def __or__(self, other, **kwargs):
+        return self._bin_op(other, "or", **kwargs)
+
     def reset_index(self, **kwargs):
         level = kwargs.get("level", None)
         if level is not None:
diff --git a/modin/experimental/engines/omnisci_on_native/frame/expr.py b/modin/experimental/engines/omnisci_on_native/frame/expr.py
--- a/modin/experimental/engines/omnisci_on_native/frame/expr.py
+++ b/modin/experimental/engines/omnisci_on_native/frame/expr.py
@@ -103,6 +103,26 @@ def is_cmp_op(op):
     return op in _cmp_ops
 
 
+_logical_ops = {"and", "or"}
+
+
+def is_logical_op(op):
+    """
+    Check if operation is a logical one.
+
+    Parameters
+    ----------
+    op : str
+        Operation to check.
+
+    Returns
+    -------
+    bool
+        True for logical operations and False otherwise.
+    """
+    return op in _logical_ops
+
+
 class BaseExpr(abc.ABC):
     """
     An abstract base class for expression tree node.
@@ -133,6 +153,8 @@ class BaseExpr(abc.ABC):
         "le": "<=",
         "lt": "<",
         "ne": "<>",
+        "and": "AND",
+        "or": "OR",
     }
 
     preserve_dtype_math_ops = {"add", "sub", "mul", "mod", "floordiv", "pow"}
@@ -462,6 +484,8 @@ def _get_bin_op_res_type(self, op_name, lhs_dtype, rhs_dtype):
             return get_dtype(float)
         elif is_cmp_op(op_name):
             return get_dtype(bool)
+        elif is_logical_op(op_name):
+            return get_dtype(bool)
         else:
             raise NotImplementedError(f"unsupported binary operation {op_name}")
 


Test patch:
diff --git a/modin/experimental/engines/omnisci_on_native/test/test_dataframe.py b/modin/experimental/engines/omnisci_on_native/test/test_dataframe.py
--- a/modin/experimental/engines/omnisci_on_native/test/test_dataframe.py
+++ b/modin/experimental/engines/omnisci_on_native/test/test_dataframe.py
@@ -1720,6 +1720,16 @@ def filter(df, **kwargs):
 
         run_and_compare(filter, data=self.cmp_data)
 
+    def test_complex_filter(self):
+        def filter_and(df, **kwargs):
+            return df[(df.a < 5) & (df.b > 20)]
+
+        def filter_or(df, **kwargs):
+            return df[(df.a < 3) | (df.b > 40)]
+
+        run_and_compare(filter_and, data=self.cmp_data)
+        run_and_compare(filter_or, data=self.cmp_data)
+
 
 class TestDateTime:
     datetime_data = {