File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -1107,6 +1107,39 @@ def test_today_alias_matches_current_date(df):
11071107 assert result .column (0 ) == result .column (1 )
11081108
11091109
1110+ def test_current_timestamp_alias_matches_now (df ):
1111+ result = df .select (
1112+ f .now ().alias ("now" ),
1113+ f .current_timestamp ().alias ("current_timestamp" ),
1114+ ).collect ()[0 ]
1115+
1116+ assert result .column (0 ) == result .column (1 )
1117+
1118+
1119+ def test_date_format_alias_matches_to_char (df ):
1120+ result = df .select (
1121+ f .to_char (
1122+ f .to_timestamp (literal ("2021-01-01T00:00:00" )), literal ("%Y/%m/%d" )
1123+ ).alias ("to_char" ),
1124+ f .date_format (
1125+ f .to_timestamp (literal ("2021-01-01T00:00:00" )), literal ("%Y/%m/%d" )
1126+ ).alias ("date_format" ),
1127+ ).collect ()[0 ]
1128+
1129+ assert result .column (0 ) == result .column (1 )
1130+ assert result .column (0 )[0 ].as_py () == "2021/01/01"
1131+
1132+
1133+ def test_make_time (df ):
1134+ ctx = SessionContext ()
1135+ df_time = ctx .from_pydict ({"h" : [12 ], "m" : [30 ], "s" : [0 ]})
1136+ result = df_time .select (
1137+ f .make_time (column ("h" ), column ("m" ), column ("s" )).alias ("t" )
1138+ ).collect ()[0 ]
1139+
1140+ assert result .column (0 )[0 ].as_py () == time (12 , 30 )
1141+
1142+
11101143def test_arrow_cast (df ):
11111144 df = df .select (
11121145 # we use `string_literal` to return utf8 instead of `literal` which returns
You can’t perform that action at this time.
0 commit comments