Skip to content

Commit 46b60e0

Browse files
committed
feat: Warn when the dbt import timestamp field is not a timestamp type
The import command only checked that the timestamp column exists, so a column declared STRING or INT64 produced a FeatureView whose timestamp_field cannot anchor point-in-time retrieval. Check the column's dbt type with the existing dbt-to-Feast mapping and print a warning when it does not map to a timestamp type. The model is still imported. Signed-off-by: luc-pimentel <154371376+luc-pimentel@users.noreply.github.com>
1 parent 5b9737d commit 46b60e0

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

‎docs/how-to-guides/dbt-integration.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,10 @@ Ensure your dbt model includes the entity column specified with `--entity-column
434434

435435
By default, Feast looks for `event_timestamp`. Use `--timestamp-field` to specify a different column name.
436436

437+
### "Timestamp field ... does not map to a timestamp type"
438+
439+
The timestamp column exists but its `data_type` in schema.yml is not a timestamp type (for example `STRING` or `INT64`). The model is still imported, but point-in-time retrieval needs a real timestamp column. Declare the column as `TIMESTAMP`, `DATETIME` or `DATE` in schema.yml. Columns with no `data_type` are treated as `STRING` and also trigger this warning.
440+
437441
### "Entity column ... may not be suitable as an entity key"
438442

439443
The entity column's `data_type` in schema.yml maps to a Feast type other than a string or integer type. Floating point values are unreliable join keys, and boolean, binary and timestamp columns rarely identify an entity. The model is still imported. Use a `STRING` or `INT64` column as the entity, or declare the column's type in schema.yml if it is wrong. `NUMBER` types with a precision above 18, such as Snowflake's `NUMBER(38,0)`, map to `Float64`; declare integer IDs as `INTEGER` or `NUMBER(18,0)` instead.

‎sdk/python/feast/cli/dbt_import.py‎

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,14 @@ def import_command(
123123
"""
124124
from feast.dbt.mapper import DbtToFeastMapper, map_dbt_type_to_feast_type
125125
from feast.dbt.parser import DbtManifestParser, DbtModel
126-
from feast.types import Array, Int32, Int64, String
126+
from feast.types import (
127+
Array,
128+
Int32,
129+
Int64,
130+
String,
131+
UnixTimestamp,
132+
ZonedTimestamp,
133+
)
127134

128135
# Parse manifest
129136
click.echo(f"{Fore.CYAN}Parsing dbt manifest: {manifest_path}{Style.RESET_ALL}")
@@ -211,6 +218,20 @@ def import_command(
211218
)
212219
continue
213220

221+
# The parser reports STRING for columns with no declared data_type.
222+
timestamp_column = next(c for c in model.columns if c.name == timestamp_field)
223+
if map_dbt_type_to_feast_type(timestamp_column.data_type) not in (
224+
UnixTimestamp,
225+
ZonedTimestamp,
226+
):
227+
click.echo(
228+
f"{Fore.YELLOW}Warning: Model '{model.name}' timestamp field "
229+
f"'{timestamp_field}' has type '{timestamp_column.data_type}', "
230+
f"which does not map to a timestamp type. Importing anyway. "
231+
f"Declare it as a timestamp type in schema.yml if this is wrong."
232+
f"{Style.RESET_ALL}"
233+
)
234+
214235
# Validate ALL entity columns exist
215236
missing_entities = [e for e in entity_cols if e not in column_names]
216237
if missing_entities:

0 commit comments

Comments
 (0)