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(backfill): update a_urn column during entity table backfill #491

Merged
merged 2 commits into from
Dec 19, 2024

Conversation

jsdonn
Copy link
Contributor

@jsdonn jsdonn commented Dec 19, 2024

Summary

Currently, backfillEntityTables API does not backfill the a_urn column. This is an oversight since we never expected to need to backfill this column and it cannot be backfilled like other aspect columns. Thus, the solution is to add it to the upsert SQL which is called in EbeanLocalAccess::add.

Testing Done

./gradlew build

Checklist

@jsdonn jsdonn marked this pull request as ready for review December 19, 2024 02:48
private static final String SQL_UPSERT_ASPECT_WITH_URN_TEMPLATE =
"INSERT INTO %s (urn, a_urn, %s, lastmodifiedon, lastmodifiedby) VALUE (:urn, :a_urn, :metadata, :lastmodifiedon, :lastmodifiedby) "
+ "ON DUPLICATE KEY UPDATE %s = :metadata, lastmodifiedon = :lastmodifiedon;";
+ "ON DUPLICATE KEY UPDATE %s = :metadata, lastmodifiedon = :lastmodifiedon, a_urn = :a_urn;";
Copy link
Contributor

Choose a reason for hiding this comment

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

would this logic only be called when a_urn column presents? how to ensure this or can you clarify in the comment a_urn always exists when this is called and why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Basically yes, there is a flag that is passed into all of the SQL statement methods that indicates whether the a_urn column exists. If it does, then use template 1, if not, use template 2

@@ -43,7 +43,7 @@ public void testCreateUpsertAspectSql() {
String expectedSql =
"INSERT INTO metadata_entity_foo (urn, a_urn, a_aspectfoo, lastmodifiedon, lastmodifiedby) VALUE (:urn, "
+ ":a_urn, :metadata, :lastmodifiedon, :lastmodifiedby) ON DUPLICATE KEY UPDATE a_aspectfoo = :metadata,"
+ " lastmodifiedon = :lastmodifiedon;";
+ " lastmodifiedon = :lastmodifiedon, a_urn = :a_urn;";
Copy link
Contributor

Choose a reason for hiding this comment

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

do we have similar unit test that covers entity without a_urn?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is right underneath. There is a flag passed into createUpsertAspectSql() which indicates if a_urn column exists or not. It is only controlled by the DAO code, not the user.

Copy link
Contributor

Choose a reason for hiding this comment

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

sounds good, thanks for clarification.

Copy link
Contributor

@yangyangv2 yangyangv2 left a comment

Choose a reason for hiding this comment

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

LGTM

@jsdonn jsdonn merged commit afc85c2 into linkedin:master Dec 19, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants