-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Date range filter #12
Conversation
@@ -29,8 +30,19 @@ public void Visit(RangeClause rangeClause) | |||
{ | |||
// general "is between" filter on numeric fields uses a rangeClause query with GTE+LT (not LTE like above) | |||
EnsureClause.IsNotNull(rangeClause.LTValue, nameof(rangeClause.LTValue)); | |||
|
|||
rangeClause.KustoQL = $"{rangeClause.FieldName} >= {rangeClause.GTEValue} and {rangeClause.FieldName} < {rangeClause.LTValue}"; | |||
var t = ClauseFieldTypeProcessor.GetType(schemaRetriever, rangeClause.FieldName).Result; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this be awaited?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it should. How about I open a new issue to change this as a new user story?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1303:Do not pass literals as localized parameters", Justification = "Resources are not supported yet.")] | ||
public static async Task<ClauseFieldType> GetType(ISchemaRetriever schemaRetriever, string fieldName) | ||
{ | ||
if (schemaRetriever == null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ensure can be used?
case ClauseFieldType.Text: | ||
rangeClause.KustoQL = $"{rangeClause.FieldName} >= {rangeClause.GTEValue} and {rangeClause.FieldName} < {rangeClause.LTValue}"; | ||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Range clause can't work with text types in ADX. this case should throw an error.
- Something is wrong in the tests since a query like:
field >= aaa and field < bbb
should fail since you're missing quotes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
@@ -76,7 +78,7 @@ public string Visit_WithValidTermQuery_ReturnsValidReponse() | |||
var es = phraseQuery.ESQuery; | |||
Assert.NotNull(es); | |||
|
|||
var visitor = new ElasticSearchDSLVisitor(SchemaRetrieverMock.CreateMockSchemaRetriever()); | |||
var visitor = VisitorTestsUtils.CreateRootVisitor(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A) here you are using the utils class
@@ -57,7 +59,8 @@ public string Visit_WithValidRangeQuery_ReturnsValidResponse() | |||
var es = rangeQuery.ESQuery; | |||
Assert.NotNull(es); | |||
|
|||
var visitor = new ElasticSearchDSLVisitor(SchemaRetrieverMock.CreateMockSchemaRetriever()); | |||
var visitor = new ElasticSearchDSLVisitor(SchemaRetrieverMock.CreateMockSchemaRetriever("days", "long")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
b) Here you are using the new ESDSLvisitor statement.
/// Have the ISchemaRetriever initialised by the default visitor. | ||
/// </summary> | ||
/// <param name="visitor"></param> | ||
internal static void AddRootDsl(ElasticSearchDSLVisitor visitor) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Name is not so clear.
e.g.
WrapWithRootDslAndAccept (maybe too long)
AddRootAndAccept?
AcceptWithRoot?
but AddRootDsl which gets a visitor. seems like the visitor is the one being added to (or added into) with the root....
}, | ||
IndexName = "someindex", | ||
}; | ||
visitor.Visit(dsl); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, the method says: AddRootDsl
but at the end you call visit... so its much more that just add root. it actually visits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, I think you shouldnt use visitor.Visit but dsl.Accept(visitor)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I renamed the method, however, I kept Visit since I am not changing existing tests code.
{ | ||
var visitor = new ElasticSearchDSLVisitor(SchemaRetrieverMock.CreateMockSchemaRetriever()); | ||
AddRootDsl(visitor); | ||
return visitor; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here you have an issue. you 'AddRootDsl' which already visits and then you return a visitor. needs some refactoring to be clearer
_ => false, | ||
}; | ||
Ensure.IsNotNullOrEmpty(fieldName, nameof(fieldName)); | ||
var t = await ClauseFieldTypeProcessor.GetType(schemaRetriever, fieldName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var t = await ClauseFieldTypeProcessor.GetType(schemaRetriever, fieldName); | |
var fieldType = await ClauseFieldTypeProcessor.GetType(schemaRetriever, fieldName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the right direction, however I think there is some mixup in the addRootDsl method
@@ -379,15 +380,15 @@ public string TestComplexWildcardQuery(string queryString) | |||
public string TestPrefixQuery(string queryString) | |||
{ | |||
var query = JsonConvert.DeserializeObject<Query>(queryString); | |||
var visitor = new ElasticSearchDSLVisitor(SchemaRetrieverMock.CreateMockSchemaRetriever()); | |||
var visitor = VisitorTestsUtils.CreateAndVisitRootVisitor(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all of those tests (like this) are now visited twice? was once before...
Added support for date range filter