Skip to content

Commit 6161766

Browse files
ericdeloreficentkathole
authored andcommitted
fix: Raise Trino monitoring query errors other than a missing table
query_monitoring_metrics returned [] for every TrinoQueryError. A missing table or schema still means no metrics yet; any other query error is now logged and re-raised, as ensure_monitoring_tables already does. An empty result made DQMJobManager.get_job report a job as missing, so update_status dropped status changes without an error. Signed-off-by: Eric Del Orefice <[email protected]>
1 parent fe27230 commit 6161766

2 files changed

Lines changed: 51 additions & 1 deletion

File tree

‎sdk/python/feast/infra/offline_stores/contrib/trino_offline_store/tests/test_trino_monitoring.py‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,48 @@ def test_query_monitoring_metrics_raises_on_connection_error(repo_config):
768768
)
769769

770770

771+
def test_query_monitoring_metrics_missing_schema_is_empty(repo_config):
772+
mock_client = MagicMock()
773+
mock_client.execute_query.side_effect = TrinoQueryError(
774+
{"errorName": "SCHEMA_NOT_FOUND", "message": "Schema does not exist"}
775+
)
776+
777+
with patch(
778+
"feast.infra.offline_stores.contrib.trino_offline_store.trino._get_trino_client",
779+
return_value=mock_client,
780+
):
781+
res = TrinoOfflineStore.query_monitoring_metrics(
782+
config=repo_config,
783+
project="test_project",
784+
metric_type="feature",
785+
)
786+
assert res == []
787+
788+
789+
@pytest.mark.parametrize(
790+
"error_name", ["ACCESS_DENIED", "SYNTAX_ERROR", "GENERIC_INTERNAL_ERROR"]
791+
)
792+
def test_query_monitoring_metrics_raises_on_other_query_errors(repo_config, error_name):
793+
# Only a missing table or schema means "no metrics yet". Anything else must not
794+
# reach the monitoring UI as an empty result.
795+
mock_client = MagicMock()
796+
mock_client.execute_query.side_effect = TrinoQueryError(
797+
{"errorName": error_name, "message": "query failed"}
798+
)
799+
800+
with patch(
801+
"feast.infra.offline_stores.contrib.trino_offline_store.trino._get_trino_client",
802+
return_value=mock_client,
803+
):
804+
with pytest.raises(TrinoQueryError) as exc_info:
805+
TrinoOfflineStore.query_monitoring_metrics(
806+
config=repo_config,
807+
project="test_project",
808+
metric_type="feature",
809+
)
810+
assert exc_info.value.error_name == error_name
811+
812+
771813
def test_clear_monitoring_baseline_falls_back_on_query_error(repo_config):
772814
mock_client = MagicMock()
773815
executed_queries = []

‎sdk/python/feast/infra/offline_stores/contrib/trino_offline_store/trino.py‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,12 +719,20 @@ def query_monitoring_metrics(
719719
df = df.sort_values(order_col_name)
720720
return [normalize_monitoring_row(row.to_dict()) for _, row in df.iterrows()]
721721
except TrinoQueryError as e:
722+
if e.error_name in ("TABLE_NOT_FOUND", "SCHEMA_NOT_FOUND"):
723+
# The monitoring table has not been created yet: no metrics so far.
724+
logger.debug(
725+
"Monitoring metrics table %s does not exist yet: %s",
726+
full_table_name,
727+
e,
728+
)
729+
return []
722730
logger.debug(
723731
"Failed to query monitoring metrics from %s: %s",
724732
full_table_name,
725733
e,
726734
)
727-
return []
735+
raise
728736

729737
@staticmethod
730738
def clear_monitoring_baseline(

0 commit comments

Comments
 (0)