Repository navigation
fix: Validate entity column types in feast dbt import - #7067
Open
NopeCharon wants to merge 1 commit into
Open
NopeCharon wants to merge 1 commit into
NopeCharon wants to merge 1 commit into
Conversation
`feast dbt import` only checked that the entity columns exist. A model whose entity column is declared as FLOAT64, BOOLEAN, BYTES or TIMESTAMP was imported silently, producing an entity keyed on a floating point, boolean, binary or timestamp value. A model with an ARRAY entity column crashed the whole import with an unhandled ValueError from FeatureView. The import now maps each entity column's dbt type through the existing dbt-to-Feast type mapping and: - skips models with an array entity column, with a warning, in the same way as models that miss an entity or timestamp column; - prints a warning for entity columns that map to anything other than String, Int32 or Int64, naming the dbt type and the Feast type it maps to, and still imports the model. This also flags Snowflake's NUMBER(38,0), which the mapping turns into Float64. Columns without a declared data_type default to STRING and do not warn. The list of imported models used for the summary and for --output code generation is now collected while processing models instead of being recomputed afterwards from column presence, so skipped models can no longer leak into the generated file. The dbt how-to documents the check and the new warnings. Fixes feast-dev#5876 Signed-off-by: NopeCharon <115794254+NopeCharon@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it:
feast dbt importonly checks that the entity columns exist. Their type is never looked at:FLOAT64,BOOLEAN,BYTESorTIMESTAMPimports silently, and Feast creates an entity keyed on a floating point, boolean, binary or timestamp value.ARRAY<...>entity column crashes the whole import with an unhandledValueError: Entity driver_id has type ValueType.STRING, which does not match the inferred type Array(...)raised fromFeatureView.__init__.With this PR, the import maps each entity column's dbt type through the existing
map_dbt_type_to_feast_typemapping and then:Model '...' has array entity column(s): ... Skipping.). This matches how models missing an entity or timestamp column are handled.String,Int32orInt64: a warning names the dbt type and the Feast type it maps to, and the model is still imported. For example:Warning: Model 'driver_features' entity column 'conv_rate' has type 'float64' (Feast type Float64), which may not be suitable as an entity key. Recommended types: STRING, INT64. Importing anyway.This also flags Snowflake'sNUMBER(38,0), which the mapping turns intoFloat64.data_type: columns without one default toSTRINGand do not warn.The models used for the summary and for
--outputcode generation are now collected as they are processed, instead of being recomputed afterwards from column presence. Otherwise a skipped model would still be written into the generated file.The dbt how-to documents the check and the two new warnings in its Requirements and Troubleshooting sections.
Which issue(s) this PR fixes:
Fixes #5876
Checks
git commit -s)Testing Strategy
Unit tests: the new
sdk/python/tests/unit/dbt/test_entity_column_type.pybuilds manifests and runsfeast dbt importthrough the CLI. It covers:FLOAT64,NUMBER(38,0),BOOLEAN,BYTESandTIMESTAMP, with the model still importedSTRING,VARCHAR(36),INT64,INTEGER,NUMBER(10,0)and an undeclared typeARRAY<INT64>entity column is skipped, and with--outputit is left out of the generated file while the other model is keptSeven of these cases fail on master (the array case with the
ValueErrorabove). All 50 tests intests/unit/dbtpass.Integration tests:
make test-python-integration-dbt(dbt-core + dbt-duckdb) passes, 84 tests.Manual tests: ran
feast dbt import --dry-runagainst the integration project's generated manifest with-e driver_id(no warning) and-e conv_rate(warning shown).Static checks: scoped
ruff check,ruff format --checkandmypyare clean.