Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6550ce6

Browse files
authored
Merge pull request #143 from lightdash/parameters-type
docs: parameters type
2 parents b32d600 + f6f42e4 commit 6550ce6

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

‎guides/using-parameters.mdx

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,61 @@ Parameters can be referenced in many places throughout your Lightdash project:
4444
7. **Additional Dimensions**: Use parameters in the SQL definition of an [additional dimension](/references/dimensions#additional-dimensions)
4545
8. **Custom Dimensions**: Use parameters in [custom dimension](/references/custom-fields#custom-sql) definitions
4646

47+
## Parameter types
48+
49+
Parameters in Lightdash support different data types to help you work with various kinds of data. By default, all parameters are treated as strings, but you can convert them to other types as needed.
50+
51+
### Supported parameter types
52+
53+
Lightdash officially supports the following parameter types:
54+
55+
- **String** (default): Text values
56+
- **Number**: Numeric values (integers and decimals)
57+
58+
### Type conversion workarounds
59+
60+
While not officially supported yet, you can work around for other data types via SQL type casting.
61+
To convert a parameter to a specific type, use the `::` syntax followed by the type name:
62+
63+
```sql
64+
${lightdash.parameters.parameter_name}::type
65+
```
66+
67+
<Note>
68+
The type conversion happens at the SQL level, so the available types depend on your database system (PostgreSQL, BigQuery, Snowflake, etc.). Common types like `integer`, `numeric`, `date`, `timestamp`, and `boolean` are supported across most databases.
69+
</Note>
70+
71+
#### Date conversion
72+
73+
As a workaround, you can use `::date` for dates or `::timestamp` for datetime values:
74+
75+
```sql
76+
-- Convert to date (workaround)
77+
WHERE ${TABLE}.order_date >= ${lightdash.parameters.start_date}::date
78+
79+
-- Convert to timestamp (workaround)
80+
WHERE ${TABLE}.created_at >= ${lightdash.parameters.start_datetime}::timestamp
81+
```
82+
83+
#### Boolean conversion
84+
85+
As a workaround, you can use `::boolean` to convert string values like "true"/"false" to boolean:
86+
87+
```sql
88+
-- Convert to boolean (workaround)
89+
WHERE ${TABLE}.is_active = ${lightdash.parameters.active_only}::boolean
90+
```
91+
92+
#### Other type conversions
93+
94+
You can use any SQL type conversion that your database supports:
95+
96+
```sql
97+
-- Convert to specific database types
98+
WHERE ${TABLE}.category_id = ${lightdash.parameters.category}::uuid
99+
WHERE ${TABLE}.amount = ${lightdash.parameters.amount}::decimal(10,2)
100+
```
101+
47102
## How to reference parameters in SQL
48103

49104
### Project-level parameters

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /