Skip to content

Commit 89d6298

Browse files
committed
Build full S3 path in ai_parse_document metadata
1 parent 26e1cca commit 89d6298

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

databend_aiserver/udfs/docparse.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,20 @@ def ai_parse_document(stage_location: StageLocation, path: str) -> Dict[str, Any
240240
# Output shape:
241241
# { "chunks": [...], "metadata": {...}, "error_information": [...] }
242242
resolved_path = resolve_stage_subpath(stage_location, path)
243-
root_prefix = ""
244-
storage_root = stage_location.storage.get("root") if stage_location.storage else ""
245-
if storage_root:
246-
root_prefix = storage_root.rstrip("/")
247-
full_path = f"{root_prefix}/{resolved_path}" if root_prefix else resolved_path
243+
storage = stage_location.storage or {}
244+
storage_root = str(storage.get("root", "") or "")
245+
bucket = storage.get("bucket") or storage.get("name")
246+
247+
if storage_root.startswith("s3://"):
248+
base = storage_root.rstrip("/")
249+
full_path = f"{base}/{resolved_path}"
250+
elif bucket:
251+
base = f"s3://{bucket}"
252+
if storage_root:
253+
base = f"{base}/{storage_root.strip('/')}"
254+
full_path = f"{base}/{resolved_path}"
255+
else:
256+
full_path = resolved_path or path
248257

249258
# Keep metadata first for predictable JSON ordering.
250259
payload: Dict[str, Any] = OrderedDict(

0 commit comments

Comments
 (0)