This is an automated email from the ASF dual-hosted git repository.
linxinyuan pushed a commit to branch xinyuan-loop-feb
in repository https://gitbox.apache.org/repos/asf/texera.git
The following commit(s) were added to refs/heads/xinyuan-loop-feb by this push:
new cd90b928c0 update
cd90b928c0 is described below
commit cd90b928c03e1dbbf281d4ece7cc143faa1448e3
Author: Xinyuan Lin <[email protected]>
AuthorDate: Thu Mar 26 03:43:45 2026 -0700
update
---
.../main/python/core/storage/document_factory.py | 35 ++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/amber/src/main/python/core/storage/document_factory.py
b/amber/src/main/python/core/storage/document_factory.py
index 8a4d6fe3c5..b2b81831cc 100644
--- a/amber/src/main/python/core/storage/document_factory.py
+++ b/amber/src/main/python/core/storage/document_factory.py
@@ -135,3 +135,38 @@ class DocumentFactory:
raise NotImplementedError(
f"Unsupported URI scheme: {parsed_uri.scheme} for opening the
document"
)
+
+ @staticmethod
+ def document_exists(uri: str) -> bool:
+ """Return True if the document exists for the given URI.
+
+ This is a non-throwing helper for callers that want to probe storage
+ existence (e.g., optional state materialization) without relying on
+ exception control-flow.
+
+ Currently supports the same URI schemes/resource types as
+ `open_document`.
+ """
+
+ parsed_uri = urlparse(uri)
+ if parsed_uri.scheme != VFSURIFactory.VFS_FILE_URI_SCHEME:
+ raise NotImplementedError(
+ f"Unsupported URI scheme: {parsed_uri.scheme} for checking
document existence"
+ )
+
+ _, _, _, resource_type = VFSURIFactory.decode_uri(uri)
+ match resource_type:
+ case VFSResourceType.RESULT:
+ namespace = StorageConfig.ICEBERG_TABLE_RESULT_NAMESPACE
+ case VFSResourceType.STATE:
+ namespace = "state"
+ case _:
+ raise ValueError(f"Resource type {resource_type} is not
supported")
+
+ storage_key = DocumentFactory.sanitize_uri_path(parsed_uri)
+ table = load_table_metadata(
+ IcebergCatalogInstance.get_instance(),
+ namespace,
+ storage_key,
+ )
+ return table is not None