|
21 | 21 | from typing import Any, Dict, Iterable, List, Optional |
22 | 22 |
|
23 | 23 | from databend_udf import StageLocation, udf |
24 | | -from opendal import exceptions as opendal_exceptions |
25 | | - |
26 | 24 | from databend_aiserver.stages.operator import ( |
27 | 25 | StageConfigurationError, |
28 | 26 | get_operator, |
29 | 27 | resolve_stage_subpath, |
| 28 | + resolve_storage_uri, |
30 | 29 | ) |
| 30 | +from opendal import exceptions as opendal_exceptions |
31 | 31 |
|
32 | 32 |
|
33 | 33 | def _format_last_modified(value: Any) -> Optional[str]: |
@@ -119,14 +119,12 @@ def _collect_stage_files( |
119 | 119 | input_types=["INT"], |
120 | 120 | result_type=[ |
121 | 121 | ("stage_name", "VARCHAR"), |
122 | | - ("relative_path", "VARCHAR"), |
123 | 122 | ("path", "VARCHAR"), |
124 | | - ("is_dir", "BOOLEAN"), |
125 | | - ("size", "BIGINT"), |
126 | | - ("mode", "VARCHAR"), |
127 | | - ("content_type", "VARCHAR"), |
| 123 | + ("fullpath", "VARCHAR"), |
| 124 | + ("size", "UINT64"), |
| 125 | + ("last_modified", "VARCHAR"), |
128 | 126 | ("etag", "VARCHAR"), |
129 | | - ("last_modified", "TIMESTAMP"), |
| 127 | + ("content_type", "VARCHAR"), |
130 | 128 | ], |
131 | 129 | name="ai_list_files", |
132 | 130 | ) |
@@ -170,22 +168,19 @@ def ai_list_files( |
170 | 168 | metadata = op.stat(entry.path) |
171 | 169 | # Check if directory using mode (opendal.Metadata doesn't have is_dir()) |
172 | 170 | # Mode for directories typically has specific bits set, or path ends with / |
173 | | - is_dir = entry.path.endswith('/') |
174 | 171 |
|
175 | 172 | # Convert mode to string if it exists, otherwise None |
176 | | - mode_str = str(metadata.mode) if metadata.mode is not None else None |
177 | | - last_modified = _format_last_modified(getattr(metadata, "last_modified", None)) |
178 | 173 |
|
179 | 174 | yield { |
180 | 175 | "stage_name": stage_location.stage_name, |
181 | | - "relative_path": stage_location.relative_path, |
182 | 176 | "path": entry.path, |
183 | | - "is_dir": is_dir, |
| 177 | + "fullpath": resolve_storage_uri(stage_location, entry.path), |
184 | 178 | "size": metadata.content_length, |
185 | | - "mode": mode_str, |
186 | | - "content_type": metadata.content_type, |
| 179 | + "last_modified": _format_last_modified( |
| 180 | + getattr(metadata, "last_modified", None) |
| 181 | + ), |
187 | 182 | "etag": metadata.etag, |
188 | | - "last_modified": last_modified, |
| 183 | + "content_type": metadata.content_type, |
189 | 184 | } |
190 | 185 |
|
191 | 186 | except Exception as e: |
|
0 commit comments