Skip to main content
Version: 0.9

Test Features

Testing is a crucial part of the feature development lifecycle. Tecton provides interactive testing tools that allow you to:

  • Unit test your feature definitions to ensure correct logic and transformations.
  • Test batch, streaming, and on-demand features by running them locally with mock data.
  • Debug feature queries to diagnose issues with performance, data quality or accuracy.
  • Compare the results of FeatureView.get_features_in_range(), FeatureView.get_partial_aggregates() and FeatureView.run_transformation() to understand their relationship.

These tools enable you to thoroughly test your features before enabling materialization or using them in production.

Unit Testing Feature Definitions​

Tecton supports unit testing feature definitions to ensure the correctness of your feature transformations. Unit tests are defined in files named **/tests/*.py and are executed automatically when you run tecton apply, tecton plan, or tecton test.

For details on writing unit tests for your feature views, see Unit Testing.

Testing Batch Features​

You can test batch features locally using the BatchFeatureView.run() method. This allows you to:

  • Execute the feature transformation pipeline over a time range and inspect the results.
  • Pass in mock data sources to control the input data.
  • Test features with tile aggregations at the "disabled", "partial" or "full" aggregation level.
  • Compare the results of get_features_in_range(), get_partial_aggregates() and run_transformation() to understand their relationship.

For more details and examples, see Testing Batch Features.

Testing Streaming Features​

You can test streaming features locally using the StreamFeatureView.run_stream() method. This will start a Spark Structured Streaming job and write results to a temp table which you can query to view real-time feature data. You can also call get_features_for_events() or get_features_in_range() on a StreamFeatureView to get historical feature data from the offline store.

For more details and examples, see Testing Stream Features.

Testing On-Demand Features​

You can test on-demand features locally using:

  • OnDemandFeatureView.run_transformation() to execute the feature with mock inputs.
  • OnDemandFeatureView.get_features_for_events() to execute the feature over historical data.

For on-demand features with batch or streaming feature dependencies, you'll need to provide mocks for those dependencies when using run_transformation().

For more details and examples, see Testing On-Demand Features.

Debugging Queries​

If there are issues with feature data quality, accuracy or performance, you can debug the queries generated by calls to get_features_for_events() or get_features_in_range() by inspecting the query plan. The query plan provides details on each step of the query, allowing you to diagnose the root cause of the issue.

For details on debugging feature queries, see Debugging Queries.

Was this page helpful?