MCPcopy Index your code
hub / github.com/feast-dev/feast / create_data_source

Method create_data_source

sdk/python/feast/dbt/mapper.py:209–279  ·  view source on GitHub ↗

Create a Feast DataSource from a dbt model. Args: model: The DbtModel to create a DataSource from timestamp_field: Override the default timestamp field created_timestamp_column: Column for created timestamp (dedup) Returns: A

(
        self,
        model: DbtModel,
        timestamp_field: Optional[str] = None,
        created_timestamp_column: Optional[str] = None,
    )

Source from the content-addressed store, hash-verified

207 return ValueType.UNKNOWN
208
209 def create_data_source(
210 self,
211 model: DbtModel,
212 timestamp_field: Optional[str] = None,
213 created_timestamp_column: Optional[str] = None,
214 ) -> Any:
215 """
216 Create a Feast DataSource from a dbt model.
217
218 Args:
219 model: The DbtModel to create a DataSource from
220 timestamp_field: Override the default timestamp field
221 created_timestamp_column: Column for created timestamp (dedup)
222
223 Returns:
224 A Feast DataSource (BigQuerySource, SnowflakeSource, or FileSource)
225
226 Raises:
227 ValueError: If data_source_type is not supported
228 """
229 ts_field = timestamp_field or self.timestamp_field
230
231 # Build tags from dbt metadata
232 tags = {"dbt.model": model.name}
233 for tag in model.tags:
234 tags[f"dbt.tag.{tag}"] = "true"
235
236 if self.data_source_type == "bigquery":
237 from feast.infra.offline_stores.bigquery_source import BigQuerySource
238
239 return BigQuerySource(
240 name=f"{model.name}_source",
241 table=model.full_table_name,
242 timestamp_field=ts_field,
243 created_timestamp_column=created_timestamp_column or "",
244 description=model.description,
245 tags=tags,
246 )
247
248 elif self.data_source_type == "snowflake":
249 from feast.infra.offline_stores.snowflake_source import SnowflakeSource
250
251 return SnowflakeSource(
252 name=f"{model.name}_source",
253 database=model.database,
254 schema=model.schema,
255 table=model.alias,
256 timestamp_field=ts_field,
257 created_timestamp_column=created_timestamp_column or "",
258 description=model.description,
259 tags=tags,
260 )
261
262 elif self.data_source_type == "file":
263 from feast.infra.offline_stores.file_source import FileSource
264
265 # For file sources, use the model name as a placeholder path
266 return FileSource(

Calls 3

BigQuerySourceClass · 0.90
SnowflakeSourceClass · 0.90
FileSourceClass · 0.90