tanishqgandhi1908 commented on code in PR #6860:
URL: https://github.com/apache/texera/pull/6860#discussion_r3781185370


##########
common/workflow-core/src/main/scala/org/apache/texera/amber/core/storage/FileResolver.scala:
##########
@@ -76,106 +85,203 @@ object FileResolver {
   }
 
   /**
-    * Parses a dataset logical path into its components, or None if it is not 
a well-formed dataset path.
-    * Expected format: 
/datasets/ownerEmail/datasetName/versionName/fileRelativePath
-    * The legacy unprefixed format is also accepted.
+    * Parses a versioned-resource file path into its components, or None if it 
is not well-formed.
+    *
+    * Two accepted forms:
+    *   - Prefixed:  
/<prefix>/ownerEmail/resourceName/versionName/fileRelativePath (>= 5 segments)
+    *     where the leading segment names a known [[ResourceType]] (dataset, 
model, …), so a single
+    *     caller can dispatch to the right backing table.
+    *   - Legacy unprefixed (datasets only, backward compat): 
/ownerEmail/datasetName/versionName/
+    *     fileRelativePath (>= 4 segments), resolved as a dataset. Models are 
new and always require
+    *     the /models/ prefix.
     *
-    * @param fileName The file path to parse
-    * @return Some((ownerEmail, datasetName, versionName, fileRelativePath)) 
if valid, None otherwise
+    * @param fileName the file path to parse
+    * @return Some((resourceType, ownerEmail, resourceName, versionName, 
fileRelativePath)) if valid,
+    *         None otherwise
     */
-  private def parseDatasetFilePath(
+  private def parsePrefixedPath(
       fileName: String
-  ): Option[(String, String, String, Array[String])] = {
+  ): Option[(ResourceType.Value, String, String, String, Array[String])] = {
     val filePath = Paths.get(fileName)
     val pathSegments = (0 until 
filePath.getNameCount).map(filePath.getName(_).toString).toArray
 
-    // TODO(datasets-prefix): require the prefix once all stored paths are 
migrated (36.sql).
-    if (pathSegments.headOption.exists(ResourceType.isValidPrefix)) {
-      if (pathSegments.length < 5) None
-      else Some((pathSegments(1), pathSegments(2), pathSegments(3), 
pathSegments.drop(4)))
-    } else if (pathSegments.length >= 4) {
-      Some((pathSegments(0), pathSegments(1), pathSegments(2), 
pathSegments.drop(3)))
-    } else None
+    pathSegments.headOption.flatMap(ResourceType.fromPrefix) match {
+      case Some(resourceType) =>
+        // Prefixed: /<prefix>/ownerEmail/resourceName/versionName/<file> (>= 
5 segments).
+        if (pathSegments.length < 5) None
+        else
+          Some(
+            (resourceType, pathSegments(1), pathSegments(2), pathSegments(3), 
pathSegments.drop(4))
+          )
+      case None =>
+        // Legacy unprefixed dataset path (backward compat): 
/ownerEmail/datasetName/versionName/<file>.
+        // TODO(datasets-prefix): require the prefix once all stored paths are 
migrated (36.sql).
+        if (pathSegments.length >= 4)

Review Comment:
   Intentional. We supports legacy unprefixed dataset paths for backward 
compatibility. Removing it would break already-stored paths. Models always 
require the /models/ prefix — only datasets accept the legacy form.



-- 
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