Features¶
Package: databricks.bundles.features
Classes¶
- class AggregationFunction¶
An aggregation function applied over a time window.
- approx_count_distinct: ApproxCountDistinctFunction | None = None¶
Computes the approximate count of distinct values.
- approx_percentile: ApproxPercentileFunction | None = None¶
Computes the approximate percentile of values.
- avg: AvgFunction | None = None¶
Computes the average of values.
- count_function: CountFunction | None = None¶
Computes the count of values.
- first: FirstFunction | None = None¶
Returns the first value.
- last: LastFunction | None = None¶
Returns the last value.
- max: MaxFunction | None = None¶
Computes the maximum value.
- min: MinFunction | None = None¶
Computes the minimum value.
- stddev_pop: StddevPopFunction | None = None¶
Computes the population standard deviation.
- stddev_samp: StddevSampFunction | None = None¶
Computes the sample standard deviation.
- sum: SumFunction | None = None¶
Computes the sum of values.
- time_window: TimeWindow | None = None¶
The time window over which the aggregation is computed.
- var_pop: VarPopFunction | None = None¶
Computes the population variance.
- var_samp: VarSampFunction | None = None¶
Computes the sample variance.
- class ApproxCountDistinctFunction¶
Computes the approximate count of distinct values.
- class ApproxPercentileFunction¶
Computes the approximate percentile of values.
- class AvgFunction¶
Computes the average of values.
- input: str¶
The input column from which the average is computed. For Kafka sources, use dot-prefixed path notation (e.g., “value.amount”). For nested fields, the leaf node name is used. Colon-prefixed notation (e.g., “value:amount”) is supported for backwards compatibility but is deprecated; migrate to dot notation.
- class ColumnSelection¶
A ColumnSelection function, equivalent to the LAST() record of an entity over a lifetime window
- class CountFunction¶
Computes the count of values.
- input: str¶
The input column from which the count is computed. For Kafka sources, use dot-prefixed path notation (e.g., “value.amount”). For nested fields, the leaf node name is used. Colon-prefixed notation (e.g., “value:amount”) is supported for backwards compatibility but is deprecated; migrate to dot notation.
- class DataSource¶
Specifies the data source backing a feature. Exactly one source type must be set.
- delta_table_source: DeltaTableSource | None = None¶
A Delta table data source.
- kafka_source: KafkaSource | None = None¶
A Kafka stream data source.
- request_source: RequestSource | None = None¶
A request-time data source.
- stream_source: StreamSource | None = None¶
A Stream data source.
- class DeltaTableSource¶
-
- dataframe_schema: str | None = None¶
Schema of the resulting dataframe after transformations, in Spark StructType JSON format (from df.schema.json()). Required if transformation_sql is specified. Example: {“type”:”struct”,”fields”:[{“name”:”col_a”,”type”:”integer”,”nullable”:true,”metadata”:{}},{“name”:”col_c”,”type”:”integer”,”nullable”:true,”metadata”:{}}]}
- filter_condition: str | None = None¶
Single WHERE clause to filter delta table before applying transformations. Will be row-wise evaluated, so should only include conditionals and projections.
- transformation_sql: str | None = None¶
A single SQL SELECT expression applied after filter_condition. Should contains all the columns needed (eg. “SELECT , col_a + col_b AS col_c FROM x.y.z WHERE col_a > 0” would have `transformation_sql` “, col_a + col_b AS col_c”) If transformation_sql is not provided, all columns of the delta table are present in the DataSource dataframe.
- class DependsOn¶
- class EntityColumn¶
- name: str¶
The name of the entity column. For Kafka sources, use dot-prefixed path notation to reference fields within the key or value schema (e.g., “value.user_id”, “key.partition_key”). For nested fields, the leaf node name (e.g., “user_id” from “value.trip_details.user_id”) is what will be present in materialized tables and expected to match at query time. Colon-prefixed notation (e.g., “value:user_id”) is supported for backwards compatibility but is deprecated; migrate to dot notation.
- class Feature¶
-
- source: DataSource¶
The data source of the feature.
- entities: list[EntityColumn]¶
The entity columns for the feature, used as aggregation keys and for query-time lookup. Optional since entities are not set for RequestSource features or on-demand calculated features.
- timeseries_column: TimeseriesColumn | None = None¶
Column recording time, used for point-in-time joins, backfills, and aggregations. Optional since a timeseries column is not set for RequestSource features or on-demand calculated features.
- class FieldDefinition¶
A single field definition within a FlatSchema, specifying the field name and its scalar data type. Does not support nested or complex types (arrays, maps, structs).
- data_type: ScalarDataType¶
The scalar data type of the field.
- class FirstFunction¶
Returns the first value.
- class FlatSchema¶
A flat (non-nested) schema for request-time fields, defined as an ordered list of field definitions. This schema only supports scalar types.
- fields: list[FieldDefinition]¶
The list of fields in this schema.
- class Function¶
- aggregation_function: AggregationFunction | None = None¶
An aggregation function applied over a time window.
- column_selection: ColumnSelection | None = None¶
Selects the latest value of a single column in a data source
- class KafkaSource¶
- name: str¶
Name of the Kafka source, used to identify it. This is used to look up the corresponding KafkaConfig object. Can be distinct from topic name.
- class LastFunction¶
Returns the last value.
- class Lifecycle¶
- depends_on: list[DependsOn]¶
Resources that must be deployed before this resource and deleted after it. Unlike variable references, this only affects ordering.
- class MaxFunction¶
Computes the maximum value.
- class MinFunction¶
Computes the minimum value.
- class RequestSource¶
A request-time data source whose value is provided at inference time: offline batch scoring or online serving endpoint
- flat_schema: FlatSchema | None = None¶
A flat schema with scalar-typed fields only.
- class RollingWindow¶
A rolling time window with an optional non-negative delay.
- delay: str | None = None¶
Non-negative analytic lag that evaluates the window this far in the past. Use this for timing variations unrelated to source lateness, such as a 30-day count as of one week ago. If unset, the analytic lag is zero. It composes with source.lateness when both are set.
- class ScalarDataType¶
Scalar data types for request-time field definitions. Only flat (non-nested) types are supported.
- INTEGER = 'INTEGER'¶
- FLOAT = 'FLOAT'¶
- BOOLEAN = 'BOOLEAN'¶
- STRING = 'STRING'¶
- DOUBLE = 'DOUBLE'¶
- LONG = 'LONG'¶
- TIMESTAMP = 'TIMESTAMP'¶
- DATE = 'DATE'¶
- SHORT = 'SHORT'¶
- BINARY = 'BINARY'¶
- DECIMAL = 'DECIMAL'¶
- class SlidingWindow¶
- slide_duration: str¶
The slide duration (interval by which windows advance, must be positive and less than duration).
- class StddevPopFunction¶
Computes the population standard deviation.
- input: str¶
The input column from which the population standard deviation is computed. For Kafka sources, use dot-prefixed path notation (e.g., “value.amount”). For nested fields, the leaf node name is used. Colon-prefixed notation (e.g., “value:amount”) is supported for backwards compatibility but is deprecated; migrate to dot notation.
- class StddevSampFunction¶
Computes the sample standard deviation.
- class StreamSource¶
A Stream entity used as a data source for a feature.
- class SumFunction¶
Computes the sum of values.
- input: str¶
The input column from which the sum is computed. For Kafka sources, use dot-prefixed path notation (e.g., “value.amount”). For nested fields, the leaf node name is used. Colon-prefixed notation (e.g., “value:amount”) is supported for backwards compatibility but is deprecated; migrate to dot notation.
- class TimeWindow¶
- rolling: RollingWindow | None = None¶
A rolling time window with an optional non-negative delay.
- sliding: SlidingWindow | None = None¶
- tumbling: TumblingWindow | None = None¶
- class TimeseriesColumn¶
- name: str¶
The name of the timeseries column. For Kafka sources, use dot-prefixed path notation to reference fields within the key or value schema (e.g., “value.event_timestamp”). For nested fields, the leaf node name (e.g., “event_timestamp” from “value.event_details.event_timestamp”) is what will be present in materialized tables and expected to match at query time. Colon-prefixed notation (e.g., “value:event_timestamp”) is supported for backwards compatibility but is deprecated; migrate to dot notation.
- class TumblingWindow¶
- class VarPopFunction¶
Computes the population variance.