github.com/matrixorigin/matrixone@v1.2.0/test/distributed/cases/function/func_math_trig.test (about) 1 #0.5 ASIN和ATAN2暂时未实现 2 3 #SELECT, 嵌套 4 SELECT SIN(PI()); 5 SELECT ROUND(SIN(PI())); 6 SELECT COS(PI()); 7 SELECT COT(12); 8 SELECT TAN(PI()); 9 SELECT TAN(PI()+1); 10 #SELECT ASIN(0.2); 11 SELECT ACOS(1); 12 SELECT ACOS(1.0001); 13 SELECT ACOS(0); 14 SELECT ATAN(2); 15 SELECT ATAN(-2); 16 SELECT ATAN(-2,2); 17 #SELECT ATAN2(PI(),0); 18 19 20 #EXTREME VALUES 21 SELECT SIN(13413); 22 SELECT SIN(-3114); 23 SELECT SIN(1); 24 SELECT SIN(-1); 25 SELECT SIN(0); 26 SELECT SIN(0.001); 27 SELECT SIN(-0.001); 28 SELECT SIN("ABC"); 29 30 SELECT COS(13413); 31 SELECT COS(-3114); 32 SELECT COS(1); 33 SELECT COS(-1); 34 SELECT COS(0); 35 SELECT COS(0.001); 36 SELECT COS(-0.001); 37 SELECT COS("ABC"); 38 39 SELECT TAN(13413); 40 SELECT TAN(-3114); 41 SELECT TAN(1); 42 SELECT TAN(-1); 43 SELECT TAN(0); 44 SELECT TAN(0.001); 45 SELECT TAN(-0.001); 46 SELECT TAN("ABC"); 47 48 SELECT COT(13413); 49 SELECT COT(-3114); 50 SELECT COT(1); 51 SELECT COT(-1); 52 SELECT COT(0.001); 53 SELECT COT(-0.001); 54 55 select cot(0); 56 57 #SELECT ASIN(13413); 58 #SELECT ASIN(-3114); 59 #SELECT ASIN(1); 60 #SELECT ASIN(-1); 61 #SELECT ASIN(0); 62 #SELECT ASIN(0.001); 63 #SELECT ASIN(-0.001); 64 #SELECT ASIN("ABC"); 65 66 SELECT ATAN(13413); 67 SELECT ATAN(-3114); 68 SELECT ATAN(1); 69 SELECT ATAN(-1); 70 SELECT ATAN(0); 71 SELECT ATAN(0.001); 72 SELECT ATAN(-0.001); 73 SELECT ATAN("ABC"); 74 75 # SELECT ATAN2(-1,-1); 76 # SELECT ATAN2(1,1); 77 # SELECT ATAN2(31413,413442); 78 # SELECT ATAN2(-141341,4134134); 79 # SELECT ATAN2(0,0); 80 # SELECT ATAN2(0, -1); 81 # SELECT ATAN2(-1, 0); 82 # SELECT ATAN2("ABC", 0); 83 84 #NULL 85 SELECT SIN(NULL); 86 SELECT COS(NULL); 87 SELECT TAN(NULL); 88 SELECT COT(NULL); 89 # SELECT ASIN(NULL); 90 SELECT ACOS(NULL); 91 SELECT ATAN(NULL); 92 # SELECT ATAN2(NULL, 1); 93 # SELECT ATAN2(1, NULL); 94 # SELECT ATAN2(NULL, NULL); 95 96 #DATA TYPE 97 create table t1(a tinyint, b SMALLINT, c bigint, d INT, e BIGINT, f FLOAT, g DOUBLE, h decimal(38,19), i DATE, k datetime, l TIMESTAMP, m char(255), n varchar(255)); 98 insert into t1 values(1, 1, 2, 43, 5, 35.5, 31.133, 14.314, "2012-03-10", "2012-03-12 10:03:12", "2022-03-12 13:03:12", "ab23c", "d5cf"); 99 insert into t1 values(71, 1, 2, 34, 5, 5.5, 341.13, 15.314, "2012-03-22", "2013-03-12 10:03:12", "2032-03-12 13:04:12", "abr23c", "3dcf"); 100 insert into t1 values(1, 1, 21, 4, 54, 53.5, 431.13, 14.394, "2011-03-12", "2015-03-12 10:03:12", "2002-03-12 13:03:12", "afbc", "dct5f"); 101 insert into t1 values(1, 71, 2, 34, 5, 5.5, 31.313, 124.314, "2012-01-12", "2019-03-12 10:03:12", "2013-03-12 13:03:12", "3abd1c", "dcvf"); 102 select sin(a), cos(a), tan(a),cot(a),atan(a) from t1; 103 select sin(b), cos(b), tan(b),cot(b),atan(b) from t1; 104 select sin(c), cos(c), tan(c),cot(c),atan(c) from t1; 105 select sin(d), cos(d), tan(d),cot(d),atan(d) from t1; 106 select sin(e), cos(e), tan(e),cot(e),atan(e) from t1; 107 select sin(f), cos(f), tan(f),cot(f),atan(f) from t1; 108 select sin(g), cos(g), tan(g),cot(g),atan(g) from t1; 109 110 select sin(h), cos(h), tan(h),cot(h),atan(h) from t1; 111 select sin(i), cos(i), tan(i),cot(i),acos(i),atan(i) from t1; 112 select sin(k), cos(k), tan(k),cot(k),acos(k),atan(k) from t1; 113 select sin(l), cos(l), tan(l),cot(l),acos(l),atan(l) from t1; 114 #select asin(a), asin(b), asin(c), asin(d), asin(e), asin(f), asin(g), asin(h), asin(i), asin(j), asin(k), asin(l) from t1; 115 #select atan2(a,a), atan2(b,b),atan2(c,c),atan2(d,d),atan2(e,e),atan2(f,f),atan2(g,g),atan2(h,h),atan2(i,i),atan2(j,j),atan2(k,k),atan2(l,l) from t1; 116 drop table t1; 117 118 119 #0.5暂不支持time类型 120 #create table t1(a time) 121 #insert into t1 values("10:03:12"); 122 #select sin(a), cos(a), tan(a),cot(a),asin(a),acos(a),atan(a),atan2(a,a) from t1; 123 #drop table t1; 124 125 126 #INSERT, DISTINCT 127 Create table t1(a float); 128 insert into t1 select (sin(1)); 129 insert into t1 select (cos(1)); 130 insert into t1 select (tan(1)); 131 insert into t1 select (cot(1)); 132 insert into t1 select (acos(1)); 133 insert into t1 select (atan(1)); 134 insert into t1 select (sin(1)); 135 insert into t1 select (cos(1)); 136 insert into t1 select (tan(1)); 137 insert into t1 select (cot(1)); 138 insert into t1 select (acos(1)); 139 insert into t1 select (atan(1)); 140 #insert into t1 values(asin(1)), (asin(1)); 141 #insert into t1 values (atan2(1,1)), (atan2(1,1)); 142 select distinct sin(a) from t1; 143 select distinct cos(a) from t1; 144 select distinct tan(a) from t1; 145 #select distinct asin(a) from t1; 146 select distinct acos(a) from t1; 147 select distinct atan(a) from t1; 148 #select distinct atan2(a) from t1; 149 drop table t1; 150 151 152 #WHERE 153 drop table if exists t1; 154 create table t1(a INT, b float); 155 insert into t1 values(1, 0),(0, 1),(1,1),(0,0); 156 select * from t1 where sin(a)<>cos(b); 157 select * from t1 where sin(b)<>cos(a); 158 select * from t1 where tan(b)<>cot(a-0.5); 159 select * from t1 where atan(b)<>acos(a); 160 #select * from t1 where asin(b)<>atan2(a,b ); 161 drop table t1; 162 163 164 #ON CONDITION 165 create table t1(a INT, b float); 166 create table t2(a INT, b float); 167 insert into t1 values(1, 0),(0, 1),(1,1),(0,0); 168 insert into t2 values(0, 1),(1, 0),(1,1),(0,0); 169 #SELECT t1.a, t2.a FROM t1 JOIN t2 ON (asin(t1.a)=asin(t2.b)); 170 SELECT t1.a, t2.a FROM t1 JOIN t2 ON (sin(t1.a)=sin(t2.b)); 171 SELECT t1.a, t2.a FROM t1 JOIN t2 ON (cos(t1.a)=cos(t2.b)); 172 SELECT t1.a, t2.a FROM t1 JOIN t2 ON (tan(t1.a)=tan(t2.b)); 173 SELECT t1.a, t2.a FROM t1 JOIN t2 ON (cot(t1.a-0.5)=cot(t2.b-0.5)); 174 SELECT t1.a, t2.a FROM t1 JOIN t2 ON (acos(t1.a)=acos(t2.b)); 175 SELECT t1.a, t2.a FROM t1 JOIN t2 ON (atan(t1.a)=atan(t2.b)); 176 #SELECT t1.a, t2.a FROM t1 JOIN t2 ON (atan2(t1.a, t1.b)=atan2(t2.a, t2.b)); 177 drop table t1; 178 drop table t2; 179 180 #HAVING 181 drop table if exists t1; 182 create table t1(a INT, b float); 183 insert into t1 values(1, 0),(0, 1),(1,1),(0,0); 184 SELECT a FROM t1 group by a having sin(a)>0; 185 SELECT a FROM t1 group by a having cos(a)>0; 186 SELECT a FROM t1 group by a having tan(a)>0; 187 SELECT a FROM t1 group by a having cot(a-0.5)>0; 188 SELECT a FROM t1 group by a having acos(a)>0; 189 SELECT a FROM t1 group by a having atan(a)>0; 190 drop table t1; 191 192 #科学计算 193 SELECT sin(0.745e5); 194 SELECT cos(1.1e5); 195 SELECT tan(1.1e5); 196 SELECT cot(0.7e5); 197 #SELECT asin(1.1e5); 198 SELECT acos(1.1e5); 199 SELECT atan(1.1e5); 200 #SELECT atan2(1.1e5,0.5e4); 201 202 203