snowflake-cli icon indicating copy to clipboard operation
snowflake-cli copied to clipboard

Add support for fully qualified names

Open sfc-gh-turbaszek opened this issue 10 months ago • 0 comments

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

  1. Introduction of IdentifierModel for pydatic models. It implements generic parameters for fully qualified names (database, schema, name). Database and schema are optional.
  2. 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")
  1. The FQN incorporates some existing logic like get_name_from_fully_qualified_name, qualified_name_for_url or from_qualified_name. In this way we extract some "naming" functionalities from SqlExecutionMixin.
  2. Refactor of functions and procedures models to use IdentifierModel, this changes only implementation.
  3. Added support for schema and database to streamlit definition/model.
  4. 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.

sfc-gh-turbaszek avatar Apr 26 '24 16:04 sfc-gh-turbaszek