From c43cf1a6629b5d7e2efe3b9ddf11fe5a6454b50e Mon Sep 17 00:00:00 2001
From: Deepyaman Datta <deepyaman.datta@utexas.edu>
Date: Tue, 11 Jun 2024 09:39:20 -0600
Subject: [PATCH] feat(selectors): parse Python types in `s.of_type`

---
 ibis/selectors.py                 | 2 +-
 ibis/tests/expr/test_selectors.py | 9 +++++++--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/ibis/selectors.py b/ibis/selectors.py
index 1b347a27eac4..2f51a1592363 100644
--- a/ibis/selectors.py
+++ b/ibis/selectors.py
@@ -264,7 +264,7 @@ def of_type(dtype: dt.DataType | str | type[dt.DataType]) -> Predicate:
         else:
             dtype = dt.dtype(dtype)
             predicate = lambda col: col.type() == dtype
-    elif inspect.isclass(dtype):
+    elif inspect.isclass(dtype) and issubclass(dtype, dt.DataType):
         predicate = lambda col: isinstance(col.type(), dtype)
     else:
         dtype = dt.dtype(dtype)
diff --git a/ibis/tests/expr/test_selectors.py b/ibis/tests/expr/test_selectors.py
index 47d4051fd2a4..62c7821e91af 100644
--- a/ibis/tests/expr/test_selectors.py
+++ b/ibis/tests/expr/test_selectors.py
@@ -49,8 +49,13 @@ def test_numeric(t):
 
 @pytest.mark.parametrize(
     ("obj", "expected"),
-    [(dt.Array, ("c", "g")), ("float", ("e",)), (dt.Decimal(3, 1), ("f",))],
-    ids=["type", "string", "instance"],
+    [
+        (dt.Array, ("c", "g")),
+        ("float", ("e",)),
+        (dt.Decimal(3, 1), ("f",)),
+        (int, ("a",)),
+    ],
+    ids=["dtype", "string", "instance", "type"],
 )
 def test_of_type(t, obj, expected):
     assert t.select(s.of_type(obj)).equals(t.select(*expected))