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

feat: Functions sdk update #3254

Merged
merged 64 commits into from
Dec 9, 2024
Merged

feat: Functions sdk update #3254

merged 64 commits into from
Dec 9, 2024

Conversation

sfc-gh-asawicki
Copy link
Collaborator

@sfc-gh-asawicki sfc-gh-asawicki commented Dec 8, 2024

Update and test functions SDK as part of ongoing functions&procedures rework:

  • Regenerate SDK after adjusting defs
  • Wrap function definitions in $$
  • Wrap arguments in double quotes
  • Extract FunctionDetails out of DESCRIBE output rows
  • Add MetricLevel to the SDK
  • Adjust alter's structure (add set/unset)
  • Add missing fields to SHOW output
  • Use extended in for SHOW
  • Add/Generate assertions for function, function details, and function parameters
  • Add missing unit tests and adjust existing ones
  • Add missing integration tests and remove most of the existing ones or adjust them
  • Adjust existing resource

Additionally:

  • Allow simplified setup for local testing
  • Add helpers to interact with user's stage
  • Improve SDK generation (remove part of the unnecessary newlines - some are still left)

Copy link

github-actions bot commented Dec 8, 2024

Integration tests failure for e97df58c923d269261474b7c544b08e03e9fff0b

Copy link

github-actions bot commented Dec 8, 2024

Integration tests failure for 503e095147e2c18268c2b8e4e132455b8c4aeb18

@sfc-gh-asawicki sfc-gh-asawicki marked this pull request as ready for review December 9, 2024 11:43
pkg/acceptance/helpers/function_client.go Show resolved Hide resolved
Body *string // present for all function types (hidden when SECURE)
NullHandling *string // present for all function types but SQL
Volatility *string // present for all function types but SQL
ExternalAccessIntegrations *string // list present for python, java, and scala
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm guessing that in the next prs we are going to have concrete types instead of plain string values?

Copy link
Collaborator Author

@sfc-gh-asawicki sfc-gh-asawicki Dec 9, 2024

Choose a reason for hiding this comment

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

yes, most probably when adding the resources (this change is already inflated :( )

} else {
*field = *d.Value
}
return nil
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe this and the function below should be enclosed in the description_helpers where we would hold functions that help with more complicated descriptions to parse (?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

let's tackle this one we have more objects handled this way (for now there is no consistency, not only because the history but also because of the different columns returned in rows response by Snowflake - we have so many *property types in the SDK)

opts.Comment = String("comment")
opts.Imports = []FunctionImport{
{
Import: "@udf_libs/echohandler.jar",
},
}
opts.Handler = "Echo.echoVarchar"
opts.FunctionDefinition = String("return x")
assertOptsValidAndSQLEquals(t, opts, `CREATE OR REPLACE TEMPORARY SECURE FUNCTION %s (x VARCHAR(100) DEFAULT 'test') COPY GRANTS RETURNS VARCHAR(100) NOT NULL LANGUAGE SCALA CALLED ON NULL INPUT IMMUTABLE RUNTIME_VERSION = '2.0' COMMENT = 'comment' IMPORTS = ('@udf_libs/echohandler.jar') HANDLER = 'Echo.echoVarchar' AS 'return x'`, id.FullyQualifiedName())
opts.FunctionDefinition = String(wrapFunctionDefinition("return x"))
Copy link
Collaborator

Choose a reason for hiding this comment

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

make a ticket/leave todo in sql generator to support "dollar quoting" there

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I will add it

pkg/sdk/common_types.go Show resolved Hide resolved
pkg/sdk/functions_def.go Show resolved Hide resolved
pkg/sdk/functions_def.go Show resolved Hide resolved
pkg/sdk/functions_impl_gen.go Show resolved Hide resolved
@@ -142,7 +142,7 @@ func TestAcc_Function_complex(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "comment", "Terraform acceptance test"),
resource.TestCheckResourceAttr(resourceName, "statement", statement),
resource.TestCheckResourceAttr(resourceName, "arguments.#", "1"),
resource.TestCheckResourceAttr(resourceName, "arguments.0.name", "D"),
resource.TestCheckResourceAttr(resourceName, "arguments.0.name", "d"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please mention the change in casing in the migration guide.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will do in the PR with resource rework.

pkg/sdk/functions_ext.go Show resolved Hide resolved
pkg/acceptance/helpers/function_client.go Show resolved Hide resolved
pkg/acceptance/testdatatypes/testdatatypes.go Show resolved Hide resolved
pkg/sdk/testint/functions_integration_test.go Show resolved Hide resolved
Copy link

github-actions bot commented Dec 9, 2024

Integration tests failure for 7a392ecb0819a0dd6cf36439c7a8d32a93d53a3f

@sfc-gh-asawicki sfc-gh-asawicki merged commit fc1eace into main Dec 9, 2024
8 of 9 checks passed
@sfc-gh-asawicki sfc-gh-asawicki deleted the functions-sdk-update branch December 9, 2024 17:11
sfc-gh-jcieslak pushed a commit that referenced this pull request Dec 12, 2024
🤖 I have created a release *beep* *boop*
---


##
[0.100.0](v0.99.0...v0.100.0)
(2024-12-12)


### 🎉 **What's new:**

* Account v1 readiness
([#3236](#3236))
([5df33a8](5df33a8))
* Account v1 readiness generated files
([#3242](#3242))
([3df59dd](3df59dd))
* Account v1 readiness resource
([#3252](#3252))
([8f5698d](8f5698d))
* Add a new account roles data source
([#3257](#3257))
([b3d6b9e](b3d6b9e))
* Add account data source
([#3261](#3261))
([6087fc9](6087fc9))
* Add all other functions and procedures implementations
([#3275](#3275))
([7a6f68d](7a6f68d))
* Basic functions implementation
([#3269](#3269))
([6d4a103](6d4a103))
* Basic procedures implementation
([#3271](#3271))
([933335f](933335f))
* Docs, test, and missing parameter
([#3280](#3280))
([10517f3](10517f3))
* Functions and procedures schemas and generated sources
([#3262](#3262))
([9b70f87](9b70f87))
* Functions sdk update
([#3254](#3254))
([fc1eace](fc1eace))
* Handle missing fields in function and procedure
([#3273](#3273))
([53e7a0a](53e7a0a))
* Procedures schemas and generated sources
([#3263](#3263))
([211ad46](211ad46))
* Procedures sdk update
([#3255](#3255))
([682606a](682606a))
* Rework account parameter resource
([#3264](#3264))
([15aa9c2](15aa9c2))
* Rework data types
([#3244](#3244))
([05ada91](05ada91))
* support table data type
([#3274](#3274))
([13401d5](13401d5))
* Tag association v1 readiness
([#3210](#3210))
([04f6d54](04f6d54))
* Test imports and small fixes
([#3276](#3276))
([a712195](a712195))
* Unsafe execute v1 readiness
([#3266](#3266))
([c4f1e8f](c4f1e8f))
* Use new data types in sql builder for functions and procedures
([#3247](#3247))
([69f677a](69f677a))


### 🔧 **Misc**

* Add ShowByID filtering generation
([#3227](#3227))
([548ec42](548ec42))
* Adress small task-related todos
([#3243](#3243))
([40de9ae](40de9ae))
* Apply masking
([#3234](#3234))
([c209a8a](c209a8a))
* fix missing references in toOpts and changes with newlines
([#3240](#3240))
([246547f](246547f))
* function tests
([#3279](#3279))
([5af6efb](5af6efb))
* Improve config builders
([#3207](#3207))
([425787c](425787c))
* Revert to proper env
([#3238](#3238))
([5d4ed3b](5d4ed3b))
* Use service user for ci
([#3228](#3228))
([2fb50d7](2fb50d7))


### 🐛 **Bug fixes:**

* Make blocked_roles_field optional in OAuth security integrations
([#3267](#3267))
([7197b57](7197b57))
* Minor fixes
([#3231](#3231))
([1863bf6](1863bf6))
* Minor fixes 2
([#3230](#3230))
([73b7e74](73b7e74))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: snowflake-release-please[bot] <105954990+snowflake-release-please[bot]@users.noreply.github.com>
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.

3 participants