tanishqgandhi1908 commented on code in PR #6502: URL: https://github.com/apache/texera/pull/6502#discussion_r3769944540
########## 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: The guard does run first, so there's no abort. EXPLAIN shows jsonb_typeof(...) = 'array' applied as a Filter on the base-table Seq Scan, with the jsonb_array_elements function scan as the inner side of the nested loop — so it only ever sees rows that already passed. That's expected, the predicate references a single relation, so it's pushed to that relation's scan. Also verified end-to-end: ran this migration against seeded rows where operators is an object, a string, and missing entirely — it completed successfully and left those rows untouched. -- 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]
