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

fix: read Name, Database and Schema during Procedure import #819

Merged
merged 5 commits into from
Jan 18, 2022

Conversation

dkduo
Copy link
Contributor

@dkduo dkduo commented Jan 13, 2022

Update ReadProcedure() to set name, database and schema during import.

Refactor ArgumentsSignature() to both remove the RETURN portion and to
uppercase the output. The RETURN is technically not part of the unique signature
of a procedure and will not exist when performing an import unless the ID
is updated to include it. Uppercasing the output means the signature will match
the output of the Snowflake SHOW command.

Change default value of comment to user-defined procedure.

Refactor unit test for Read to more thoroughly test reading an existing procedure
with the minimal initial values provided as would be the case during an import.

Update acceptance test to include testing an import.

Test Plan

  • unit tests
  • acceptance tests

References

Denton Krietz added 4 commits January 13, 2022 09:20
Update ReadProcedure() to set name, database and schema from Show during
import.

Remove the RETURN argument from ArgumentsSignature() because it is not
part of the unqiue signature of a procedure and will not exist during
import unless the ID is updated to include it.

Change default value of comment to 'user-defined procedure' and fix
corresponding tests.
Refactor ArgumentsSignature(), not only removing the RETURN
but also capitalizing the entire output to match the output
of the SHOW statement.

Refactor unit test for Read to more thoroughly test reading
the existing procedure with the minimal initial values provided.

Update acceptance test to include testing an import.
@@ -230,7 +230,7 @@ type procedure struct {
Name sql.NullString `db:"name"`
SchemaName sql.NullString `db:"schema_name"`
Text sql.NullString `db:"text"`
DatabaseName sql.NullString `db:"database_name"`
DatabaseName sql.NullString `db:"catalog_name"`
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like a mistake?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For some reason, Snowflake returns the database name in a column called catalog_name when calling the SHOW PROCEDURES query.
https://docs.snowflake.com/en/sql-reference/sql/show-procedures.html#output

Copy link
Contributor

Choose a reason for hiding this comment

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

well that's weird and not uniform...

@alldoami
Copy link
Contributor

/ok-to-test sha=4640860

@github-actions
Copy link

Integration tests success for 4640860

@alldoami
Copy link
Contributor

/ok-to-test sha=1ef9ac4

@github-actions
Copy link

Integration tests success for 1ef9ac4

@alldoami alldoami merged commit d17656f into Snowflake-Labs:main Jan 18, 2022
@dkduo dkduo deleted the import_procedure branch January 19, 2022 23:07
daniepett pushed a commit to daniepett/terraform-provider-snowflake that referenced this pull request Feb 9, 2022
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.

2 participants