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

Add support for generated columns #53

Merged
merged 3 commits into from
Feb 17, 2024

Conversation

nicholasd-ff
Copy link
Contributor

Support for sampling tables with generated columns

This change adds support for sampling tables with generated columns
and tests to check the new feature is working correctly.

Fixes #52

Test output:

1..26
 set_config 
------------
 
(1 row)

 setval 
--------
      1
(1 row)

 setval 
--------
      1
(1 row)

ok 1 - child1 should have 100 rows
ok 2 - child2 should have 100 rows
ok 3 - child3 should have 100 rows
ok 4 - child4 should have 100 rows
ok 5 - child5 should have 100 rows
ok 6 - child6 should have 100 rows
ok 7 - child7 should have 100 rows
ok 8 - child8 should have 100 rows
ok 9 - child9 should have 100 rows
ok 10 - child10 should have 100 rows
ok 11 - all parent rows should be fetched due to FKs
ok 12 - escaping
ok 13 - ordered test case broken, this should return by clustered order
ok 14 - long table name should have 10 rows
ok 15 - some_numbers table should have 10 rows
ok 16 - The double_val column is not 2x the base_val
ok 17 - The double_val column is not 2x the base_val
ok 18 - The double_val column is not 2x the base_val
ok 19 - The double_val column is not 2x the base_val
ok 20 - The double_val column is not 2x the base_val
ok 21 - The double_val column is not 2x the base_val
ok 22 - The double_val column is not 2x the base_val
ok 23 - The double_val column is not 2x the base_val
ok 24 - The double_val column is not 2x the base_val
ok 25 - The double_val column is not 2x the base_val
 set_config 
------------
 
(1 row)

 setval 
--------
      1
(1 row)

 setval 
--------
      1
(1 row)

ok 26 - results should be ordered

Among various benefits moves off a soon-to-be obsolete version of Debian
and adds support for postgres versions up to 16.

Fixes mla#50
This change adds support for sampling tables with generated columns
and tests to check the new feature is working correctly.

Fixes mla#52
@nicholasd-ff nicholasd-ff marked this pull request as draft February 15, 2024 15:05
@nicholasd-ff
Copy link
Contributor Author

I need to fix a problem with the FK constraints, nearly got it but it means some changes elsewhere to push the columns into the table object.

@nicholasd-ff
Copy link
Contributor Author

I think I've fixed it, but I'm testing it at an approximately 30% sample rate on our 120GB staging database as a torture test and I'll update the PR if it's successful.

This change ensures that foreign key checks on tables with generated
columns work properly.
@nicholasd-ff nicholasd-ff marked this pull request as ready for review February 15, 2024 16:02
@mla mla merged commit 17d443c into mla:master Feb 17, 2024
@mla
Copy link
Owner

mla commented Feb 17, 2024

Looks great to me, @nicholasd-ff. Changes merged. Thank you!

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.

pg_sample doesn't correctly handle generated columns
2 participants