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!

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

1 Like

Hey Dawid!

That worked, thanks!

cam u get Employer database

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