Skip to content

examples for functions #860

Answered by cstmgl
cstmgl asked this question in Q&A
Feb 15, 2022 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

I think my first guess was close enough, this seems to work:

resource "snowflake_function" "proc_array_max" {
  arguments {
    name = "A"
    type = "ARRAY"
  }
  provider    = snowflake.datavault_sysadmin
  for_each    = local.databases
  database    = each.value
  name        = "ARRAY_MAX"
  return_type = "VARCHAR"
  schema      = "PROC"
  language    = "javascript"
  statement   = <<-EOT
    return ''+(A.sort().reverse().shift() ?? '');
  EOT
  depends_on  = [snowflake_schema.proc]
}

It probably, at least in my mind, would be nice to have an example in the actual documentation

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Dinesh-Rupchandani
Comment options

Answer selected by cstmgl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants