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

conditional materialized view refresh and create-replace for the view #87

Open
wants to merge 184 commits into
base: main
Choose a base branch
from

Conversation

kraftaa
Copy link

@kraftaa kraftaa commented May 3, 2024

for issue: #88
hi I've started testing quary in the production and hitting dependencies errors: If I follow the logic of DROP/CREATE view I can't do it without CASCADE deleting all dependencies. The same with materialized views.

I suggest that for the view and materialized view there would be no DROP command and then changed creation commands:

  • view : CREATE OR REPLACE VIEW ...
  • materialized view: checking if the view exists first and based on that either REFRESH MATERIALIZED VIEW .. or CREATE MATERIALIZED VIEW ... In case of REFRESH there is no issue with dependent views.

thank you

@kraftaa kraftaa changed the title conditional materialized view refresh and create-replace for the view conditional materialized view refresh and create-replace for the view fix #88 May 3, 2024
@kraftaa kraftaa changed the title conditional materialized view refresh and create-replace for the view fix #88 Fix #88 conditional materialized view refresh and create-replace for the view May 3, 2024
@kraftaa kraftaa changed the title Fix #88 conditional materialized view refresh and create-replace for the view conditional materialized view refresh and create-replace for the view May 3, 2024
@benfdking
Copy link
Collaborator

benfdking commented May 5, 2024

The fundamental problem with this approach is that if you change the model between the runs, the behavior is vastly different from what you would expect, e.g., changing the model as expected.

We do have a system for this, though, which I think we can rely on our "cached views" system. It's mainly defined in this file: https://github.com/quarylabs/quary/blob/main/rust/core/src/automatic_branching.rs.

We currently use it for our development flow; suppose you have models A, B, and C that depend on each other as follows, and you are pushing them to production in a materialized way.

A --> B --> C

It essentially measures the diff between your local setup and what's in production and tries to use as much "production" as possible to rely on materialized models as much as possible. So if your local models change C to C', you can still rely on production A and B because those are identical.

At its core, it's a "diffing system" that I think we can use here as well, to both speed up builds by

  • running refresh if the model is materialized but the definition is the same
  • skipping create/replace steps for views that are identical.

I hope some of the above makes sense.

@kraftaa
Copy link
Author

kraftaa commented May 6, 2024

Ben, thank you, yes it makes total sense.

@benfdking
Copy link
Collaborator

#141 The beginning!

louisjoecodes and others added 22 commits June 5, 2024 13:41
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 5.0.0 to 5.0.1.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](actions/setup-go@0c52d54...cdcb360)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
benfdking and others added 30 commits June 5, 2024 13:43
Bumps [petgraph](https://github.com/petgraph/petgraph) from 0.6.4 to 0.6.5.
- [Changelog](https://github.com/petgraph/petgraph/blob/master/RELEASES.rst)
- [Commits](https://github.com/petgraph/petgraph/compare/petgraph@v0.6.4...petgraph@v0.6.5)

---
updated-dependencies:
- dependency-name: petgraph
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [prost-build](https://github.com/tokio-rs/prost) from 0.12.3 to 0.12.4.
- [Release notes](https://github.com/tokio-rs/prost/releases)
- [Commits](tokio-rs/prost@v0.12.3...v0.12.4)

---
updated-dependencies:
- dependency-name: prost-build
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [rust-embed](https://github.com/pyros2097/rust-embed) from 8.3.0 to 8.4.0.
- [Changelog](https://github.com/pyrossh/rust-embed/blob/master/changelog.md)
- [Commits](https://github.com/pyros2097/rust-embed/commits)

---
updated-dependencies:
- dependency-name: rust-embed
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.197 to 1.0.203.
- [Release notes](https://github.com/serde-rs/serde/releases)
- [Commits](serde-rs/serde@v1.0.197...v1.0.203)

---
updated-dependencies:
- dependency-name: serde
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [prost-build](https://github.com/tokio-rs/prost) from 0.12.4 to 0.12.6.
- [Release notes](https://github.com/tokio-rs/prost/releases)
- [Commits](tokio-rs/prost@v0.12.4...v0.12.6)

---
updated-dependencies:
- dependency-name: prost-build
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.37.0 to 1.38.0.
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](tokio-rs/tokio@tokio-1.37.0...tokio-1.38.0)

---
updated-dependencies:
- dependency-name: tokio
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [testcontainers-modules](https://github.com/testcontainers/testcontainers-rs-modules-community) from 0.4.2 to 0.4.3.
- [Release notes](https://github.com/testcontainers/testcontainers-rs-modules-community/releases)
- [Changelog](https://github.com/testcontainers/testcontainers-rs-modules-community/blob/main/CHANGELOG.md)
- [Commits](testcontainers/testcontainers-rs-modules-community@v0.4.2...v0.4.3)

---
updated-dependencies:
- dependency-name: testcontainers-modules
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.2.11 to 5.2.12.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v5.2.12/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
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.

4 participants