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

Ensure most recent metadata is served despite duplicate version 0's #268

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

jphui
Copy link
Contributor

@jphui jphui commented May 31, 2023

Checklist

  • The PR conforms to DataHub's Contributing Guideline (particularly Commit Message Format)
  • Links to related issues (if applicable)
  • Tests for the changes have been added/updated (if applicable)
  • Docs related to the changes have been added/updated (if applicable)

<fix> : added ordering to get() make sure that the most recent record (despite duplicates in other versioning) is at the top and returned

<test> : added a unit test with corresponding SQL script to ensure that the above fix works

The unit test requires a new script because the existing scripts would throw a Primary / Unique Key Error; a new script that adds createdOn was required.

@jphui jphui changed the base branch from master to jhui/jdbc June 6, 2023 23:35
@jphui jphui changed the base branch from jhui/jdbc to master June 6, 2023 23:36
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.

several comments

@@ -892,6 +892,8 @@ private List<EbeanMetadataAspect> batchGetUnion(@Nonnull List<AspectKey<URN, ? e
}
}

sb.append(" ORDER BY createdOn DESC");
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this needs to be inside the For loop. Basically you want

//   SELECT * FROM metadata_aspect WHERE urn = 'urn0' AND aspect = 'aspect0' AND version = 0 ORDER BY createdOn DESC limit 1
//   UNION ALL
//   SELECT * FROM metadata_aspect WHERE urn = 'urn0' AND aspect = 'aspect1' AND version = 0 ORDER BY createdOn DESC limit 1

does it make sense?

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 thought through this as well and believed it should be outside because in the case where you're running multiple SELECT's, we want the final result to be ordered, not just each subsection.

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