20
20
def test_expr_components (library : str , attr : str , expected : list [int ]) -> None :
21
21
df = temporal_dataframe_1 (library )
22
22
col = df .__dataframe_namespace__ ().col
23
- result = df .select (getattr (col ("a" ).dt , attr )())
24
- result_list = result .collect ().get_column_by_name ("a" )
25
- assert result_list .get_value (0 ) == expected [0 ]
26
- assert result_list .get_value (1 ) == expected [1 ]
27
- assert result_list .get_value (2 ) == expected [2 ]
23
+ for col_name in ("a" , "c" , "e" ):
24
+ result = df .select (getattr (col (col_name ).dt , attr )())
25
+ result_list = result .collect ().get_column_by_name (col_name )
26
+ assert result_list .get_value (0 ) == expected [0 ]
27
+ assert result_list .get_value (1 ) == expected [1 ]
28
+ assert result_list .get_value (2 ) == expected [2 ]
28
29
29
30
30
31
@pytest .mark .parametrize (
@@ -41,7 +42,42 @@ def test_expr_components(library: str, attr: str, expected: list[int]) -> None:
41
42
)
42
43
def test_col_components (library : str , attr : str , expected : list [int ]) -> None :
43
44
df = temporal_dataframe_1 (library ).collect ()
44
- result = getattr (df .get_column_by_name ("a" ).dt , attr )()
45
+ for col_name in ("a" , "c" , "e" ):
46
+ result = getattr (df .get_column_by_name (col_name ).dt , attr )()
47
+ assert result .get_value (0 ) == expected [0 ]
48
+ assert result .get_value (1 ) == expected [1 ]
49
+ assert result .get_value (2 ) == expected [2 ]
50
+
51
+
52
+ @pytest .mark .parametrize (
53
+ ("col_name" , "expected" ),
54
+ [
55
+ ("a" , [123000 , 321000 , 987000 ]),
56
+ ("c" , [123543 , 321654 , 987321 ]),
57
+ ("e" , [123543 , 321654 , 987321 ]),
58
+ ],
59
+ )
60
+ def test_expr_microsecond (library : str , col_name : str , expected : list [int ]) -> None :
61
+ df = temporal_dataframe_1 (library )
62
+ col = df .__dataframe_namespace__ ().col
63
+ result = df .select (col (col_name ).dt .microsecond ())
64
+ result_list = result .collect ().get_column_by_name (col_name )
65
+ assert result_list .get_value (0 ) == expected [0 ]
66
+ assert result_list .get_value (1 ) == expected [1 ]
67
+ assert result_list .get_value (2 ) == expected [2 ]
68
+
69
+
70
+ @pytest .mark .parametrize (
71
+ ("col_name" , "expected" ),
72
+ [
73
+ ("a" , [123000 , 321000 , 987000 ]),
74
+ ("c" , [123543 , 321654 , 987321 ]),
75
+ ("e" , [123543 , 321654 , 987321 ]),
76
+ ],
77
+ )
78
+ def test_col_microsecond (library : str , col_name : str , expected : list [int ]) -> None :
79
+ df = temporal_dataframe_1 (library ).collect ()
80
+ result = df .get_column_by_name (col_name ).dt .microsecond ()
45
81
assert result .get_value (0 ) == expected [0 ]
46
82
assert result .get_value (1 ) == expected [1 ]
47
83
assert result .get_value (2 ) == expected [2 ]
0 commit comments