-
Notifications
You must be signed in to change notification settings - Fork 10
/
macro.yml
180 lines (164 loc) · 6.48 KB
/
macro.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
version: 2
macros:
- name: get_column_names
description: >
'Returns string column names of relation passed or passes through
list of strings if already supplied'
arguments:
- name: relation
type: 'Relation'
description: 'Relation passed with Jinja ref syntax'
- name: get_matches
description: Returns list of strings matching provided regular expression
arguments:
- name: input_list
type: 'List'
description: 'List of characters'
- name: regex
type: 'Character'
description: 'Regular expression to be used for comparison in re.match()'
- name: across
description: >
'Generates blocks of SQL code by iterating over a list of variable names,
and inserting these names into a template string of code at the places
marked with \{\{var\}\}. Note that comas are inserted between lines of code but
not after the final loop. If desired, this must be done manually.'
arguments: &argsAcross
- name: var_list
type: 'List'
description: List of variables over which to apply logic block
- name: script_string
type: 'String'
description: >
'String of script to include for each variable
with variable name abstracted to \{\{var\}\}.
By default, will return column names with no transformation.'
- name: final_comma
type: 'Boolean'
description: >
'false (default) or true to denote whether to include terminal comma.
This is particularly useful if var_list may return null. In that case,
including the comma on the inside is safer than hard-coding it in your
main SQL script.'
- name: c_across
description: >
'Generates blocks of SQL code by iterating over a list of variable names,
and inserting these names into a template string. If template script is a single
character, the template string itself is put between each variable. For example,
+ converts to a+b+c. Otherwise it should contain \{\{var\}\}, which will the be
replaced with a comma-separated list of variables. For example,
greatest(\{\{var\}\}) would be replaced with greatest(a,b,c). '
arguments:
- name: var_list
type: 'List'
description: List of variables over which to apply logic block
- name: script_string
type: 'String'
description: >
'String of script to include for each variable
with variable name abstracted to \{\{var\}\} or provided
as operator to place between each element of the variable list.'
- name: if_any
description: >
'Generates blocks of SQL code by iterating over a list of variable names,
and inserting these names into a template string of code at the places
marked with \{\{var\}\}. Conditions are separated by logical OR.'
arguments: &argsIf
- name: var_list
type: 'List'
description: List of variables over which to apply logic block
- name: script_string
type: 'String'
description: >
'String of script to include for each variable
with variable name abstracted to \{\{var\}\}'
- name: if_all
description: >
'Generates blocks of SQL code by iterating over a list of variable names,
and inserting these names into a template string of code at the places
marked with \{\{var\}\}. Conditions are separated by logical AND'
arguments: *argsIf
- name: starts_with
description: >
Returns list of string column names from relation
which start with a specified string
arguments: &args
- name: string
type: 'String'
description: String to match
- name: relation
type: 'Relation'
description: >
'Relation whose column names should be evaluated for matches.
If list of column names has already been obtained with a separate
call to get_column_names(), this list may be passed instead for efficiency.'
- name: ends_with
description: >
Returns list of string column names from relation
which end with a specified string
arguments: *args
- name: contains
description: >
Returns list of string column names from relation
which contain (at any position) a specified string
arguments: *args
- name: not_contains
description: >
Returns list of string column names from relation
which do not contain (at any position) a specified string
arguments: *args
- name: one_of
description: >
Returns list of string column names from relation
which exactly match any of a list of strings
arguments: &argsOneOf
- name: strings
type: 'List'
description: List of strings against which to compare column names
- name: relation
type: 'Relation'
description: Relation whose column names should be evaluated for matches or list of column names
- name: not_one_of
description: >
Returns list of string column names from relation
which do not match any of a list of strings
arguments: *argsOneOf
- name: matches
description: >
Returns list of string column names from relation
which exactly match a specified regex
arguments: *args
- name: everything
description: >
Returns list of string column names from relation
which start with specified string
arguments:
- name: relation
type: 'Relation'
description: 'Relation passed with Jinja ref syntax or list of column names'
- name: where
description: >
Returns list of string column names from relation
which are identified as a specific type
arguments:
- name: fn
type: 'String'
description: >
String with name of function for dbt Column class which identifies type.
Currently supports 'is_numeric', 'is_number', 'is_float', 'is_string'
- name: relaiton
type: 'Relation'
description: >
Relation passed with Jinja ref syntax. Note that unlike other macros,
a list of column names is not supported for this function because
metadata from the underlying Column class is required
- name: map
description: >
Utility function for applying a function to a list.
This function is intended for internal use only.
The primary use is currently to support the where function
arguments:
- name: input_list
description: List of objects
- name: fn
description: Function to apply