tirkarthi commented on PR #28256:
URL: https://github.com/apache/airflow/pull/28256#issuecomment-1399415469
Thanks @potiuk , I guess the following does the similar without a migration.
Lets say there are 3 errors with c.py deleted. Then `self._file_paths` will be
`["a.py", "b.zip"]` and it will create a query to find filenames that don't
start with b.zip and not equal to a.py thus deleting only c.py error entry.
- a.py
- b.zip/c.py
- c.py (file deleted)
```python
query = session.query(errors.ImportError)
if self._file_paths:
for file_path in self._file_paths:
if file_path.endswith(".zip"):
query =
query.filter(~(errors.ImportError.filename.startswith(file_path)))
else:
query = query.filter(errors.ImportError.filename !== file_path)
query.delete(synchronize_session="fetch")
session.commit()
```
```python
with create_session() as session:
print(session.query(ImportError).filter(~(ImportError.filename.startswith("b.zip"))).filter(ImportError.filename
!= 'a.py'))
SELECT import_error.id AS import_error_id, import_error.timestamp AS
import_error_timestamp, import_error.filename AS import_error_filename,
import_error.stacktrace AS import_error_stacktrace
FROM import_error
WHERE (import_error.filename NOT LIKE %(filename_1)s || '%%') AND
import_error.filename != %(filename_2)s
```
--
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]