Parameter in sql table name

I am trying to parameterise my connection:

view: view_name {
  sql_table_name: {% parameter tablename %};;

  parameter: tablename{
    type: unquoted
    allowed_value: {
      label: "Staging"
      value: "`datatbase.staging.table`"
    }
    allowed_value: {
      label: "Production"
      value: "`database.prod.table`"
    }
    default_value: "`database.prod.table`"
  }

I get this error:

Filter on unquoted field view_name.tablename must contain only underscores, numbers, letters, '.', or '$'.

I’m not sure how to re-wrote the value to make this work.

Thanks!

Solved Solved
0 4 2,693
1 ACCEPTED SOLUTION

Hey Dawid!

That worked, thanks!

View solution in original post

4 REPLIES 4

I would write it this way: 

view: view_name {
sql_table_name: database.{% parameter schema %}.table;;

parameter: schema {
type: unquoted
allowed_value: {
label: "Staging"
value: "staging"
}
allowed_value: {
label: "Production"
value: "prod"
}
default_value: "prod"
}
}

Alternatively, try to remove the back ticks from your values, that could work too

Think you David , I want konw how can use this parameter value to multiole choice?

Hey Dawid!

That worked, thanks!

meqdam
New Member

cam u get Employer database

Top Labels in this Space
Top Solution Authors