gopidesupavan commented on code in PR #69575:
URL: https://github.com/apache/airflow/pull/69575#discussion_r3602299483


##########
providers/common/dataquality/src/airflow/providers/common/dataquality/backends/object_storage.py:
##########
@@ -0,0 +1,256 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""
+Object-storage results backend.
+
+Each DQ check writes a keyed JSON document plus read indexes optimized for the 
UI:
+
+    
runs/by_task/dag_id=<dag>/task_id=<task>/date=<2026-07-04>/<started_at>__<run_uid>.json
+        Canonical run record: ``{"run": ..., "results": [...], "summary": 
...}``.
+
+    
runs/by_task_instance/dag_id=<dag>/task_id=<task>/<safe_run_id>__<map_index>.json
+        Latest result for a task-instance page. Last write wins across retries.
+
+    
rules/by_task_rule/dag_id=<dag>/task_id=<task>/rule_uid=<uid>/<started_at>__<run_uid>.json
+        One rule result plus run context: ``{"run": ..., "result": ...}``.
+
+The duplicate files are intentional read indexes: DQ tasks write once, while 
the UI reads
+many times. Keeping these indexes avoids scanning all task runs for common UI 
views.
+"""
+
+from __future__ import annotations
+
+import json
+import logging
+from datetime import datetime, timezone
+from typing import Any
+
+from airflow.providers.common.dataquality.results import DQRun, RuleResult, 
build_summary
+from airflow.sdk import ObjectStoragePath
+
+log = logging.getLogger(__name__)
+
+
+class ObjectStorageResultsBackend:
+    """Persist DQ results as JSON files via ``ObjectStoragePath``."""
+
+    def __init__(self, results_path: str, conn_id: str | None = None) -> None:
+        self.root = ObjectStoragePath(results_path, conn_id=conn_id)
+
+    def write_run(self, run: DQRun, results: list[RuleResult]) -> None:
+        timestamp = run.started_at or datetime.now(tz=timezone.utc).isoformat()
+        compact_ts = self._get_safe_key(timestamp)
+        payload = self._build_run_payload(run, results)
+
+        self._write_run_file(run, timestamp[:10], compact_ts, payload)
+        self._write_task_instance_index(run, payload)
+        self._write_rule_indexes(run, results, timestamp)
+
+    def read_task_rule_history(
+        self, dag_id: str, task_id: str, rule_uid: str, limit: int = 100, 
before: str | None = None

Review Comment:
   make sense changed 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to