xvrl: @dakra some tests would be nice
dakra: I added a test
diff --git a/pydruid/query.py b/pydruid/query.py
index af246a0..cd7c1cf 100644
--- a/pydruid/query.py
+++ b/pydruid/query.py
@@ -24,12 +24,6 @@ from pydruid.utils.dimensions import build_dimension
 from pydruid.utils.postaggregator import Postaggregator
 from pydruid.utils.query_utils import UnicodeWriter
 
-try:
-    import pandas
-except ImportError:
-    print('Warning: unable to import Pandas. The export_pandas method will not work.')
-    pass
-
 
 class Query(collections.MutableSequence):
     """
@@ -159,6 +153,8 @@ class Query(collections.MutableSequence):
                     0      7  2013-10-04T00:00:00.000Z         user_1
                     1      6  2013-10-04T00:00:00.000Z         user_2
         """
+        import pandas
+
         if self.result:
             if self.query_type == "timeseries":
                 nres = [list(v['result'].items()) + [('timestamp', v['timestamp'])]
@@ -250,11 +246,11 @@ class QueryBuilder(object):
                 query_dict['pagingSpec'] = val
             elif key == 'limit_spec':
                 query_dict['limitSpec'] = val
-            elif key == "filter":
+            elif key == "filter" and val is not None:
                 query_dict[key] = Filter.build_filter(val)
-            elif key == "having":
+            elif key == "having" and val is not None:
                 query_dict[key] = Having.build_having(val)
-            elif key == 'dimension':
+            elif key == 'dimension' and val is not None:
                 query_dict[key] = build_dimension(val)
             elif key == 'dimensions':
                 query_dict[key] = [build_dimension(v) for v in val]

Exception when `filter=None`
When building query if `filter=None` then an exception occurs:

```
File "/Users/se7entyse7en/Envs/viralize-web/lib/python2.7/site-packages/pydruid/utils/filters.py", line 61, in build_filter
    return filter_obj.filter['filter']
 AttributeError: 'NoneType' object has no attribute 'filter'
```

diff --git a/tests/test_query.py b/tests/test_query.py
index 64da17b..d84f35b 100644
--- a/tests/test_query.py
+++ b/tests/test_query.py
@@ -111,6 +111,44 @@ class TestQueryBuilder:
         # then
         assert query.query_dict == expected_query_dict
 
+    def test_build_query_none_type(self):
+        # given
+        expected_query_dict = {
+            'queryType': None,
+            'dataSource': 'things',
+            'aggregations': [{'fieldName': 'thing', 'name': 'count', 'type': 'count'}],
+            'filter': {'dimension': 'one', 'type': 'selector', 'value': 1},
+            'having': {'aggregation': 'sum', 'type': 'greaterThan', 'value': 1},
+            'dimension': 'dim1',
+        }
+
+        builder = QueryBuilder()
+
+        # when
+        builder_dict = {
+            'datasource': 'things',
+            'aggregations': {
+                'count': aggregators.count('thing'),
+            },
+            'filter': filters.Dimension('one') == 1,
+            'having': having.Aggregation('sum') > 1,
+            'dimension': 'dim1',
+        }
+        query = builder.build_query(None, builder_dict)
+
+        # then
+        assert query.query_dict == expected_query_dict
+
+        # you should be able to pass `None` to dimension/having/filter
+        for v in ['dimension', 'having', 'filter']:
+            expected_query_dict[v] = None
+            builder_dict[v] = None
+
+            query = builder.build_query(None, builder_dict)
+
+            assert query.query_dict == expected_query_dict
+
+
     def test_validate_query(self):
         # given
         builder = QueryBuilder()

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest mock
apt-get update apt-get install -y gcc
3.9
requirements/base.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
exceptiongroup==1.2.2
iniconfig==2.1.0
mock==5.2.0
packaging==24.2
pluggy==1.5.0
-e git+https://github.com/druid-io/pydruid.git@ce0982867d4bb3d809ba32c6563dadc8d8d6576f#egg=pydruid
pytest==8.3.5
six==1.17.0
tomli==2.2.1

name: pydruid
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - exceptiongroup==1.2.2
      - iniconfig==2.1.0
      - mock==5.2.0
      - packaging==24.2
      - pluggy==1.5.0
      - pytest==8.3.5
      - six==1.17.0
      - tomli==2.2.1
prefix: /opt/conda/envs/pydruid

tests/test_query.py::TestQueryBuilder::test_build_query_none_type
tests/test_query.py::TestQueryBuilder::test_build_query tests/test_query.py::TestQueryBuilder::test_validate_query tests/test_query.py::TestQuery::test_export_tsv tests/test_query.py::TestQuery::test_query_acts_as_a_wrapper_for_raw_result
pydruid/query.py
pydruid/query.py