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

materialize-sql: add support for checking prerequisites during validation #612

Merged
merged 6 commits into from
Mar 21, 2023

Conversation

williamhbaker
Copy link
Member

@williamhbaker williamhbaker commented Mar 20, 2023

Description:

Adds a "prerequisites" check to sql materializations that is invoked during Validate calls.

Currently there are some ad-hoc validations that occur during NewEndpoint. These are not comprehensive, and not including them in Validate means that they don't run during Test invocations. The comprehensive validations are more involved and moving them from NewEndpoint to Validate is also nice since they won't have to run every time the connector starts up, and are only run when a change to the materialization is being considered.

I generally tried to interpret errors for common user-error cases and return clear & helpful error messages for these cases. This does not always work as well as I'd like depending on what the client library gives us, but overall I think we will have things covered pretty well here.

There is the potential for multiple errors to be independently evaluated for some materializations. In this case we will report as many errors as possible rather than stopping on the first one. This is really only the case for redshift and bigquery which use staging buckets and have the potential for separate client configuration and cloud storage configuration errors.

Also note that there is a small tweak to the snowflake configuration validation: We will now only accept host URLs ending in .snowflakecomputing.com. It has never been possible for the materialization to work with anything other than *.snowflakecomputing.com, but now the connector will validate that specifically when parsing the configuration. This helps eliminate a lot of possible configuration errors that would have to otherwise be validated in the prereq check for the connector.

Workflow steps:

Use connectors like before, but have better error messages when trying to publish them.

Documentation links affected:

I'll take a look at the snowflake docs and see if there is anything that needs updated there.

Notes for reviewers:

(anything that might help someone review this PR)


This change is Reviewable

…tion

Adds the field CheckPrerequisites to the Endpoint struct created by all sql materializations. This
field is a function that will be called in Validate.
Adds prerequisite checks during validation & a configuration check to enforce that the snowflake
host configuration must end with ".snowflakecomputing.com". This might not work if we ever support
things like AWS PrivateLink, but for now it allows an easy way to prevent errors with this
configuration field.

Also adds a test for Snowflake fencing which is entirely unrelated to these changes, but seemed nice
to do while I was updating tests.
Copy link
Member

@mdibaiee mdibaiee left a comment

Choose a reason for hiding this comment

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

Thanks Will! LGTM, just a tiny nit

@@ -88,12 +96,14 @@ func (c *config) Validate() error {
return fmt.Errorf("missing '%s'", req[0])
}
}

if !validHost(c.Host) {
return fmt.Errorf("invalid host %q (must match end in snowflakecomputing.com and not include a protocol)", c.Host)
Copy link
Member

Choose a reason for hiding this comment

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

Nit: I think it's better if validHost itself gives this error, since that function knows what it is checking, I would expect the caller to not have to know what is happening inside the function

@williamhbaker williamhbaker merged commit 5fff47c into main Mar 21, 2023
@williamhbaker williamhbaker deleted the wb/materialize-sql-validation branch March 21, 2023 16:20
@oliviamiannone oliviamiannone added the docs complete / NA No (more) doc work related to this PR label Mar 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs complete / NA No (more) doc work related to this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants