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

Fix parsing of database results for materialized view autorefresh #643

Merged
merged 3 commits into from
Oct 26, 2023

Conversation

mikealfare
Copy link
Contributor

@mikealfare mikealfare commented Oct 26, 2023

Problem

The results from the database for auto refresh on a materialized view returned unhandled values. This caused an incorrect flow through the logic in the materialization.

Solution

Map the values from the query to their appropriate boolean values.

Checklist

  • I have read the contributing guide and understand what's expected of me
  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • This PR has no interface changes (e.g. macros, cli, logs, json artifacts, config files, adapter interface, etc) or this PR has already received feedback and approval from Product or DX

@mikealfare mikealfare self-assigned this Oct 26, 2023
@cla-bot cla-bot bot added the cla:yes label Oct 26, 2023
@github-actions
Copy link
Contributor

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the dbt-redshift contributing guide.

1 similar comment
@github-actions
Copy link
Contributor

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the dbt-redshift contributing guide.

@mikealfare mikealfare changed the title Fix materialized view issues from 1.7.0rc to 1.7.0final Fix parsing of database results for materialized view autorefresh Oct 26, 2023
@cla-bot cla-bot bot added the cla:yes label Oct 26, 2023
@@ -163,19 +163,6 @@ def test_change_is_applied_via_alter_str_true(self, project, my_materialized_vie
assert_message_in_logs(f"Applying ALTER to: {my_materialized_view}", logs)
assert_message_in_logs(f"Applying REPLACE to: {my_materialized_view}", logs, False)

def test_change_is_applied_via_alter_str_false(self, project, my_materialized_view):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The string version of this is already tested with the test above. Also, this does not represent a change, and just the fact that "False" is treated the same as False. This is covered in a unit test.

"query": cls._parse_query(query.get("definition")),
}

autorefresh_value = materialized_view.get("autorefresh")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Redshift returns the value as a single character: 't' or 'f'. Sometimes agate picks this up and converts and sometimes it does not.

@mikealfare mikealfare marked this pull request as ready for review October 26, 2023 02:17
@mikealfare mikealfare requested a review from a team as a code owner October 26, 2023 02:17
@mikealfare mikealfare merged commit b4176b9 into main Oct 26, 2023
22 checks passed
@mikealfare mikealfare deleted the bug/materialized-views/auto-refresh branch October 26, 2023 17:27
@github-actions
Copy link
Contributor

The backport to 1.6.latest failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-1.6.latest 1.6.latest
# Navigate to the new working tree
cd .worktrees/backport-1.6.latest
# Create a new branch
git switch --create backport-643-to-1.6.latest
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 b4176b95ee976b6c503a49904f754c8953730480
# Push it to GitHub
git push --set-upstream origin backport-643-to-1.6.latest
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-1.6.latest

Then, create a pull request where the base branch is 1.6.latest and the compare/head branch is backport-643-to-1.6.latest.

github-actions bot pushed a commit that referenced this pull request Oct 26, 2023
* map t/f to bool for database results

* remove unnecessary test that did not properly test its hypothesis

* changelog

(cherry picked from commit b4176b9)
@github-actions
Copy link
Contributor

The backport to 1.6.latest failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-1.6.latest 1.6.latest
# Navigate to the new working tree
cd .worktrees/backport-1.6.latest
# Create a new branch
git switch --create backport-643-to-1.6.latest
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 b4176b95ee976b6c503a49904f754c8953730480
# Push it to GitHub
git push --set-upstream origin backport-643-to-1.6.latest
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-1.6.latest

Then, create a pull request where the base branch is 1.6.latest and the compare/head branch is backport-643-to-1.6.latest.

@github-actions
Copy link
Contributor

The backport to 1.6.latest failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-1.6.latest 1.6.latest
# Navigate to the new working tree
cd .worktrees/backport-1.6.latest
# Create a new branch
git switch --create backport-643-to-1.6.latest
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 b4176b95ee976b6c503a49904f754c8953730480
# Push it to GitHub
git push --set-upstream origin backport-643-to-1.6.latest
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-1.6.latest

Then, create a pull request where the base branch is 1.6.latest and the compare/head branch is backport-643-to-1.6.latest.

@github-actions
Copy link
Contributor

The backport to 1.6.latest failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-1.6.latest 1.6.latest
# Navigate to the new working tree
cd .worktrees/backport-1.6.latest
# Create a new branch
git switch --create backport-643-to-1.6.latest
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 b4176b95ee976b6c503a49904f754c8953730480
# Push it to GitHub
git push --set-upstream origin backport-643-to-1.6.latest
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-1.6.latest

Then, create a pull request where the base branch is 1.6.latest and the compare/head branch is backport-643-to-1.6.latest.

mikealfare added a commit that referenced this pull request Oct 26, 2023
* map t/f to bool for database results

* remove unnecessary test that did not properly test its hypothesis

* changelog

(cherry picked from commit b4176b9)
mikealfare added a commit that referenced this pull request Oct 26, 2023
…) (#644)

* map t/f to bool for database results

* remove unnecessary test that did not properly test its hypothesis

* changelog

(cherry picked from commit b4176b9)

Co-authored-by: Mike Alfare <13974384+mikealfare@users.noreply.github.com>
McKnight-42 pushed a commit that referenced this pull request Oct 26, 2023
…d view autorefresh (#645)

* Fix parsing of database results for materialized view autorefresh (#643)

* map t/f to bool for database results

* remove unnecessary test that did not properly test its hypothesis

* changelog

(cherry picked from commit b4176b9)

* remove test that did not exist in 1.6; missed during merge conflict resolution
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants