6 kyu
Present XML data the SQL way
501FArekkusu
Loading description...
Fundamentals
SQL
Data Science
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
Great kata! Forced me to google how to work with XML data.
Excellent practice and a good reason to delve deeper into the work of postgreSQL with xml.
Can someone please tell me if the email is empty input the xpath function will return NULL as place holder or no in the array? Everything is fine but only the order of the email address I can't solve it.
This comment has been hidden.
I am new too querying XML and got stuck because I kept getting the error "PG::CardinalityViolation: ERROR: more than one value returned by column XPath expression". This appeared to be caused because there were multiple values that could be returned from the XML path '/data/user/email_addresses/address'. Its a simple fix, and If anyone else gets stuck with this error, I finally tracked down an example of how handle multiple values here: https://www.ibm.com/docs/en/i/7.1?topic=table-using-xmltable-handle-multiple-values
Attempting to tackle this kata, I got all the data right but the ages.
What I'm doing is an age(actual_date, born_date). I guess the problem is on the tests, as they were calculated from a different date as the one I'm calculating now. Anyway, I can't think about any other way of calculating the ages, as I don't know when those tests where generated.
Maybe it could be good to have some sort of a reference date to calculate the ages, in order to make the results match with the tests. Otherwise I can't see how people could tackle this kata
Firstly, random tests always use
today
as the reference point, it is your approach of explicitly specifying2021-06-18
that is bad. Secondly, your solution is wrong as it incorrectly "generates" thedate_of_birth
- the extraction itself produces correct values but string-to-date conversion is always off:I'm having issues to produce 'Hidden' for the email address when the profile is private ... Could someone help with this part? Any hint will be most welcome
Below the results I'm able to produce:
first_name | last_name | age | email_address John | Doe | 23 | john.doe14825@domain.com Johnatan | Doe | 25 | johnathan.doe68245@domain.com Johny | Doe |27 | johny.doe97218@domain.com Jon Doe | 21 | johny.xoxo@domain.com
Thanks
Extract the
private
field and check its value - all you need is a simple conditional expression. In your place I'd be more worried about assigning email addresses to wrong people, likeJon
has the secondJohny
's email address listed as his own. I've changed the sample tests to use different names, so if you reset the trainer, you'll see the issue clearly.I did not capture the original data, but i guess they have the identical date_of_birth
Changed it so that a list of unique dates is generated. Idk if there's a reliable way to confirm it works correctly.
Rewrote the tests to generate a list of shuffled unique names, so this shouldn't be a problem anymore.