Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: sqa deprecations for airflow providers #39293

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -1506,14 +1506,15 @@ def add_user(
user.username = username
user.email = email
user.active = True
self.get_session.add(user)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes the SQA 2.0 warning however I think we might could / should leave it as it is. SQA 2.0 complains about the User object that is being merged into a Session along the backref cascade. In SQA 2.0 this won't happen. But we add the User object explicit to session so IMO we should be fine without the change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that is Models from the FAB, which do not supports SA20 neither.

cc: @vincbeck maybe you have information about it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we discussed here we try to fix all warnings. So IMO this change looks good.

user.roles = role if isinstance(role, list) else [role]
if hashed_password:
user.password = hashed_password
else:
user.password = generate_password_hash(password)
self.get_session.add(user)
self.get_session.commit()
log.info(const.LOGMSG_INF_SEC_ADD_USER, username)

return user
except Exception as e:
log.error(const.LOGMSG_ERR_SEC_ADD_USER, e)
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/openlineage/utils/sql.py
Expand Up @@ -149,7 +149,7 @@ def create_information_schema_query(
sqlalchemy_engine: Engine | None = None,
) -> str:
"""Create query for getting table schemas from information schema."""
metadata = MetaData(sqlalchemy_engine)
metadata = MetaData()
select_statements = []
# Don't iterate over tables hierarchy, just pass it to query single information schema table
if use_flat_cross_db_query:
Expand Down