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


##########
sql/updates/36.sql:
##########
@@ -0,0 +1,179 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+\c texera_db
+
+SET search_path TO texera_db;
+
+BEGIN;
+
+-- The file resolver now requires an explicit resource-type prefix on dataset
+-- logical paths (/datasets/ownerEmail/datasetName/versionName/...) so other
+-- resource types (e.g. models) can be told apart by the prefix. Existing
+-- workflows store unprefixed dataset paths inside workflow.content and
+-- workflow_version.content, in two operator properties:
+--   * fileName            (scan-source operators): /owner/name/version/file
+--   * datasetVersionPath  (file-lister operator):  /owner/name/version
+-- This migration prepends the "datasets" segment to both.
+--
+-- A value is treated as a dataset path only when its first two segments match 
an
+-- existing (user.email, dataset.name) pair -- that pair is unique.
+-- Local file paths and URLs match no dataset and are left untouched.
+-- Already-prefixed values are skipped (idempotent). jsonb_set
+-- uses create_missing = false so absent properties are never added.
+
+DO $$
+DECLARE
+    wf_count INT := 0;
+    wv_count INT := 0;
+BEGIN
+    WITH affected AS (
+        SELECT w.wid
+        FROM workflow w,
+             jsonb_array_elements(w.content::jsonb -> 'operators') AS op,

Review Comment:
   Update: I have gone ahead and added the explicit guard anyway, all four 
jsonb_array_elements call sites now feed the expansion an empty array when 
operators isn't an array, with the WHERE checks kept as redundant row filters. 
   Used CASE rather than IS JSON for PG14/15 compatibility. Re-ran the full 
end-to-end suite afterwards.



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