ephraimbuddy commented on code in PR #33932:
URL: https://github.com/apache/airflow/pull/33932#discussion_r1312799653


##########
airflow/cli/commands/variable_command.py:
##########
@@ -86,7 +87,18 @@ def variables_import(args):
         except JSONDecodeError:
             raise SystemExit("Invalid variables file.")
     suc_count = fail_count = 0
+    skipped = set()
+    action_on_existing = args.action_on_existing_key
+    if action_on_existing == "fail":
+        existing_key = 
set(session.scalars(select(Variable.key).where(Variable.key.in_(var_json))))
+        if existing_key:
+            raise SystemExit(f"Failed. These keys: 
{list(sorted(existing_key))}  already exists.")
+
     for k, v in var_json.items():
+        if action_on_existing == "skip":
+            if session.scalar(select(Variable).where(Variable.key == k)):
+                skipped.add(k)
+                continue

Review Comment:
   Is that better?
   



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