uranusjr commented on code in PR #33932:
URL: https://github.com/apache/airflow/pull/33932#discussion_r1312669463
##########
airflow/cli/commands/variable_command.py:
##########
@@ -86,7 +87,16 @@ 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
for k, v in var_json.items():
+ if action_on_existing != "overwrite":
+ exists_q = session.scalar(select(Variable).where(Variable.key ==
k))
Review Comment:
This could be a bit expensive. Something like this could be better
```python
existing_ids =
set(session.scalars(select(Variable.key).where(Variable.key.in_(var_json))))
if existing_ids and action_on_existing == "fail":
# Fail, existing variable keys found.
```
--
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]