@@ -246,7 +246,7 @@ def test2(col1):
246
246
247
247
assert tf .hopsworks_udf .to_dict () == udf_json
248
248
249
- def test_generate_output_column_names_one_argument_one_output_type (self ):
249
+ def test_generate_output_column_names_one_argument_one_output_type_mdt (self ):
250
250
@udf (int )
251
251
def test_func (col1 ):
252
252
return col1 + 1
@@ -258,14 +258,19 @@ def test_func(col1):
258
258
)
259
259
assert mdt ._get_output_column_names () == ["test_func_col1_" ]
260
260
261
+ def test_generate_output_column_names_one_argument_one_output_type_odt (self ):
262
+ @udf (int )
263
+ def test_func (col1 ):
264
+ return col1 + 1
265
+
261
266
odt = TransformationFunction (
262
267
featurestore_id = 10 ,
263
268
hopsworks_udf = test_func ,
264
269
transformation_type = TransformationType .ON_DEMAND ,
265
270
)
266
271
assert odt ._get_output_column_names () == ["test_func" ]
267
272
268
- def test_generate_output_column_names_one_argument_one_output_type_prefix (self ):
273
+ def test_generate_output_column_names_one_argument_one_output_type_prefix_mdt (self ):
269
274
@udf (int )
270
275
def test_func (col1 ):
271
276
return col1 + 1
@@ -278,7 +283,13 @@ def test_func(col1):
278
283
transformation_type = TransformationType .MODEL_DEPENDENT ,
279
284
)
280
285
assert mdt ._get_output_column_names () == ["test_func_prefix_col1_" ]
281
- assert mdt .output_column_names == ["prefix_test_func_prefix_col1_" ]
286
+
287
+ def test_generate_output_column_names_one_argument_one_output_type_prefix_odt (self ):
288
+ @udf (int )
289
+ def test_func (col1 ):
290
+ return col1 + 1
291
+
292
+ test_func ._feature_name_prefix = "prefix_"
282
293
283
294
odt = TransformationFunction (
284
295
featurestore_id = 10 ,
@@ -288,7 +299,7 @@ def test_func(col1):
288
299
assert odt ._get_output_column_names () == ["test_func" ]
289
300
assert odt .output_column_names == ["prefix_test_func" ]
290
301
291
- def test_generate_output_column_names_multiple_argument_one_output_type (self ):
302
+ def test_generate_output_column_names_multiple_argument_one_output_type_mdt (self ):
292
303
@udf (int )
293
304
def test_func (col1 , col2 , col3 ):
294
305
return col1 + 1
@@ -299,14 +310,20 @@ def test_func(col1, col2, col3):
299
310
transformation_type = TransformationType .MODEL_DEPENDENT ,
300
311
)
301
312
assert mdt ._get_output_column_names () == ["test_func_col1_col2_col3_" ]
313
+
314
+ def test_generate_output_column_names_multiple_argument_one_output_type_odt (self ):
315
+ @udf (int )
316
+ def test_func (col1 , col2 , col3 ):
317
+ return col1 + 1
318
+
302
319
odt = TransformationFunction (
303
320
featurestore_id = 10 ,
304
321
hopsworks_udf = test_func ,
305
322
transformation_type = TransformationType .ON_DEMAND ,
306
323
)
307
324
assert odt ._get_output_column_names () == ["test_func" ]
308
325
309
- def test_generate_output_column_names_multiple_argument_one_output_type_prefix (
326
+ def test_generate_output_column_names_multiple_argument_one_output_type_prefix_mdt (
310
327
self ,
311
328
):
312
329
@udf (int )
@@ -326,6 +343,16 @@ def test_func(col1, col2, col3):
326
343
assert mdt .output_column_names == [
327
344
"prefix_test_func_prefix_col1_prefix_col2_prefix_col3_"
328
345
]
346
+
347
+ def test_generate_output_column_names_multiple_argument_one_output_type_prefix_odt (
348
+ self ,
349
+ ):
350
+ @udf (int )
351
+ def test_func (col1 , col2 , col3 ):
352
+ return col1 + 1
353
+
354
+ test_func ._feature_name_prefix = "prefix_"
355
+
329
356
odt = TransformationFunction (
330
357
featurestore_id = 10 ,
331
358
hopsworks_udf = test_func ,
@@ -334,7 +361,9 @@ def test_func(col1, col2, col3):
334
361
assert odt ._get_output_column_names () == ["test_func" ]
335
362
assert odt .output_column_names == ["prefix_test_func" ]
336
363
337
- def test_generate_output_column_names_single_argument_multiple_output_type (self ):
364
+ def test_generate_output_column_names_single_argument_multiple_output_type_mdt (
365
+ self ,
366
+ ):
338
367
@udf ([int , float , int ])
339
368
def test_func (col1 ):
340
369
return pd .DataFrame (
@@ -352,7 +381,7 @@ def test_func(col1):
352
381
"test_func_col1_2" ,
353
382
]
354
383
355
- def test_generate_output_column_names_single_argument_multiple_output_type_prefix (
384
+ def test_generate_output_column_names_single_argument_multiple_output_type_prefix_mdt (
356
385
self ,
357
386
):
358
387
@udf ([int , float , int ])
@@ -379,7 +408,9 @@ def test_func(col1):
379
408
"prefix_test_func_prefix_col1_2" ,
380
409
]
381
410
382
- def test_generate_output_column_names_multiple_argument_multiple_output_type (self ):
411
+ def test_generate_output_column_names_multiple_argument_multiple_output_type_mdt (
412
+ self ,
413
+ ):
383
414
@udf ([int , float , int ])
384
415
def test_func (col1 , col2 , col3 ):
385
416
return pd .DataFrame (
@@ -397,7 +428,7 @@ def test_func(col1, col2, col3):
397
428
"test_func_col1_col2_col3_2" ,
398
429
]
399
430
400
- def test_generate_output_column_names_multiple_argument_multiple_output_type_prefix (
431
+ def test_generate_output_column_names_multiple_argument_multiple_output_type_prefix_mdt (
401
432
self ,
402
433
):
403
434
@udf ([int , float , int ])
@@ -462,7 +493,7 @@ def test_func(col1, statistics=stats):
462
493
== "On-Demand Transformation functions cannot use statistics, please remove statistics parameters from the functions"
463
494
)
464
495
465
- def test_alias_one_output (self ):
496
+ def test_alias_one_output_mdt (self ):
466
497
@udf (int )
467
498
def add_one (feature ):
468
499
return feature + 1
@@ -477,6 +508,11 @@ def add_one(feature):
477
508
478
509
assert mdt .output_column_names == ["feature_plus_one_mdt" ]
479
510
511
+ def test_alias_one_output_odt (self ):
512
+ @udf (int )
513
+ def add_one (feature ):
514
+ return feature + 1
515
+
480
516
odt = TransformationFunction (
481
517
featurestore_id = 10 ,
482
518
hopsworks_udf = add_one ,
@@ -487,7 +523,7 @@ def add_one(feature):
487
523
488
524
assert odt .output_column_names == ["feature_plus_one_odt" ]
489
525
490
- def test_alias_one_output_list (self ):
526
+ def test_alias_one_output_list_mdt (self ):
491
527
@udf (int )
492
528
def add_one (feature ):
493
529
return feature + 1
@@ -502,6 +538,11 @@ def add_one(feature):
502
538
503
539
assert mdt .output_column_names == ["feature_plus_one_mdt" ]
504
540
541
+ def test_alias_one_output_list_odt (self ):
542
+ @udf (int )
543
+ def add_one (feature ):
544
+ return feature + 1
545
+
505
546
odt = TransformationFunction (
506
547
featurestore_id = 10 ,
507
548
hopsworks_udf = add_one ,
@@ -512,7 +553,7 @@ def add_one(feature):
512
553
513
554
assert odt .output_column_names == ["feature_plus_one_odt" ]
514
555
515
- def test_alias_multiple_output (self ):
556
+ def test_alias_multiple_output_mdt (self ):
516
557
@udf ([int , int ])
517
558
def add_and_sub (feature ):
518
559
return feature + 1 , feature - 1
@@ -530,7 +571,7 @@ def add_and_sub(feature):
530
571
"feature_minus_one_mdt" ,
531
572
]
532
573
533
- def test_alias_multiple_output_list (self ):
574
+ def test_alias_multiple_output_list_mdt (self ):
534
575
@udf ([int , int ])
535
576
def add_and_sub (feature ):
536
577
return feature + 1 , feature - 1
@@ -548,7 +589,7 @@ def add_and_sub(feature):
548
589
"feature_minus_one_mdt" ,
549
590
]
550
591
551
- def test_alias_invalid_number_column_names (self ):
592
+ def test_alias_invalid_number_column_names_mdt (self ):
552
593
@udf ([int , int ])
553
594
def add_and_sub (feature ):
554
595
return feature + 1 , feature - 1
@@ -567,6 +608,7 @@ def add_and_sub(feature):
567
608
== "The number of output feature names provided does not match the number of features returned by the transformation function 'add_and_sub(feature)'. Pease provide exactly 2 feature name(s) to match the output."
568
609
)
569
610
611
+ def test_alias_invalid_number_column_names_odt (self ):
570
612
@udf (int )
571
613
def add_one (feature ):
572
614
return feature + 1
@@ -585,7 +627,7 @@ def add_one(feature):
585
627
== "The number of output feature names provided does not match the number of features returned by the transformation function 'add_one(feature)'. Pease provide exactly 1 feature name(s) to match the output."
586
628
)
587
629
588
- def test_alias_invalid_type (self ):
630
+ def test_alias_invalid_type_mdt (self ):
589
631
@udf ([int ])
590
632
def add_one (feature ):
591
633
return feature + 1
@@ -604,6 +646,11 @@ def add_one(feature):
604
646
== "Invalid output feature names provided for the transformation function 'add_one(feature)'. Please ensure all arguments are strings."
605
647
)
606
648
649
+ def test_alias_invalid_type_odt (self ):
650
+ @udf ([int ])
651
+ def add_one (feature ):
652
+ return feature + 1
653
+
607
654
odt = TransformationFunction (
608
655
featurestore_id = 10 ,
609
656
hopsworks_udf = add_one ,
@@ -618,7 +665,7 @@ def add_one(feature):
618
665
== "Invalid output feature names provided for the transformation function 'add_one(feature)'. Please ensure all arguments are strings."
619
666
)
620
667
621
- def test_alias_duplicates (self ):
668
+ def test_alias_duplicates_mdt (self ):
622
669
@udf ([int , int ])
623
670
def add_and_sub (feature ):
624
671
return feature + 1 , feature - 1
@@ -637,7 +684,7 @@ def add_and_sub(feature):
637
684
== "Duplicate output feature names provided for the transformation function 'add_and_sub(feature)'. Please ensure all arguments names are unique."
638
685
)
639
686
640
- def test_call_and_alias (self ):
687
+ def test_call_and_alias_mdt (self ):
641
688
@udf (int )
642
689
def add_one (feature ):
643
690
return feature + 1
@@ -653,6 +700,11 @@ def add_one(feature):
653
700
assert mdt .output_column_names == ["feature_plus_one_mdt" ]
654
701
assert mdt .hopsworks_udf .transformation_features == ["feature2_mdt" ]
655
702
703
+ def test_call_and_alias_odt (self ):
704
+ @udf (int )
705
+ def add_one (feature ):
706
+ return feature + 1
707
+
656
708
odt = TransformationFunction (
657
709
featurestore_id = 10 ,
658
710
hopsworks_udf = add_one ,
@@ -664,7 +716,7 @@ def add_one(feature):
664
716
assert odt .output_column_names == ["feature_plus_one_odt" ]
665
717
assert odt .hopsworks_udf .transformation_features == ["feature2_odt" ]
666
718
667
- def test_alias_invalid_length (self ):
719
+ def test_alias_invalid_length_mdt (self ):
668
720
@udf (int )
669
721
def add_one (feature ):
670
722
return feature + 1
@@ -683,6 +735,11 @@ def add_one(feature):
683
735
== "Invalid output feature names specified for the transformation function 'add_one(feature)'. Please provide names shorter than 63 characters."
684
736
)
685
737
738
+ def test_alias_invalid_length_odt (self ):
739
+ @udf (int )
740
+ def add_one (feature ):
741
+ return feature + 1
742
+
686
743
odt = TransformationFunction (
687
744
featurestore_id = 10 ,
688
745
hopsworks_udf = add_one ,
@@ -786,6 +843,13 @@ def really_long_function_name_that_exceed_63_characters_causing_invalid_name_for
786
843
"really_long_function_name_that_exceed_63_characters_causing_inv"
787
844
]
788
845
846
+ def test_generate_output_col_name_invalid_mdt (self , caplog ):
847
+ @udf (int )
848
+ def really_long_function_name_that_exceed_63_characters_causing_invalid_name_for_on_demand_features (
849
+ features ,
850
+ ):
851
+ return features
852
+
789
853
mdt = TransformationFunction (
790
854
featurestore_id = 10 ,
791
855
hopsworks_udf = really_long_function_name_that_exceed_63_characters_causing_invalid_name_for_on_demand_features ,
0 commit comments