snowflake-cli
snowflake-cli copied to clipboard
Add support for fully qualified names
Pre-review checklist
- [x] I've confirmed that instructions included in README.md are still correct after my changes in the codebase.
- [x] I've added or updated automated unit tests to verify correctness of my new code.
- [x] I've added or updated integration tests to verify correctness of my new code.
- [x] I've confirmed that my changes are working by executing CLI's commands manually.
- [x] I've confirmed that my changes are up-to-date with the target branch.
- [x] I've described my changes in the release notes.
- [x] I've described my changes in the section below.
Changes description
- Introduction of
IdentifierModel
for pydatic models. It implements generic parameters for fully qualified names (database, schema, name). Database and schema are optional. - New
FQN
class representing fully qualified name. The FQN can be built manually but there's also a builder pattern that allows us to construct or update the FQN. Some examples:
fqn = FQN.from_string("my_schema.object").using_connection(conn)
fqn = FQN.from_identifier_model(cli_context.project_definition.streamlit).using_context()
fqn = FQN.from_string("my_name").set_database("db").set_schema("foo")
- The
FQN
incorporates some existing logic likeget_name_from_fully_qualified_name
,qualified_name_for_url
orfrom_qualified_name
. In this way we extract some "naming" functionalities fromSqlExecutionMixin
. - Refactor of functions and procedures models to use
IdentifierModel
, this changes only implementation. - Added support for schema and database to streamlit definition/model.
- I removed the
.uppercase()
usage to support quoted identifiers as pointed in #824
There are still some naming/identifier utils in api.project.util
module. In followup PRs I will try to move them to either FQN class or at least to identifiers
module.