Skip to content

fix: #1572 - make where_clause_suffix an actual suffix #1573

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

Merged
merged 1 commit into from
Jan 31, 2023

Conversation

delwaterman
Copy link
Contributor

@delwaterman delwaterman commented Nov 9, 2021

Signed-off-by: Orion Delwaterman [email protected]

Summary of Changes

Fixes #1572

Changes the config of RedshiftMetadataExtractor where_clause_suffix to not require a user to include a WHERE statement in their sql partial. This follows the behavior of PostgresMetadataExtractor, and seems more consistent with the variable name where_clause_suffix by treating the partial as a suffix to a where clause.

This will be a breaking change for anyone using redshift extractor (so probably will need a minor version bump). That being, IMHO, it's better to make the behavior follow expected patterns rather than ask users to hunt through source code to determine why their query is breaking (which happened to me).

Tests

databuilder/tests/unit/extractor/test_redshift_metadata_extractor.py

Documentation

CheckList

Make sure you have checked all steps below to ensure a timely review.

  • PR title addresses the issue accurately and concisely. Example: "Updates the version of Flask to v1.0.2"
  • PR includes a summary of changes.
  • PR adds unit tests, updates existing unit tests, OR documents why no test additions or modifications are needed.
  • In case of new functionality, my PR adds documentation that describes how to use it.
    • All the public functions and the classes in the PR contain docstrings that explain what it does

@delwaterman delwaterman requested a review from a team as a code owner November 9, 2021 02:54
@boring-cyborg boring-cyborg bot added the area:databuilder From databuilder folder label Nov 9, 2021
@dkunitsk
Copy link

dkunitsk commented Nov 9, 2021

Redshift extractor is reasonably popular and the style fix isn't worth breaking ingestors, imho. where True is always a workaround.

@delwaterman
Copy link
Contributor Author

If I may, I lost 1 hour of development tracking down this issue, which doesn't feel like a lot, but forcing a user to dig through source code to understand how to use a public API is bad form. Personally it led me to trust this code base less, because it felt sloppy. I am not trying to pick a fight, but I am trying to tell my experience as a new developer using the project

That being said, why don't we do a comprimise, and support the old pattern, with a deprecation warning:

if where_clause_suffix.lower().startswith("where"):
    logger.Warn("you no longer need to begin with 'where' in your suffix")
    where_clause = where_clause_suffix
else:
    where_clause = f"where {where_clause_suffix}"

@verdan
Copy link
Member

verdan commented Nov 9, 2021

This is kind of an issue we had for Postgres, and we fixed it here: 6cf8965#diff-01ee0656007972e26ae47d9003cf877aefa524b6e91a6bf6b72035892ba9b757R47

So another suggestion is to make the where_clause_suffix a real suffix, what @delwaterman is suggesting, and make the default value as true.

But your's approach to supporting existing installation is also good. IMHO, announcing such breaking changes properly should not hurt the existing users. It's a minor change but will make life easy for any new installation.

@dkunitsk
Copy link

dkunitsk commented Nov 9, 2021

+1 to either of the nonbreaking alternatives mentioned above.

@delwaterman
Copy link
Contributor Author

Ok I will do the update

@delwaterman delwaterman force-pushed the fix-redshift-extractor branch from c2ba297 to b64decd Compare November 9, 2021 19:04
@delwaterman delwaterman force-pushed the fix-redshift-extractor branch 6 times, most recently from 0448cb7 to 5349b32 Compare November 23, 2021 18:12
@delwaterman delwaterman force-pushed the fix-redshift-extractor branch from 5349b32 to 0a7b454 Compare November 23, 2021 18:47
@delwaterman
Copy link
Contributor Author

@verdan @dkunitsk This is now ready

@stale
Copy link

stale bot commented Dec 7, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale label Dec 7, 2021
@delwaterman
Copy link
Contributor Author

Bump

@stale stale bot removed the stale label Dec 8, 2021
@stale
Copy link

stale bot commented Dec 23, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale label Dec 23, 2021
@delwaterman
Copy link
Contributor Author

bump

@feng-tao feng-tao added the keep fresh Disables stalebot from closing an issue label Jan 19, 2022
@stale stale bot removed the stale label Jan 19, 2022
@dkunitsk dkunitsk merged commit d2926a8 into amundsen-io:main Jan 31, 2023
B-T-D pushed a commit to B-T-D/amundsen that referenced this pull request Mar 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:databuilder From databuilder folder keep fresh Disables stalebot from closing an issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug Report - Postegres / Redshift Extractors have inconsistent behavior
4 participants