Commit 05a4fb5
authored
feat: Add multiple entity support to dbt integration (#5901)
* feat: Add multiple entity support to dbt integration
- Update CLI to accept multiple -e flags for entity columns
- Update mapper and codegen for multiple entities
- Update documentation with examples and usage
This extends the dbt integration to support FeatureViews with
multiple entities, enabling use cases like transaction features
keyed by both user_id and merchant_id.
Fixes #5872
Signed-off-by: yassinnouh21 <yassinnouh21@gmail.com>
* fix: Infer entity value types from dbt column types
When creating entities from dbt models with integer columns, entities were
being created with default ValueType.STRING, causing validation errors:
"Entity X has type ValueType.STRING, which does not match the inferred type Int64"
Solution: Added mapping dict and helper function for clean type conversion:
- FEAST_TYPE_TO_VALUE_TYPE: Maps FeastType to ValueType
- feast_type_to_value_type(): Helper function for conversion
- _infer_entity_value_type(): Method in DbtToFeastMapper class
This replaces verbose if-else chains with a clean dictionary lookup pattern.
Also corrects schema generation to include entity columns, as FeatureView.__init__
expects to extract entity columns from the schema itself (lines 216-234 in
feature_view.py).
Changes:
- feast/cli/dbt_import.py: Use mapper's _infer_entity_value_type() method
- feast/dbt/mapper.py: Add type mapping dict and helper method
Signed-off-by: yassinnouh21 <yassinnouh21@gmail.com>
* fix: Update unit tests for multi-entity parameter changes
Updated test_mapper.py to use new parameter names:
- entity_column -> entity_columns (accepts both str and List[str])
- result["entity"] -> result["entities"] (now returns list)
Tests now correctly check for list of entities returned by
create_all_from_model().
Signed-off-by: yassinnouh21 <yassinnouh21@gmail.com>
---------
Signed-off-by: yassinnouh21 <yassinnouh21@gmail.com>1 parent 739d28a commit 05a4fb5Copy full SHA for 05a4fb5
5 files changed
+232-74Lines changed: 232 additions & 74 deletions
File tree
Expand file treeCollapse file tree
Open diff view settings
Filter options
- docs/how-to-guides
- sdk/python
- feast
- cli
- dbt
- tests/unit/dbt
Expand file treeCollapse file tree
Open diff view settings
Collapse file
docs/how-to-guides/dbt-integration.md
Copy file name to clipboardExpand all lines: docs/how-to-guides/dbt-integration.md+48-2Lines changed: 48 additions & 2 deletions
- Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
5 | 5 | |
6 | 6 | |
7 | 7 | |
8 | | - |
9 | 8 | |
10 | 9 | |
11 | 10 | |
| ||
185 | 184 | |
186 | 185 | |
187 | 186 | |
| 187 | + |
| 188 | + |
| 189 | + |
| 190 | + |
| 191 | + |
| 192 | + |
| 193 | + |
| 194 | + |
| 195 | + |
| 196 | + |
| 197 | + |
| 198 | + |
| 199 | + |
| 200 | + |
| 201 | + |
| 202 | + |
| 203 | + |
| 204 | + |
| 205 | + |
| 206 | + |
| 207 | + |
| 208 | + |
| 209 | + |
| 210 | + |
| 211 | + |
| 212 | + |
| 213 | + |
| 214 | + |
| 215 | + |
| 216 | + |
| 217 | + |
| 218 | + |
| 219 | + |
| 220 | + |
| 221 | + |
| 222 | + |
| 223 | + |
| 224 | + |
| 225 | + |
| 226 | + |
| 227 | + |
| 228 | + |
| 229 | + |
| 230 | + |
| 231 | + |
| 232 | + |
| 233 | + |
188 | 234 | |
189 | 235 | |
190 | 236 | |
| ||
217 | 263 | |
218 | 264 | |
219 | 265 | |
220 | | - |
| 266 | + |
221 | 267 | |
222 | 268 | |
223 | 269 | |
|
Collapse file
sdk/python/feast/cli/dbt_import.py
Copy file name to clipboardExpand all lines: sdk/python/feast/cli/dbt_import.py+50-19Lines changed: 50 additions & 19 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
30 | 30 | |
31 | 31 | |
32 | 32 | |
| 33 | + |
| 34 | + |
33 | 35 | |
34 | | - |
| 36 | + |
35 | 37 | |
36 | 38 | |
37 | 39 | |
| ||
89 | 91 | |
90 | 92 | |
91 | 93 | |
92 | | - |
| 94 | + |
93 | 95 | |
94 | 96 | |
95 | 97 | |
| ||
141 | 143 | |
142 | 144 | |
143 | 145 | |
| 146 | + |
| 147 | + |
| 148 | + |
| 149 | + |
| 150 | + |
| 151 | + |
| 152 | + |
| 153 | + |
| 154 | + |
| 155 | + |
| 156 | + |
| 157 | + |
| 158 | + |
| 159 | + |
| 160 | + |
| 161 | + |
| 162 | + |
| 163 | + |
| 164 | + |
| 165 | + |
| 166 | + |
| 167 | + |
144 | 168 | |
145 | 169 | |
146 | 170 | |
| ||
188 | 212 | |
189 | 213 | |
190 | 214 | |
191 | | - |
192 | | - |
| 215 | + |
| 216 | + |
| 217 | + |
193 | 218 | |
194 | 219 | |
195 | | - |
| 220 | + |
196 | 221 | |
197 | 222 | |
198 | 223 | |
199 | | - |
200 | | - |
201 | | - |
202 | | - |
203 | | - |
204 | | - |
205 | | - |
206 | | - |
207 | | - |
208 | | - |
| 224 | + |
| 225 | + |
| 226 | + |
| 227 | + |
| 228 | + |
| 229 | + |
| 230 | + |
| 231 | + |
| 232 | + |
| 233 | + |
| 234 | + |
| 235 | + |
| 236 | + |
| 237 | + |
| 238 | + |
| 239 | + |
209 | 240 | |
210 | 241 | |
211 | 242 | |
| ||
218 | 249 | |
219 | 250 | |
220 | 251 | |
221 | | - |
222 | | - |
| 252 | + |
| 253 | + |
223 | 254 | |
224 | 255 | |
225 | 256 | |
| ||
242 | 273 | |
243 | 274 | |
244 | 275 | |
245 | | - |
| 276 | + |
246 | 277 | |
247 | 278 | |
248 | 279 | |
| ||
257 | 288 | |
258 | 289 | |
259 | 290 | |
260 | | - |
| 291 | + |
261 | 292 | |
262 | 293 | |
263 | 294 | |
|
Collapse file
sdk/python/feast/dbt/codegen.py
Copy file name to clipboardExpand all lines: sdk/python/feast/dbt/codegen.py+34-21Lines changed: 34 additions & 21 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
6 | 6 | |
7 | 7 | |
8 | 8 | |
9 | | - |
| 9 | + |
10 | 10 | |
11 | 11 | |
12 | 12 | |
| ||
106 | 106 | |
107 | 107 | |
108 | 108 | |
109 | | - |
| 109 | + |
110 | 110 | |
111 | 111 | |
112 | 112 | |
| ||
220 | 220 | |
221 | 221 | |
222 | 222 | |
223 | | - |
| 223 | + |
224 | 224 | |
225 | 225 | |
226 | 226 | |
| ||
231 | 231 | |
232 | 232 | |
233 | 233 | |
234 | | - |
| 234 | + |
235 | 235 | |
236 | 236 | |
237 | 237 | |
| ||
240 | 240 | |
241 | 241 | |
242 | 242 | |
243 | | - |
| 243 | + |
| 244 | + |
| 245 | + |
| 246 | + |
| 247 | + |
| 248 | + |
| 249 | + |
| 250 | + |
| 251 | + |
244 | 252 | |
245 | 253 | |
246 | 254 | |
247 | 255 | |
248 | 256 | |
249 | 257 | |
250 | | - |
| 258 | + |
251 | 259 | |
252 | | - |
253 | | - |
254 | | - |
255 | | - |
256 | | - |
257 | | - |
258 | | - |
259 | | - |
260 | | - |
261 | | - |
| 260 | + |
| 261 | + |
| 262 | + |
| 263 | + |
| 264 | + |
| 265 | + |
| 266 | + |
| 267 | + |
| 268 | + |
| 269 | + |
| 270 | + |
| 271 | + |
| 272 | + |
262 | 273 | |
263 | 274 | |
264 | 275 | |
| ||
269 | 280 | |
270 | 281 | |
271 | 282 | |
272 | | - |
| 283 | + |
| 284 | + |
| 285 | + |
273 | 286 | |
274 | 287 | |
275 | 288 | |
| ||
339 | 352 | |
340 | 353 | |
341 | 354 | |
342 | | - |
| 355 | + |
343 | 356 | |
344 | 357 | |
345 | 358 | |
| ||
366 | 379 | |
367 | 380 | |
368 | 381 | |
369 | | - |
| 382 | + |
370 | 383 | |
371 | 384 | |
372 | 385 | |
| ||
380 | 393 | |
381 | 394 | |
382 | 395 | |
383 | | - |
| 396 | + |
384 | 397 | |
385 | 398 | |
386 | 399 | |
| ||
400 | 413 | |
401 | 414 | |
402 | 415 | |
403 | | - |
| 416 | + |
404 | 417 | |
405 | 418 | |
406 | 419 | |
|
0 commit comments