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

feat(#184): add source column on data_record #185

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

1yuv
Copy link
Member

@1yuv 1yuv commented Nov 25, 2024

Description

Add source column on data_record table.
Closes #184

License

The software is provided under AGPL-3.0. Contributions to this project are accepted under the same license.

@1yuv 1yuv requested review from lorerod and witash November 25, 2024 19:06
Copy link
Contributor

@lorerod lorerod left a comment

Choose a reason for hiding this comment

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

Thanks, @1yuv, for these changes. I recommend ensuring the new source field (or fields) is properly tested to verify that the new logic works as expected in all cases. Feel free to reach out if you need guidance on implementing these updates. Looking forward to seeing the final version!

@@ -22,6 +22,7 @@ SELECT
document_metadata.saved_timestamp,
to_timestamp((NULLIF(doc->>'reported_date'::text, ''::text)::bigint / 1000)::double precision) AS reported,
doc->>'form' as form,
doc#>>'{fields,inputs,source}' as source,
Copy link
Contributor

Choose a reason for hiding this comment

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

Does breaking this into separate columns (fields, inputs, source) make sense?
This can improve clarity in downstream usage, simplify debugging and testing, and align with potential future changes of individual transformation.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't see any benefits of breaking this into the separate columns. Moreover, that way is less performant and I've opened an issue to make this changes in every other places.

Copy link
Contributor

@lorerod lorerod Dec 3, 2024

Choose a reason for hiding this comment

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

Your suggestion to use direct access with #>> is an excellent approach for improving performance. If downstream processes don't need to select specific fields, inputs, or source attributes, separating them may not be necessary.
However, if more granularity is required, we could balance performance and flexibility by separating the columns while using direct access instead of ->.
Please let me know what you think.

@@ -23,6 +23,8 @@ models:
data_type: timestamp with time zone
- name: form
data_type: string
- name: source
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you consider adding generic data test here? You can refer to this documentation.

Copy link
Contributor

Choose a reason for hiding this comment

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

I will also recommend updating the data_record fixtures to include the new fields along with their expected results.

Additionally, it would be interesting to have a sqltest to verify that the values for the new fields are correctly populated and consistent between data_record and couchdb.

For these updates, you can refer to the Guide for testing dbt models or review the existing tests already implemented in this repository. Let me know if you need any assistance!

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.

Add source on data_record
2 participants