You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Update README.md
* Mutually excl range examples in disclosure triangle
* Fix union_relations error when no include/exclude provided
* Fix union_relations error when no include/exclude provided (#509)
* Update CHANGELOG.md
* Add to_condition to relationships where
* very minor nit - update "an new" to "a new" (#519)
* add quoting to split_part (#528)
* add quoting to split_part
* update docs for split_part
* typo
* corrected readme syntax
* revert and update to just documentation
* add new line
* Update README.md
* Update README.md
* Update README.md
Co-authored-by: Joel Labes <joel.labes@dbtlabs.com>
* add macro to get columns (#516)
* add macro to get columns
* star macro should use get_columns
* add adapter.
* swap adapter for dbt_utils
Co-authored-by: Joel Labes <joel.labes@dbtlabs.com>
* update documentation
* add output_lower arg
* update name to get_filtered_columns_in_relation from get_columns
* add tests
* forgot args
* too much whitespace removal
-----------
Actual:
-----------
--->"field_3"as "test_field_3"<---
-----------
Expected:
-----------
--->"field_3" as "test_field_3"<---
* didnt mean to move a file that i did not create. moving things back.
* remove lowercase logic
* limit_zero
Co-authored-by: Joel Labes <joel.labes@dbtlabs.com>
* Add listagg macro and integration test
* remove type in listagg macro
* updated integration test
* Add redshift to listagg macro
* remove redshift listagg
* explicitly named group by column
* updated default values
* Updated example to use correct double vs. single quotes
* whitespace control
* Added redshift specific macro
* Remove documentation
* Update integration test so less likely to accidentally work
Co-authored-by: Joel Labes <joel.labes@dbtlabs.com>
* default everything but measure to none
* added limit functionality for other dbs
* syntax bug for postgres
* update redshift macro
* fixed block def control
* Fixed bug in redshift
* Bug fix redshift
* remove unused group_by arg
* Added additional test without order by col
* updated to regex replace
* typo
* added more integration_tests
* attempt to make redshift less complicated
* typo
* update redshift
* replace to substr
* More explicit versions with added complexity
* handle special characters
Co-authored-by: Joel Labes <joel.labes@dbtlabs.com>
Co-authored-by: Jamie Rosenberg <james.rosenberg@canva.com>
Co-authored-by: Pat Kearns <pat.kearns@fishtownanalytics.com>
Copy file name to clipboardexpand all lines: CHANGELOG.md
+1
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,4 @@
1
+
1
2
# dbt-utils v0.8.3
2
3
## New features
3
4
- A macro for deduplicating data ([#335](https://github.com/dbt-labs/dbt-utils/issues/335), [#512](https://github.com/dbt-labs/dbt-utils/pull/512))
This macro returns the unique values for a column in a given [relation](https://docs.getdbt.com/docs/writing-code-in-dbt/class-reference/#relation) as an array.
553
553
554
-
Arguments:
554
+
**Args:**
555
555
- `table` (required): a [Relation](https://docs.getdbt.com/reference/dbt-classes#relation) (a `ref` or `source`) that contains the list of columns you wish to select from
556
556
- `column` (required): The name of the column you wish to find the column values of
557
557
- `order_by` (optional, default=`'count(*) desc'`): How the results should be ordered. The default is to order by `count(*) desc`, i.e. decreasing frequency. Setting this as `'my_column'` will sort alphabetically, while `'min(created_at)'` will sort by when thevalue was first observed.
This macro returns an iterable Jinja list of columns for a given [relation](https://docs.getdbt.com/docs/writing-code-in-dbt/class-reference/#relation), (i.e. not from a CTE)
597
+
- optionally exclude columns
598
+
- the input values are not case-sensitive (input uppercase or lowercase and it will work!)
599
+
> Note: The native [`adapter.get_columns_in_relation` macro](https://docs.getdbt.com/reference/dbt-jinja-functions/adapter#get_columns_in_relation) allows you
600
+
to pull column names in a non-filtered fashion, also bringing along with it other (potentially unwanted) information, such as dtype, char_size, numeric_precision, etc.
601
+
602
+
**Args:**
603
+
- `from` (required): a [Relation](https://docs.getdbt.com/reference/dbt-classes#relation) (a `ref` or `source`) that contains the list of columns you wish to select from
604
+
- `except` (optional, default=`[]`): The name of the columns you wish to exclude. (case-insensitive)
605
+
606
+
**Usage:**
607
+
```sql
608
+
-- Returns a list of the columns from a relation, so you can then iterate in a for loop
609
+
{% set column_names = dbt_utils.get_filtered_columns_in_relation(from=ref('your_model'), except=["field_1", "field_2"]) %}
610
+
...
611
+
{% for column_name in column_names %}
612
+
max({{ column_name }}) ... as max_'{{ column_name }}',
Returns a list of [Relations](https://docs.getdbt.com/docs/writing-code-in-dbt/class-reference/#relation)
597
619
that match a given schema- or table-name pattern.
@@ -770,9 +792,20 @@ group by 1,2,3
770
792
```
771
793
772
794
#### star ([source](macros/sql/star.sql))
773
-
This macro generates a comma-separated list of all fields that exist in the `from` relation, excluding any fields listed in the `except` argument. The construction is identical to `select * from {{ref('my_model')}}`, replacing star (`*`) with the star macro. This macro also has an optional `relation_alias` argument that will prefix all generated fields with an alias (`relation_alias`.`field_name`).
795
+
This macro generates a comma-separated list of all fields that exist in the `from` relation, excluding any fields
796
+
listed in the `except` argument. The construction is identical to `select * from {{ref('my_model')}}`, replacing star (`*`) with
797
+
the star macro.
798
+
This macro also has an optional `relation_alias` argument that will prefix all generated fields with an alias (`relation_alias`.`field_name`).
799
+
The macro also has optional `prefix` and `suffix` arguments. When one or both are provided, they will be concatenated onto each field's alias
800
+
in the output (`prefix` ~ `field_name` ~ `suffix`). NB: This prevents the output from being used in any context other than a select statement.
801
+
774
802
775
-
The macro also has optional `prefix` and `suffix` arguments. When one or both are provided, they will be concatenated onto each field's alias in the output (`prefix` ~ `field_name` ~ `suffix`). NB: This prevents the output from being used in any context other than a select statement.
803
+
**Args:**
804
+
-`from` (required): a [Relation](https://docs.getdbt.com/reference/dbt-classes#relation) (a `ref` or `source`) that contains the list of columns you wish to select from
805
+
-`except` (optional, default=`[]`): The name of the columns you wish to exclude. (case-insensitive)
806
+
-`relation_alias` (optional, default=`''`): will prefix all generated fields with an alias (`relation_alias`.`field_name`).
807
+
-`prefix` (optional, default=`''`): will prefix the output `field_name` (`field_name as prefix_field_name`).
808
+
-`suffix` (optional, default=`''`): will suffix the output `field_name` (`field_name as field_name_suffix`).
0 commit comments