:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(hogql): route metadata through language service (#100568)
Paweł Szczurb37c5e3e9e7b
diff --git a/posthog/api/services/query.py b/posthog/api/services/query.pyindex c11e29fcc0b0..2bd0f4fae29c 100644--- a/posthog/api/services/query.py+++ b/posthog/api/services/query.py@@ -75,7 +75,7 @@ def _language_service_eligible(query: HogQLAutocomplete | HogQLMetadata) -> booland query.modifiers is None)if isinstance(query, HogQLMetadata):- return common and query.variables is None and not query.debug and not query.indexUsage+ return common and query.variables is None and not query.debugreturn commondiff --git a/posthog/api/test/test_query_service.py b/posthog/api/test/test_query_service.pyindex 2c29affa2e74..ab5bdbf0b39a 100644--- a/posthog/api/test/test_query_service.py+++ b/posthog/api/test/test_query_service.py@@ -34,7 +34,7 @@ from posthog.hogql.direct_connection import INVALID_CONNECTION_ID_ERRORfrom posthog.hogql.errors import ResolutionErrorfrom posthog.hogql.language_service import LanguageServiceResult-from posthog.api.services.query import process_query_model+from posthog.api.services.query import _language_service_eligible, process_query_modelfrom posthog.exceptions import DatabaseSchemaUnavailablefrom posthog.models import Team, User@@ -47,6 +47,11 @@ from products.warehouse_sources.backend.facade.types import ExternalDataSourceTyclass TestLanguageServiceRouting(SimpleTestCase):+ def test_hogql_metadata_with_index_usage_is_language_service_eligible(self) -> None:+ query = HogQLMetadata(query="SELECT * FROM events", language=HogLanguage.HOG_QL, indexUsage=True)++ assert _language_service_eligible(query)+@patch("posthog.api.services.query._language_service_call")def test_hogql_autocomplete_uses_language_service_response(self, mock_language_service_call: MagicMock):mock_language_service_call.return_value = LanguageServiceResult(