@@ -73,19 +73,24 @@ Background reading to understand the concepts of Feature Store and OCI Data Scie
73
73
74
74
75
75
# step2: Create feature store
76
- def transactions_df(dataframe):
76
+ def transactions_df(dataframe, **kwargs):
77
+ columns = kwargs.get('columns', '*') # Default to select all columns if 'columns' not provided
78
+ where_clause = kwargs.get('where_clause', '') # Default to empty where clause if 'where_clause' not provided
79
+
77
80
sql_query = f"""
78
81
SELECT
79
- col1,
80
- col2
82
+ {columns}
81
83
FROM
82
- {dataframe}
84
+ {table_name}
85
+ {where_clause}
83
86
"""
84
87
return sql_query
85
88
89
+ transformation = feature_store.create_transformation(
90
+ transformation_mode=TransformationMode.SQL,
91
+ source_code_func=transactions_df
92
+ )
86
93
87
- transformation = feature_store.create_transformation(transformation_mode=TransformationMode.SQL,
88
- source_code_func=transactions_df)
89
94
90
95
# step3: Create expectation
91
96
expectation_suite = ExpectationSuite(expectation_suite_name="feature_definition")
@@ -102,14 +107,17 @@ Background reading to understand the concepts of Feature Store and OCI Data Scie
102
107
stats_config = StatisticsConfig().with_is_enabled(False)
103
108
104
109
# step5: Create feature group
110
+ transformation_args = {"columns": "col1, col2", "where_clause": "col3 > 100"}
105
111
feature_group = entity.create_feature_group(
106
- ["name"],
112
+ primary_keys=["name"],
113
+ partition_keys=["name"],
107
114
input_feature_details,
108
- expectation_suite,
109
- ExpectationType.LENIENT,
110
- stats_config,
115
+ expectation_suite=expectation_suite ,
116
+ expectation_type= ExpectationType.LENIENT,
117
+ statistics_config= stats_config,
111
118
name="<feature_group_name>",
112
- transformation_id=transformation.id
119
+ transformation_id=transformation.id,
120
+ transformation_kwargs=transformation_args
113
121
)
114
122
115
123
0 commit comments