From 700aa5f994ff8bc3eaa06239d96595c7c95f6811 Mon Sep 17 00:00:00 2001 From: Shruthilaya Jaganathan Date: Tue, 18 Mar 2025 17:06:01 -0400 Subject: [PATCH] fix: Update EAP search config to override default --- src/sentry/search/eap/resolver.py | 6 ++++-- tests/sentry/search/eap/test_spans.py | 13 +++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/sentry/search/eap/resolver.py b/src/sentry/search/eap/resolver.py index 074dabc2a9f25f..b7879b5ff0a2cd 100644 --- a/src/sentry/search/eap/resolver.py +++ b/src/sentry/search/eap/resolver.py @@ -32,7 +32,6 @@ ) from sentry.api import event_search -from sentry.api.event_search import SearchConfig from sentry.exceptions import InvalidSearchQuery from sentry.search.eap import constants from sentry.search.eap.columns import ( @@ -164,7 +163,10 @@ def __resolve_query( try: parsed_terms = event_search.parse_search_query( querystring, - config=SearchConfig(wildcard_free_text=True), + config=event_search.SearchConfig.create_from( + event_search.default_config, + wildcard_free_text=True, + ), params=self.params.filter_params, get_field_type=self.get_field_type, get_function_result_type=self.get_field_type, diff --git a/tests/sentry/search/eap/test_spans.py b/tests/sentry/search/eap/test_spans.py index c92c3e3e10e8e4..9559e3d6f0b90e 100644 --- a/tests/sentry/search/eap/test_spans.py +++ b/tests/sentry/search/eap/test_spans.py @@ -28,6 +28,7 @@ from sentry.search.eap.types import SearchResolverConfig from sentry.search.events.types import SnubaParams from sentry.testutils.cases import TestCase +from sentry.testutils.helpers.datetime import freeze_time class SearchResolverQueryTest(TestCase): @@ -128,6 +129,18 @@ def test_greater_than_numeric_filter(self): ) assert having is None + def test_timestamp_relative_filter(self): + with freeze_time("2018-12-11 10:20:00"): + where, having, _ = self.resolver.resolve_query("timestamp:-24h") + assert where == TraceItemFilter( + comparison_filter=ComparisonFilter( + key=AttributeKey(name="sentry.timestamp", type=AttributeKey.Type.TYPE_STRING), + op=ComparisonFilter.OP_GREATER_THAN_OR_EQUALS, + value=AttributeValue(val_str="2018-12-10 10:20:00+00:00"), + ) + ) + assert having is None + def test_query_with_and(self): where, having, _ = self.resolver.resolve_query("span.description:foo span.op:bar") assert where == TraceItemFilter(