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

Update holdings_ext.sql #857

Merged
merged 3 commits into from
Jul 8, 2024
Merged

Conversation

VandanaShah-Cornell
Copy link
Contributor

/*Changes:

  1. Fixed to bring in the correct data for the 'updated_by_user_id' field; it was bringing in data from the created by userid rather than the updated_by_user_id.
  2. The holdings_supress field needed to be cast as Boolean.
  3. The json extract for ill_policy_id needed to be cast as UUID.
  4. Cast the date fields as "timestamptz" (changed from text)
  5. Cast the discovery_suppress field as Boolean (changed from text)
  6. Cast the extract of updatedByUserId as UUID (changed from text) */

/*Changes: 
1. Fixed to bring in the correct data for the 'updated_by_user_id' field; it was bringing in data from the created by userid rather than the updated_by_user_id. 
2. The holdings_supress field needed to be cast as Boolean. 
3. The json extract for ill_policy_id needed to be cast as UUID.
4. Cast the date fields as "timestamptz" (changed from text)
5. Cast the discovery_suppress field as Boolean (changed from text)
6. Cast the extract of updatedByUserId as UUID (changed from text)
*/
@VandanaShah-Cornell
Copy link
Contributor Author

This PR closes issue #856

Copy link
Contributor

@trapido trapido left a comment

Choose a reason for hiding this comment

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

There are a couple of problems:
1.The query won’t run because the CTE is not properly terminated with “)” and the main query is missing a select statement. The easiest way to fix this might be to remove line 11, “WITH holdings AS ( “.
2.I think that joining holdings_record__t and holdings_record tables might be redundant: it should be possible to extract all of the data out of holdings_record table.

All queries:

  • PR Title and Description are accurate and thorough
  • PR is based on a new branch (not main)
  • PR scope is not overly broad
  • Query runs without errors
  • Query output is correct
  • Query logic is clear and well documented
  • Query is readable and properly indented
  • Table and column names are in all-lowercase
  • Quotation marks are used only where necessary
  • JSON extraction is in standard form, for example:
    LDP: t #>> '{f1,f2,f3}' [for compatibility across LDP 1 & 2]
    Metadb: jsonb_extract_path_text(t, f1, f2, f3)

Derived tables:

  • First line is "--metadb:table" directive, followed by blank line
  • User documentation in comment lines, followed by blank line
  • File name is listed in runlist.txt after dependencies

@VandanaShah-Cornell
Copy link
Contributor Author

My apologies for these errors, looks like I was testing the query without creating a table, and then sent the version I was mucking around with as a PR, instead of the cleaned version.

@VandanaShah-Cornell
Copy link
Contributor Author

VandanaShah-Cornell commented Jul 1, 2024 via email

@VandanaShah-Cornell
Copy link
Contributor Author

Re: Using both holdings_record__t and holdings_record tables : most of the fields are already extracted from the jsonb and are in the holdings_record__t table, except for three fields that needed to be extracted from the holdings_record table. It is easier to use the transformed table, is there any reason to not do this? Seems like extra work to extract fields that are already in transformed tables.

@trapido
Copy link
Contributor

trapido commented Jul 5, 2024

Thank you very much, Vandana! Everything looks good. Just one minor thing: should the metadb dirctive read "--metadb:table holdings_ext" instead of "--Metadb: holdings_ext"?
Regarding using holdings_record__t and holdings_record tables in the same query, there is nothing wrong with this, I just remember Nassib mentioning that this is not efficient because we are essentially joining two copies of the same data.

@nassibnassar nassibnassar merged commit e5b470f into folio-org:main Jul 8, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants