-
Notifications
You must be signed in to change notification settings - Fork 396
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
[Feature] Add databricks_function
resource
#4189
base: main
Are you sure you want to change the base?
Conversation
…source updating feature branch.
databricks_function
resourcedatabricks_function
resource
databricks_function
resourcedatabricks_function
resource
Hello, is there any timeline on when this could make it into the provider? Would love to have this soon! |
Hi @ian-norris-ncino. I'm aiming to have this integrated into the provider by the end of the month, depending on my availability. I'll keep you posted. |
databricks_function
resourcedatabricks_function
resource
name = "calculate_bmi" | ||
catalog_name = databricks_catalog.sandbox.name | ||
schema_name = databricks_schema.functions.name | ||
input_params = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could be easier for people to specify input_param
as separate blocks, like we do in other resources
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although doc says that input_params
is a block, and then there are parameters inside: https://docs.databricks.com/api/workspace/functions/create#input_params
Test Details: go/deco-tests/11869831592 |
internal/providers/pluginfw/resources/catalog/resource_function.go
Outdated
Show resolved
Hide resolved
internal/providers/pluginfw/resources/catalog/resource_function.go
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @dgomez04, thanks for the PR, left some comments.
internal/providers/pluginfw/resources/catalog/resource_function.go
Outdated
Show resolved
Hide resolved
internal/providers/pluginfw/resources/catalog/resource_function.go
Outdated
Show resolved
Hide resolved
internal/providers/pluginfw/resources/catalog/resource_function.go
Outdated
Show resolved
Hide resolved
internal/providers/pluginfw/resources/catalog/resource_function.go
Outdated
Show resolved
Hide resolved
internal/providers/pluginfw/resources/catalog/resource_function_acc_test.go
Outdated
Show resolved
Hide resolved
If integration tests don't run automatically, an authorized user can run them manually by following the instructions below: Trigger: Inputs:
Checks will be approved automatically on success. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking nice! Some changes needed for the next iteration, but I think we're not far from the final state.
resource "databricks_function" "calculate_bmi" { | ||
name = "calculate_bmi" | ||
catalog_name = databricks_catalog.sandbox.name | ||
schema_name = databricks_schema.functions.name | ||
input_params = [ | ||
{ | ||
name = "weight" | ||
type = "DOUBLE" | ||
}, | ||
{ | ||
name = "height" | ||
type = "DOUBLE" | ||
} | ||
] | ||
data_type = "DOUBLE" | ||
routine_body = "SQL" | ||
routine_definition = "weight / (height * height)" | ||
language = "SQL" | ||
is_deterministic = true | ||
sql_data_access = "CONTAINS_SQL" | ||
security_type = "DEFINER" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on my reading of the FunctionInfo type, this will need to look a bit different. Not your fault, as some of these things have changed since you started writing this PR. Specifically, the input_params
is an object with a list nested object field parameters
.
resource "databricks_function" "calculate_bmi" { | |
name = "calculate_bmi" | |
catalog_name = databricks_catalog.sandbox.name | |
schema_name = databricks_schema.functions.name | |
input_params = [ | |
{ | |
name = "weight" | |
type = "DOUBLE" | |
}, | |
{ | |
name = "height" | |
type = "DOUBLE" | |
} | |
] | |
data_type = "DOUBLE" | |
routine_body = "SQL" | |
routine_definition = "weight / (height * height)" | |
language = "SQL" | |
is_deterministic = true | |
sql_data_access = "CONTAINS_SQL" | |
security_type = "DEFINER" | |
} | |
resource "databricks_function" "calculate_bmi" { | |
name = "calculate_bmi" | |
catalog_name = databricks_catalog.sandbox.name | |
schema_name = databricks_schema.functions.name | |
input_params = { | |
parameters = [{ | |
name = "weight" | |
type_name = "DOUBLE" | |
}, | |
{ | |
name = "height" | |
type_name = "DOUBLE" | |
}] | |
] | |
data_type = "DOUBLE" | |
routine_body = "SQL" | |
routine_definition = "weight / (height * height)" | |
is_deterministic = true | |
sql_data_access = "CONTAINS_SQL" | |
security_type = "DEFINER" | |
} |
resource "databricks_function" "calculate_bmi_py" { | ||
name = "calculate_bmi_py" | ||
catalog_name = databricks_catalog.sandbox.name | ||
schema_name = databricks_schema.functions.name | ||
input_params = [ | ||
{ | ||
name = "weight_kg" | ||
type = "DOUBLE" | ||
}, | ||
{ | ||
name = "height_m" | ||
type = "DOUBLE" | ||
} | ||
] | ||
data_type = "DOUBLE" | ||
routine_body = "EXTERNAL" | ||
routine_definition = "return weight_kg / (height_m ** 2)" | ||
language = "Python" | ||
is_deterministic = false | ||
sql_data_access = "NO_SQL" | ||
security_type = "DEFINER" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resource "databricks_function" "calculate_bmi_py" { | |
name = "calculate_bmi_py" | |
catalog_name = databricks_catalog.sandbox.name | |
schema_name = databricks_schema.functions.name | |
input_params = [ | |
{ | |
name = "weight_kg" | |
type = "DOUBLE" | |
}, | |
{ | |
name = "height_m" | |
type = "DOUBLE" | |
} | |
] | |
data_type = "DOUBLE" | |
routine_body = "EXTERNAL" | |
routine_definition = "return weight_kg / (height_m ** 2)" | |
language = "Python" | |
is_deterministic = false | |
sql_data_access = "NO_SQL" | |
security_type = "DEFINER" | |
} | |
resource "databricks_function" "calculate_bmi_py" { | |
name = "calculate_bmi_py" | |
catalog_name = databricks_catalog.sandbox.name | |
schema_name = databricks_schema.functions.name | |
input_params = { | |
parameters = [ | |
{ | |
name = "weight_kg" | |
type_name = "DOUBLE" | |
}, | |
{ | |
name = "height_m" | |
type_name = "DOUBLE" | |
}] | |
} | |
data_type = "DOUBLE" | |
routine_body = "EXTERNAL" | |
routine_definition = "return weight_kg / (height_m ** 2)" | |
is_deterministic = false | |
sql_data_access = "NO_SQL" | |
security_type = "DEFINER" | |
} |
// TODO Add resources here | ||
sharing.ResourceShare, // Using the staging name (with pluginframework suffix) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems extra, can you remove this?
@@ -42,6 +42,9 @@ var migratedDataSources = []func() datasource.DataSource{ | |||
// List of resources that have been onboarded to the plugin framework - not migrated from sdkv2. | |||
// Keep this list sorted. | |||
var pluginFwOnlyResources = []func() resource.Resource{ | |||
// TODO Add resources here | |||
sharing.ResourceShare, // Using the staging name (with pluginframework suffix) | |||
catalog.ResourceFunction, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you sort this alphabetically (after app.ResourceApp
)?
|
||
func (r *FunctionResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { | ||
attrs, blocks := tfschema.ResourceStructToSchemaMap(catalog_tf.FunctionInfo{}, func(c tfschema.CustomizableSchema) tfschema.CustomizableSchema { | ||
c.ToNestedBlockObject() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to call this anymore (it was actually removed). For resources that are migrated from SDKv2, you need to call c.ConfigureForSdkV2Migration()
, but this is a new resource, so nothing is needed here.
c.SetRequired("name") | ||
c.SetRequired("catalog_name") | ||
c.SetRequired("schema_name") | ||
c.SetRequired("input_params") | ||
c.SetRequired("data_type") | ||
c.SetRequired("full_data_type") | ||
c.SetRequired("routine_defintion") | ||
c.SetRequired("is_deterministic") | ||
c.SetRequired("is_null_call") | ||
c.SetRequired("specific_name") | ||
c.SetRequired("routine_body") | ||
c.SetRequired("security_type") | ||
c.SetRequired("sql_data_access") | ||
c.SetRequired("parameter_style") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these actually needed? As in, if you don't have them, are they treated as optional?
return | ||
} | ||
|
||
funcName := stateFunc.Name.ValueString() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need to use FullName here instead of Name?
c.SetReadOnly("updated_at") | ||
c.SetReadOnly("updated_by") | ||
|
||
return c |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked at UpdateFunction, and it seems like the only thing you can update about a function is its owner. Everything else cannot be updated. Can we mark all other fields with SetForceNew()
?
Changes
Introduces
databricks_function
resource—allowing users to create and manage UDFs within Terraform. work in progress...Closes #4074
Tests
make test
run locallydocs/
folderinternal/acceptance