Skip to content

Commit 5caf833

Browse files
TsengSRTsengSR
andauthored
.Net: Bug: Qdrant DateTime Range filter set incorrectly (#12936)
### Motivation and Context Fixes #12934 The filter translation layer set all 4 (Gt, Gte, Lt, Lte) properties of the datetime range object, which resulted in always 0 results being returned as no rows can be greater and smaller than the set date at the same time. ### Description At first I added some simple tests and an `DateTimeOffset` properties to the unit tests, which failed. After debugging and finding the issue, I made the changes and the tests passed. I was only able to test the Qdrant and InMemory integrations though, due to lack of locally running and preconfigured databases. **Open** ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [ ] I didn't break anyone 😄 Co-authored-by: TsengSR <kpgit@atomic-gear.net>
1 parent 5124a1b commit 5caf833

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

dotnet/src/VectorData/Qdrant/QdrantFilterTranslator.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,10 @@ bool TryProcessComparison(Expression first, Expression second, [NotNullWhen(true
133133
Key = property.StorageName,
134134
DatetimeRange = new DatetimeRange
135135
{
136-
Gt = Timestamp.FromDateTimeOffset(v),
137-
Gte = Timestamp.FromDateTimeOffset(v),
138-
Lt = Timestamp.FromDateTimeOffset(v),
139-
Lte = Timestamp.FromDateTimeOffset(v)
136+
Gt = comparison.NodeType == ExpressionType.GreaterThan ? Timestamp.FromDateTimeOffset(v) : null,
137+
Gte = comparison.NodeType == ExpressionType.GreaterThanOrEqual ? Timestamp.FromDateTimeOffset(v) : null,
138+
Lt = comparison.NodeType == ExpressionType.LessThan ? Timestamp.FromDateTimeOffset(v) : null,
139+
Lte = comparison.NodeType == ExpressionType.LessThanOrEqual ? Timestamp.FromDateTimeOffset(v) : null
140140
}
141141
},
142142

0 commit comments

Comments
 (0)