@@ -1029,18 +1029,41 @@ def test_select_truncate(self, suffix):
1029
1029
db_obj .drop_table ("test_select_truncate" + suffix , ConflictType .Ignore )
1030
1030
db_obj .create_table ("test_select_truncate" + suffix ,
1031
1031
{"c1" : {"type" : "double" },
1032
- "c2" : {"type" : "float" }}, ConflictType .Error )
1032
+ "c2" : {"type" : "double" },
1033
+ "c3" : {"type" : "float" }
1034
+ }, ConflictType .Error )
1033
1035
table_obj = db_obj .get_table ("test_select_truncate" + suffix )
1034
1036
table_obj .insert (
1035
- [{"c1" : "2.123" , "c2" : "2.123" }, {"c1" : "-2.123" , "c2" : "-2.123" }, {"c1" : "2" , "c2" : "2" }, {"c1" : "2.1" , "c2" :" 2.1" }])
1037
+ [{"c1" : "2.123" , "c2" : "2.123" , "c3" : "2.123" }, {"c1" : "-2.123" , "c2" : "-2.123" , "c3" : "-2.123" }, {"c1" : "2" , "c2" : "2" , "c3" : "2" }, {"c1" : "2.1" , "c2" :" 2.1" , "c3" : " 2.1" }])
1036
1038
1037
- res , extra_res = table_obj .output (["trunc(c1, 2 )" , "trunc(c2, 2)" ]).to_df ()
1039
+ res , extra_res = table_obj .output (["trunc(c1, 14 )" , "trunc(c2, 2)" , "trunc(c3 , 2)" ]).to_df ()
1038
1040
print (res )
1039
- pd .testing .assert_frame_equal (res , pd .DataFrame ({'(c1 trunc 2)' : (" 2.12" , " -2.12" , " 2.00" , " 2.10" ),
1040
- '(c2 trunc 2)' : (" 2.12" , " -2.12" , " 2.00" , " 2.10" )})
1041
- .astype ({'(c1 trunc 2)' : dtype ('str_' ), '(c2 trunc 2)' : dtype ('str_' )}))
1041
+ pd .testing .assert_frame_equal (res , pd .DataFrame ({'(c1 trunc 14)' : (" 2.12300000000000" , " -2.12300000000000" , " 2.00000000000000" , " 2.10000000000000" ),
1042
+ '(c2 trunc 2)' : (" 2.12" , " -2.12" , " 2.00" , " 2.10" ),
1043
+ '(c3 trunc 2)' : (" 2.12" , " -2.12" , " 2.00" , " 2.10" )
1044
+ })
1045
+ .astype ({'(c1 trunc 14)' : dtype ('str_' ), '(c2 trunc 2)' : dtype ('str_' ), '(c3 trunc 2)' : dtype ('str_' )}))
1042
1046
1043
1047
1044
1048
res = db_obj .drop_table ("test_select_truncate" + suffix )
1045
1049
assert res .error_code == ErrorCode .OK
1046
1050
1051
+
1052
+ def test_select_reverse (self , suffix ):
1053
+ db_obj = self .infinity_obj .get_database ("default_db" )
1054
+ db_obj .drop_table ("test_select_reverse" + suffix , ConflictType .Ignore )
1055
+ db_obj .create_table ("test_select_reverse" + suffix ,
1056
+ {"c1" : {"type" : "varchar" , "constraints" : ["primary key" , "not null" ]},
1057
+ "c2" : {"type" : "varchar" , "constraints" : ["not null" ]}}, ConflictType .Error )
1058
+ table_obj = db_obj .get_table ("test_select_reverse" + suffix )
1059
+ table_obj .insert (
1060
+ [{"c1" : 'abc' , "c2" : 'ABC' }, {"c1" : 'a123' , "c2" : 'a123' }, {"c1" : 'c' , "c2" : 'C' }, {"c1" : 'abcdefghijklmn' , "c2" : 'ABCDEFGHIJKLMN' }])
1061
+
1062
+ res , extra_res = table_obj .output (["reverse(c1)" , "reverse(c2)" ]).to_df ()
1063
+ print (res )
1064
+ pd .testing .assert_frame_equal (res , pd .DataFrame ({'reverse(c1)' : ('cba' , '321a' , 'c' , 'nmlkjihgfedcba' ),
1065
+ 'reverse(c2)' : ('CBA' , '321a' , 'C' , 'NMLKJIHGFEDCBA' )})
1066
+ .astype ({'reverse(c1)' : dtype ('str_' ), 'reverse(c2)' : dtype ('str_' )}))
1067
+
1068
+ res = db_obj .drop_table ("test_select_reverse" + suffix )
1069
+ assert res .error_code == ErrorCode .OK
0 commit comments