Skip to content

Commit a405afc

Browse files
danmichaeljonesDan Jones
andauthored
Add new is_null property filter (#58)
* Update ignore * Add new IsNullPropertyFilter filter response type * Update tests with new filter --------- Co-authored-by: Dan Jones <[email protected]>
1 parent 441e9ac commit a405afc

File tree

7 files changed

+34
-0
lines changed

7 files changed

+34
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,3 +169,6 @@ cython_debug/
169169

170170
# PyPI configuration file
171171
.pypirc
172+
173+
# MacOS
174+
.DS_Store

test/query_agent/test_query_model.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@ def json(self) -> dict:
135135
"longitude": 20.0,
136136
"max_distance_meters": 30.0,
137137
},
138+
{
139+
"filter_type": "is_null",
140+
"property_name": "prop_is_null",
141+
"is_null": True,
142+
},
138143
{
139144
"filter_type": "something_new",
140145
"property_name": "strange_property",
@@ -219,6 +224,11 @@ def json(self) -> dict:
219224
"longitude": 20.0,
220225
"max_distance_meters": 30.0,
221226
},
227+
{
228+
"filter_type": "is_null",
229+
"property_name": "prop_is_null",
230+
"is_null": True,
231+
},
222232
{
223233
"filter_type": "something_new",
224234
"property_name": "strange_property",

test/test_imports.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def test_class_exports():
5757
IntegerArrayPropertyFilter,
5858
IntegerPropertyAggregation,
5959
IntegerPropertyFilter,
60+
IsNullPropertyFilter,
6061
NumericMetrics,
6162
Operations,
6263
OperationStep,
@@ -118,6 +119,7 @@ def test_class_exports():
118119
IntegerArrayPropertyFilter,
119120
IntegerPropertyAggregation,
120121
IntegerPropertyFilter,
122+
IsNullPropertyFilter,
121123
GeoPropertyFilter,
122124
NumericMetrics,
123125
Operations,
@@ -198,6 +200,7 @@ def test_class_exports():
198200
"ProgressDetails",
199201
"ProgressMessage",
200202
"StreamedTokens",
203+
"IsNullPropertyFilter",
201204
]
202205

203206
assert hasattr(

weaviate_agents/classes/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
IntegerArrayPropertyFilter,
2424
IntegerPropertyAggregation,
2525
IntegerPropertyFilter,
26+
IsNullPropertyFilter,
2627
NumericMetrics,
2728
ProgressDetails,
2829
ProgressMessage,
@@ -94,4 +95,5 @@
9495
"ProgressMessage",
9596
"QueryWithCollection",
9697
"StreamedTokens",
98+
"IsNullPropertyFilter",
9799
]

weaviate_agents/classes/query.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
IntegerArrayPropertyFilter,
1515
IntegerPropertyAggregation,
1616
IntegerPropertyFilter,
17+
IsNullPropertyFilter,
1718
NumericMetrics,
1819
ProgressDetails,
1920
ProgressMessage,
@@ -66,4 +67,5 @@
6667
"ProgressMessage",
6768
"QueryWithCollection",
6869
"StreamedTokens",
70+
"IsNullPropertyFilter",
6971
]

weaviate_agents/query/classes/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
IntegerArrayPropertyFilter,
1717
IntegerPropertyAggregation,
1818
IntegerPropertyFilter,
19+
IsNullPropertyFilter,
1920
NumericMetrics,
2021
ProgressDetails,
2122
ProgressMessage,
@@ -66,4 +67,5 @@
6667
"ProgressMessage",
6768
"QueryWithCollection",
6869
"StreamedTokens",
70+
"IsNullPropertyFilter",
6971
]

weaviate_agents/query/classes/response.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class KnownFilterType(str, Enum):
3131
DATE = "date_range"
3232
DATE_ARRAY = "date_array"
3333
GEO = "geo"
34+
IS_NULL = "is_null"
3435

3536

3637
class KnownPropertyFilterBase(BaseModel):
@@ -159,6 +160,16 @@ class GeoPropertyFilter(KnownPropertyFilterBase):
159160
max_distance_meters: float
160161

161162

163+
class IsNullPropertyFilter(KnownPropertyFilterBase):
164+
"""Filter by property null state."""
165+
166+
filter_type: Literal[KnownFilterType.IS_NULL] = Field(
167+
repr=False, default=KnownFilterType.IS_NULL
168+
)
169+
170+
is_null: bool
171+
172+
162173
class UnknownPropertyFilter(BaseModel):
163174
"""Catch-all filter for unknown filter types, to preserve future back-compatibility."""
164175

@@ -193,6 +204,7 @@ def model_post_init(self, context: Any) -> None:
193204
DatePropertyFilter,
194205
DateArrayPropertyFilter,
195206
GeoPropertyFilter,
207+
IsNullPropertyFilter,
196208
UnknownPropertyFilter,
197209
]
198210

0 commit comments

Comments
 (0)