Skip to content

Commit 47b02a4

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 60515ad commit 47b02a4

2 files changed

Lines changed: 20 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
@@ -431,3 +431,7 @@ Ensure your dbt model includes the entity column specified with `--entity-column
431431
### "Missing timestamp column"
432432

433433
By default, Feast looks for `event_timestamp`. Use `--timestamp-field` to specify a different column name.
434+
435+
### "Timestamp field ... does not map to a timestamp type"
436+
437+
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.

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,9 @@ def import_command(
121121
# Generate Python file instead of applying to registry
122122
feast dbt import -m target/manifest.json -e driver_id --tag feast --output features.py
123123
"""
124-
from feast.dbt.mapper import DbtToFeastMapper
124+
from feast.dbt.mapper import DbtToFeastMapper, map_dbt_type_to_feast_type
125125
from feast.dbt.parser import DbtManifestParser
126+
from feast.types import UnixTimestamp, ZonedTimestamp
126127

127128
# Parse manifest
128129
click.echo(f"{Fore.CYAN}Parsing dbt manifest: {manifest_path}{Style.RESET_ALL}")
@@ -209,6 +210,20 @@ def import_command(
209210
)
210211
continue
211212

213+
# The parser reports STRING for columns with no declared data_type.
214+
timestamp_column = next(c for c in model.columns if c.name == timestamp_field)
215+
if map_dbt_type_to_feast_type(timestamp_column.data_type) not in (
216+
UnixTimestamp,
217+
ZonedTimestamp,
218+
):
219+
click.echo(
220+
f"{Fore.YELLOW}Warning: Model '{model.name}' timestamp field "
221+
f"'{timestamp_field}' has type '{timestamp_column.data_type}', "
222+
f"which does not map to a timestamp type. Importing anyway. "
223+
f"Declare it as a timestamp type in schema.yml if this is wrong."
224+
f"{Style.RESET_ALL}"
225+
)
226+
212227
# Validate ALL entity columns exist
213228
missing_entities = [e for e in entity_cols if e not in column_names]
214229
if missing_entities:

0 commit comments

Comments
 (0)