forked from dataform-co/dataform
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add string agg function (dataform-co#1094)
* add string agg function * fix spelling mistake in README * another sp * omit redshift for test * switch != to !== Co-authored-by: Dan Lee <[email protected]>
- Loading branch information
DanLee
and
Dan Lee
authored
Nov 10, 2020
1 parent
ceccc5b
commit a1ccc79
Showing
4 changed files
with
47 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ Useful functions for constructing SQL statements in Dataform packages. | |
- Redshift | ||
- Snowflake | ||
|
||
*If you would like us to add support for another warehouse, please get in touch via [email](mailto:[email protected]) or [Slack](https://dataform.co/slack)* | ||
_If you would like us to add support for another warehouse, please get in touch via [email](mailto:[email protected]) or [Slack](https://dataform.co/slack)_ | ||
|
||
## Installation | ||
|
||
|
@@ -17,34 +17,35 @@ Useful functions for constructing SQL statements in Dataform packages. | |
### Common SQL functions | ||
|
||
#### surrogateKey | ||
|
||
Creates a unique hash from a list of fields. Useful for generating a surrogate key for a table. | ||
|
||
`${sql.surrogateKey(["field_one", "field_two"])}` | ||
|
||
#### windowFunction | ||
|
||
Creates a window function with the given configuration. | ||
|
||
`${sql.windowFunction({ | ||
name: "window_function_name", | ||
value: "target_column", | ||
ignoreNulls: true, | ||
windowSpecification: { | ||
partitionFields: ["field_to_partition_by_one", "field_to_partition_by_two"], | ||
orderFields: ["field_to_order_by_one", "field_to_order_by_two"], | ||
frameClause: "rows between 0 preceding and unbounded following" | ||
} | ||
})}` | ||
`${sql.windowFunction({ name: "window_function_name", value: "target_column", ignoreNulls: true, windowSpecification: { partitionFields: ["field_to_partition_by_one", "field_to_partition_by_two"], orderFields: ["field_to_order_by_one", "field_to_order_by_two"], frameClause: "rows between 0 preceding and unbounded following" } })}` | ||
|
||
#### asTimestamp | ||
|
||
Casts the field to timestamp type | ||
|
||
`${sql.asTimestamp("field")}` | ||
|
||
#### asString | ||
|
||
Casts the field to timestamp type | ||
|
||
`${sql.asString("field")}` | ||
|
||
#### stringAgg | ||
|
||
Groups the values in a field into a concatenated string, with an optional delimiter value that defaults to "," | ||
|
||
`${sql.stringAgg("field", "delimiter")}` | ||
|
||
### Timestamp functions | ||
|
||
Calculate the time difference between two timestamps. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters