Skip to content

Optional Parameters Support #3011

@arikfr

Description

@arikfr

Today to make a parameter optional, the user needs to have a workaround in the query logic itself. For example:

select count(0)
from queries
where 'All' = '{{org_id}}' or org_id::varchar = '{{org_id}}'

In this case when the value of org_id is All, then we don't filter by it. It will be great if the user could mark a whole section as optional if no parameter is provided. The templating language we use (Mustache) actually supports this:

select count(0)
from queries
{{#org_id}}
where 'All' = '{{org_id}}' or org_id::varchar = '{{org_id}}'
{{/org_id}}

If no value for {{org_id}} is provided, then the section between {{#org_id}} and {{/org_id}} won't be rendered. So in theory, we can just allow for passing empty values for parameters and it works.

This has two issues though:

  1. Any false-y value will make this section not render. Including 0 (zero), which might be acceptable in some cases.
  2. This might make the implementation of Move parameters merging to the backend and make it safe #2904 more complicated.

We should probably take this into account when implementing #2904, and revisit once it's indeed implemented.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions