This commit is contained in:
2026-06-05 15:01:34 +03:00
parent 50180aaa14
commit 4cef6af041
27 changed files with 13547 additions and 892 deletions

View File

@@ -115,6 +115,20 @@ class AsyncAPIClient:
self._tokens = cached_tokens
self._authenticated = True
app_logger.info("[async_authenticate][CacheHit] Reusing cached Superset auth tokens for %s", self.base_url)
# Refresh CSRF token to set matching session cookie on this httpx client
try:
csrf_url = f"{self.api_base_url}/security/csrf_token/"
csrf_resp = await self._client.get(
csrf_url,
headers={"Authorization": f"Bearer {cached_tokens['access_token']}"},
)
if csrf_resp.is_success:
new_csrf = csrf_resp.json().get("result")
if new_csrf:
self._tokens["csrf_token"] = new_csrf
SupersetAuthCache.set(self._auth_cache_key, self._tokens)
except Exception:
pass
return self._tokens
auth_lock = self._get_auth_lock(self._auth_cache_key)
async with auth_lock:
@@ -123,6 +137,19 @@ class AsyncAPIClient:
self._tokens = cached_tokens
self._authenticated = True
app_logger.info("[async_authenticate][CacheHitAfterWait] Reusing cached Superset auth tokens for %s", self.base_url)
try:
csrf_url = f"{self.api_base_url}/security/csrf_token/"
csrf_resp = await self._client.get(
csrf_url,
headers={"Authorization": f"Bearer {cached_tokens['access_token']}"},
)
if csrf_resp.is_success:
new_csrf = csrf_resp.json().get("result")
if new_csrf:
self._tokens["csrf_token"] = new_csrf
SupersetAuthCache.set(self._auth_cache_key, self._tokens)
except Exception:
pass
return self._tokens
with belief_scope("AsyncAPIClient.authenticate"):
app_logger.info("[async_authenticate][Enter] Authenticating to %s", self.base_url)

View File

@@ -92,6 +92,18 @@ class TranslationPreview:
config_hash = self._executor.compute_config_hash(job)
dict_snapshot_hash = self._executor.compute_dict_snapshot_hash(job_id)
source_rows = await self._executor.fetch_sample_rows(job=job, sample_size=sample_size, env_id=env_id)
logger.reason(
f"Fetched {len(source_rows)} sample rows for preview",
extra={
"src": "preview",
"payload": {
"row_count": len(source_rows),
"translation_column": job.translation_column,
"first_row_keys": list(source_rows[0].keys())[:10] if source_rows else [],
"first_row_translation_col": str(source_rows[0].get(job.translation_column, "MISSING")[:100]) if source_rows else "NO_ROWS",
},
},
)
if not source_rows:
raise ValueError("No rows returned from datasource for preview")

View File

@@ -60,20 +60,13 @@ class PreviewExecutor:
dataset_id=int(job.source_datasource_id), dataset_record=dataset_detail,
template_params={}, effective_filters=[],
)
# Build column list from dataset schema for explicit column projection
column_names = [
col["name"] for col in dataset_detail.get("columns", [])
if col.get("name") and col.get("is_active", True)
]
queries = query_context.get("queries", [])
if queries:
queries[0]["row_limit"] = sample_size
queries[0]["columns"] = column_names or []
queries[0]["metrics"] = []
queries[0].pop("result_type", None)
query_context["result_type"] = "query"
queries[0].pop("columns", None)
queries[0]["metrics"] = []
query_context["result_type"] = "samples"
form_data = query_context.get("form_data", {})
form_data.pop("query_mode", None)

View File

@@ -187,7 +187,14 @@ class SupersetSqlLabExecutor:
headers={"Content-Type": "application/json"},
)
logger.reason("SQL Lab endpoint succeeded", extra={
"endpoint": endpoint,
"src": "superset_executor",
"payload": {
"endpoint": endpoint,
"response_keys": list(response.keys()) if isinstance(response, dict) else type(response).__name__,
"response_status": response.get("status") if isinstance(response, dict) else "N/A",
"has_query_id": "query_id" in (response if isinstance(response, dict) else {}),
"has_errors": "errors" in (response if isinstance(response, dict) else {}),
},
})
except Exception as ep_err:
logger.explore("SQL Lab execute failed", extra={
@@ -214,19 +221,22 @@ class SupersetSqlLabExecutor:
# Log full response for debugging if query_id is missing
if not query_id:
logger.explore("No query_id from SQL Lab execute", extra={
"database_id": db_id,
"status": status,
"raw_response_keys": list(result.keys()),
"raw_response_preview": json.dumps(result)[:2000],
})
logger.explore("No query_id from SQL Lab execute", error="response missing query_id",
extra={"src": "superset_executor", "payload": {
"database_id": db_id,
"status": status,
"raw_response_keys": list(result.keys()),
"raw_response_preview": json.dumps(result)[:2000],
}})
logger.reason("SQL Lab execute response (no query_id)", extra={
"database_id": db_id,
"status": status,
"response_keys": list(result.keys()),
"has_result": "result" in result,
"has_query": "query" in result,
"raw_preview": json.dumps(result)[:2000],
"src": "superset_executor", "payload": {
"database_id": db_id,
"status": status,
"response_keys": list(result.keys()),
"has_result": "result" in result,
"has_query": "query" in result,
"raw_preview": json.dumps(result)[:2000],
}
})
logger.reason("SQL Lab execute response", {