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

Issues with date format on hscic.raw_prescribing_normalised #4989

Open
richiecroker opened this issue Sep 2, 2024 · 1 comment
Open

Issues with date format on hscic.raw_prescribing_normalised #4989

richiecroker opened this issue Sep 2, 2024 · 1 comment
Assignees

Comments

@richiecroker
Copy link
Collaborator

I attempted to write a new measure definition using hscic.raw_prescribing_normalised as the numerator, and list_size as the denominator, and it threw the following error:

No matching signature for operator = for argument types: TIMESTAMP, DATE. Supported signature: ANY = ANY at [86:15], with line 86 being AND practices_with_months.month = num.month

On investigation I found a stackoverflow discussion on the same issue.

Looking at how we create the SQL for the view, we have this line:
PARSE_DATETIME("%F", REGEXP_REPLACE(raw_prescribing._FILE_NAME, "^.+/(20\\d\\d)_(\\d\\d)/[^/]+$", "\\1-\\2-01")) AS month, which creates a DATETIME field type.

Other views, such as hscic.normalised_prescribinghave a TIMESTAMP field type.

As a temporary workaround, I have created a new view hscic.raw_prescribing_normalised_date which replaced the line above with PARSE_TIMESTAMP("%F", REGEXP_REPLACE(raw_prescribing._FILE_NAME, "^.+/(20\\d\\d)_(\\d\\d)/[^/]+$", "\\1-\\2-01")) AS month, which seems to work fine.

@evansd @inglesp should we replace the line in hscic.raw_prescribing_normalised with the PARSE_TIMESTAMP version, or is that likely to break anything?

@evansd
Copy link
Collaborator

evansd commented Sep 3, 2024

I think we should update the existing view to use PARSE_TIMESTAMP as you suggest. As you say, the other views use this type and I can see quite a few places in the code where we explicitly cast dates to TIMESTAMP so we're obviously expecting that. My guess is that we used PARSE_DATETIME inadvertently when defining this view and then never noticed because we never attempted to a join on that column until you created that measure.

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

No branches or pull requests

3 participants