-
Notifications
You must be signed in to change notification settings - Fork 459
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
coord: restrict queries run on mz_introspection
#18276
coord: restrict queries run on mz_introspection
#18276
Conversation
- add new adapter::coord::introspection module - check when sequencing, if we're on the mz_introspection cluster, we're only referencing system items
Hey @morsapaes, could you provide some insight into how our dbt adapter works? 🙂 This PR is an attempt to restrict what queries are run against the
For the Materialize connector, it appears as though we should be falling back to the default cluster if no cluster configuration is set (comment) but I'm not sure that's happening? I'm also not familiar with dbt though, so I could be misunderstanding how it works. |
This is true, but revisiting the code there are some quirks that can be confusing. Leaving a rambling at the bottom of the comment that hopefully makes things clearer (while also helping me think things through). In theory, the issue with tests shouldn't be tied to where materializations are created, but to the queries that are run to verify that these materializations return the results we expect them to return. As an example, here's what the
All dbt tests follow this pattern of running a seed file with expected results, and validating those against the actual results that are observed. There are things failing that make sense to me, for example: [2023-03-20T19:11:07Z] create view "materialize"."test16793394665858303751_test_utils"."current_ts"
[2023-03-20T19:11:07Z] as (
[2023-03-20T19:11:07Z] select now() as current_ts_column
[2023-03-20T19:11:07Z] );
...
[2023-03-20T19:11:07Z] INFO file_log:eventmgr.py:59 19:11:07.093932 [info ] [Thread-113]: 1 of 1 OK created sql view model test16793394665858303751_test_utils.current_ts [CREATE VIEW in 0.08s]
...
[2023-03-20T19:11:07Z] ______ ERROR at setup of TestCurrentTimestamp.test_current_timestamp_type ______
[2023-03-20T19:11:07Z]
[2023-03-20T19:11:07Z] self = <test_utils.TestCurrentTimestamp object at 0x7f5d92030d30>
[2023-03-20T19:11:07Z] project = <dbt.tests.fixtures.project.TestProjInfo object at 0x7f5d8a9248e0>
[2023-03-20T19:11:07Z]
[2023-03-20T19:11:07Z] @pytest.fixture(scope="class")
[2023-03-20T19:11:07Z] def current_timestamp(self, project):
[2023-03-20T19:11:07Z] run_dbt(["build"])
[2023-03-20T19:11:07Z] relation = relation_from_name(project.adapter, "current_ts")
[2023-03-20T19:11:07Z] > result = project.run_sql(f"select current_ts_column from {relation}", fetch="one")
...
[2023-03-20T19:11:07Z] E psycopg2.errors.InternalError_: querying the following items
"materialize.test16793394665858303751_test_utils.current_ts" is not allowed from the "mz_introspection" cluster. Use
`SET CLUSTER = <cluster-name>` to change your cluster and re-run the query. Since these tests run in CI, we could default to the Forcing clusters after connectionWe force the default cluster defined in
Since Materialize will throw an error if none of the options are specified, there isn't a risk that sources or sinks end up being created in |
…rs from the active
Closed to split the changes into two different PRs: |
Work in Progress
Motivation
mz_introspection
cluster #18075Tips for reviewer
Checklist
$T ⇔ Proto$T
mapping (possibly in a backwards-incompatible way) and therefore is tagged with aT-proto
label.