Skip to content

Commit bee98ed

Browse files
wt0530githubgxll
authored andcommitted
[fix][runtime] Fix build interval return type is any
1 parent 9cd342b commit bee98ed

File tree

1 file changed

+238
-14
lines changed
  • runtime/src/main/java/io/dingodb/expr/runtime/op/interval

1 file changed

+238
-14
lines changed

runtime/src/main/java/io/dingodb/expr/runtime/op/interval/MulOp.java

Lines changed: 238 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,18 @@
1717
package io.dingodb.expr.runtime.op.interval;
1818

1919
import io.dingodb.expr.annotations.Operators;
20+
import io.dingodb.expr.common.type.IntervalDayType;
21+
import io.dingodb.expr.common.type.IntervalHourType;
22+
import io.dingodb.expr.common.type.IntervalMinuteType;
23+
import io.dingodb.expr.common.type.IntervalMonthType;
24+
import io.dingodb.expr.common.type.IntervalSecondType;
2025
import io.dingodb.expr.common.type.IntervalType;
26+
import io.dingodb.expr.common.type.IntervalWeekType;
27+
import io.dingodb.expr.common.type.IntervalYearType;
2128
import io.dingodb.expr.common.utils.CastWithString;
2229
import io.dingodb.expr.runtime.op.BinaryIntervalOp;
30+
import io.dingodb.expr.runtime.op.OpType;
31+
import org.checkerframework.checker.nullness.qual.NonNull;
2332

2433
import java.math.BigDecimal;
2534
import java.sql.Date;
@@ -31,39 +40,249 @@ public class MulOp extends BinaryIntervalOp {
3140

3241
private static final long serialVersionUID = -1357285098612662070L;
3342

34-
static IntervalType mul(String value0, IntervalType value1) {
43+
static IntervalYearType.IntervalYear mul(String value0, IntervalYearType.IntervalYear value1) {
3544
BigDecimal decimal = new BigDecimal(CastWithString.longCastWithStringCompat(value0.split("\\.")[0]));
36-
return buildInterval(decimal, value1);
45+
return (IntervalYearType.IntervalYear) buildInterval(decimal, value1);
3746
}
3847

39-
static IntervalType mul(Integer value0, IntervalType value1) {
48+
static IntervalMonthType.IntervalMonth mul(String value0, IntervalMonthType.IntervalMonth value1) {
49+
BigDecimal decimal = new BigDecimal(CastWithString.longCastWithStringCompat(value0.split("\\.")[0]));
50+
return (IntervalMonthType.IntervalMonth) buildInterval(decimal, value1);
51+
}
52+
53+
static IntervalDayType.IntervalDay mul(String value0, IntervalDayType.IntervalDay value1) {
54+
BigDecimal decimal = new BigDecimal(CastWithString.longCastWithStringCompat(value0.split("\\.")[0]));
55+
return (IntervalDayType.IntervalDay) buildInterval(decimal, value1);
56+
}
57+
58+
static IntervalWeekType.IntervalWeek mul(String value0, IntervalWeekType.IntervalWeek value1) {
59+
BigDecimal decimal = new BigDecimal(CastWithString.longCastWithStringCompat(value0.split("\\.")[0]));
60+
return (IntervalWeekType.IntervalWeek) buildInterval(decimal, value1);
61+
}
62+
63+
static IntervalHourType.IntervalHour mul(String value0, IntervalHourType.IntervalHour value1) {
64+
BigDecimal decimal = new BigDecimal(CastWithString.longCastWithStringCompat(value0.split("\\.")[0]));
65+
return (IntervalHourType.IntervalHour) buildInterval(decimal, value1);
66+
}
67+
68+
static IntervalMinuteType.IntervalMinute mul(String value0, IntervalMinuteType.IntervalMinute value1) {
69+
BigDecimal decimal = new BigDecimal(CastWithString.longCastWithStringCompat(value0.split("\\.")[0]));
70+
return (IntervalMinuteType.IntervalMinute) buildInterval(decimal, value1);
71+
}
72+
73+
static IntervalSecondType.IntervalSecond mul(String value0, IntervalSecondType.IntervalSecond value1) {
74+
BigDecimal decimal = new BigDecimal(CastWithString.longCastWithStringCompat(value0.split("\\.")[0]));
75+
return (IntervalSecondType.IntervalSecond) buildInterval(decimal, value1);
76+
}
77+
78+
static IntervalYearType.IntervalYear mul(Integer value0, IntervalYearType.IntervalYear value1) {
79+
BigDecimal decimal = new BigDecimal(Math.round(CastWithString.doubleCastWithStringCompat(value0.toString())));
80+
return (IntervalYearType.IntervalYear) buildInterval(decimal, value1);
81+
}
82+
83+
static IntervalMonthType.IntervalMonth mul(Integer value0, IntervalMonthType.IntervalMonth value1) {
84+
BigDecimal decimal = new BigDecimal(Math.round(CastWithString.doubleCastWithStringCompat(value0.toString())));
85+
return (IntervalMonthType.IntervalMonth) buildInterval(decimal, value1);
86+
}
87+
88+
static IntervalDayType.IntervalDay mul(Integer value0, IntervalDayType.IntervalDay value1) {
89+
BigDecimal decimal = new BigDecimal(Math.round(CastWithString.doubleCastWithStringCompat(value0.toString())));
90+
return (IntervalDayType.IntervalDay) buildInterval(decimal, value1);
91+
}
92+
93+
static IntervalWeekType.IntervalWeek mul(Integer value0, IntervalWeekType.IntervalWeek value1) {
94+
BigDecimal decimal = new BigDecimal(Math.round(CastWithString.doubleCastWithStringCompat(value0.toString())));
95+
return (IntervalWeekType.IntervalWeek) buildInterval(decimal, value1);
96+
}
97+
98+
static IntervalHourType.IntervalHour mul(Integer value0, IntervalHourType.IntervalHour value1) {
99+
BigDecimal decimal = new BigDecimal(Math.round(CastWithString.doubleCastWithStringCompat(value0.toString())));
100+
return (IntervalHourType.IntervalHour) buildInterval(decimal, value1);
101+
}
102+
103+
static IntervalMinuteType.IntervalMinute mul(Integer value0, IntervalMinuteType.IntervalMinute value1) {
104+
BigDecimal decimal = new BigDecimal(Math.round(CastWithString.doubleCastWithStringCompat(value0.toString())));
105+
return (IntervalMinuteType.IntervalMinute) buildInterval(decimal, value1);
106+
}
107+
108+
static IntervalSecondType.IntervalSecond mul(Integer value0, IntervalSecondType.IntervalSecond value1) {
109+
BigDecimal decimal = new BigDecimal(Math.round(CastWithString.doubleCastWithStringCompat(value0.toString())));
110+
return (IntervalSecondType.IntervalSecond) buildInterval(decimal, value1);
111+
}
112+
113+
static IntervalYearType.IntervalYear mul(Long value0, IntervalYearType.IntervalYear value1) {
114+
BigDecimal decimal = new BigDecimal(Math.round(CastWithString.doubleCastWithStringCompat(value0.toString())));
115+
return (IntervalYearType.IntervalYear) buildInterval(decimal, value1);
116+
}
117+
118+
static IntervalMonthType.IntervalMonth mul(Long value0, IntervalMonthType.IntervalMonth value1) {
119+
BigDecimal decimal = new BigDecimal(Math.round(CastWithString.doubleCastWithStringCompat(value0.toString())));
120+
return (IntervalMonthType.IntervalMonth) buildInterval(decimal, value1);
121+
}
122+
123+
static IntervalDayType.IntervalDay mul(Long value0, IntervalDayType.IntervalDay value1) {
124+
BigDecimal decimal = new BigDecimal(Math.round(CastWithString.doubleCastWithStringCompat(value0.toString())));
125+
return (IntervalDayType.IntervalDay) buildInterval(decimal, value1);
126+
}
127+
128+
static IntervalWeekType.IntervalWeek mul(Long value0, IntervalWeekType.IntervalWeek value1) {
129+
BigDecimal decimal = new BigDecimal(Math.round(CastWithString.doubleCastWithStringCompat(value0.toString())));
130+
return (IntervalWeekType.IntervalWeek) buildInterval(decimal, value1);
131+
}
132+
133+
static IntervalHourType.IntervalHour mul(Long value0, IntervalHourType.IntervalHour value1) {
134+
BigDecimal decimal = new BigDecimal(Math.round(CastWithString.doubleCastWithStringCompat(value0.toString())));
135+
return (IntervalHourType.IntervalHour) buildInterval(decimal, value1);
136+
}
137+
138+
static IntervalMinuteType.IntervalMinute mul(Long value0, IntervalMinuteType.IntervalMinute value1) {
139+
BigDecimal decimal = new BigDecimal(Math.round(CastWithString.doubleCastWithStringCompat(value0.toString())));
140+
return (IntervalMinuteType.IntervalMinute) buildInterval(decimal, value1);
141+
}
142+
143+
static IntervalSecondType.IntervalSecond mul(Long value0, IntervalSecondType.IntervalSecond value1) {
144+
BigDecimal decimal = new BigDecimal(Math.round(CastWithString.doubleCastWithStringCompat(value0.toString())));
145+
return (IntervalSecondType.IntervalSecond) buildInterval(decimal, value1);
146+
}
147+
148+
static IntervalYearType.IntervalYear mul(Double value0, IntervalYearType.IntervalYear value1) {
149+
BigDecimal decimal = new BigDecimal(Math.round(CastWithString.doubleCastWithStringCompat(value0.toString())));
150+
return (IntervalYearType.IntervalYear) buildInterval(decimal, value1);
151+
}
152+
153+
static IntervalMonthType.IntervalMonth mul(Double value0, IntervalMonthType.IntervalMonth value1) {
154+
BigDecimal decimal = new BigDecimal(Math.round(CastWithString.doubleCastWithStringCompat(value0.toString())));
155+
return (IntervalMonthType.IntervalMonth) buildInterval(decimal, value1);
156+
}
157+
158+
static IntervalDayType.IntervalDay mul(Double value0, IntervalDayType.IntervalDay value1) {
159+
BigDecimal decimal = new BigDecimal(Math.round(CastWithString.doubleCastWithStringCompat(value0.toString())));
160+
return (IntervalDayType.IntervalDay) buildInterval(decimal, value1);
161+
}
162+
163+
static IntervalWeekType.IntervalWeek mul(Double value0, IntervalWeekType.IntervalWeek value1) {
164+
BigDecimal decimal = new BigDecimal(Math.round(CastWithString.doubleCastWithStringCompat(value0.toString())));
165+
return (IntervalWeekType.IntervalWeek) buildInterval(decimal, value1);
166+
}
167+
168+
static IntervalHourType.IntervalHour mul(Double value0, IntervalHourType.IntervalHour value1) {
169+
BigDecimal decimal = new BigDecimal(Math.round(CastWithString.doubleCastWithStringCompat(value0.toString())));
170+
return (IntervalHourType.IntervalHour) buildInterval(decimal, value1);
171+
}
172+
173+
static IntervalMinuteType.IntervalMinute mul(Double value0, IntervalMinuteType.IntervalMinute value1) {
174+
BigDecimal decimal = new BigDecimal(Math.round(CastWithString.doubleCastWithStringCompat(value0.toString())));
175+
return (IntervalMinuteType.IntervalMinute) buildInterval(decimal, value1);
176+
}
177+
178+
static IntervalSecondType.IntervalSecond mul(Double value0, IntervalSecondType.IntervalSecond value1) {
179+
BigDecimal decimal = new BigDecimal(Math.round(CastWithString.doubleCastWithStringCompat(value0.toString())));
180+
return (IntervalSecondType.IntervalSecond) buildInterval(decimal, value1);
181+
}
182+
183+
static IntervalYearType.IntervalYear mul(Float value0, IntervalYearType.IntervalYear value1) {
184+
BigDecimal decimal = new BigDecimal(Math.round(CastWithString.doubleCastWithStringCompat(value0.toString())));
185+
return (IntervalYearType.IntervalYear) buildInterval(decimal, value1);
186+
}
187+
188+
static IntervalMonthType.IntervalMonth mul(Float value0, IntervalMonthType.IntervalMonth value1) {
189+
BigDecimal decimal = new BigDecimal(Math.round(CastWithString.doubleCastWithStringCompat(value0.toString())));
190+
return (IntervalMonthType.IntervalMonth) buildInterval(decimal, value1);
191+
}
192+
193+
static IntervalDayType.IntervalDay mul(Float value0, IntervalDayType.IntervalDay value1) {
194+
BigDecimal decimal = new BigDecimal(Math.round(CastWithString.doubleCastWithStringCompat(value0.toString())));
195+
return (IntervalDayType.IntervalDay) buildInterval(decimal, value1);
196+
}
197+
198+
static IntervalWeekType.IntervalWeek mul(Float value0, IntervalWeekType.IntervalWeek value1) {
40199
BigDecimal decimal = new BigDecimal(Math.round(CastWithString.doubleCastWithStringCompat(value0.toString())));
41-
return buildInterval(decimal, value1);
200+
return (IntervalWeekType.IntervalWeek) buildInterval(decimal, value1);
42201
}
43202

44-
static IntervalType mul(Long value0, IntervalType value1) {
203+
static IntervalHourType.IntervalHour mul(Float value0, IntervalHourType.IntervalHour value1) {
45204
BigDecimal decimal = new BigDecimal(Math.round(CastWithString.doubleCastWithStringCompat(value0.toString())));
46-
return buildInterval(decimal, value1);
205+
return (IntervalHourType.IntervalHour) buildInterval(decimal, value1);
47206
}
48207

49-
static IntervalType mul(Double value0, IntervalType value1) {
208+
static IntervalMinuteType.IntervalMinute mul(Float value0, IntervalMinuteType.IntervalMinute value1) {
50209
BigDecimal decimal = new BigDecimal(Math.round(CastWithString.doubleCastWithStringCompat(value0.toString())));
51-
return buildInterval(decimal, value1);
210+
return (IntervalMinuteType.IntervalMinute) buildInterval(decimal, value1);
52211
}
53212

54-
static IntervalType mul(Float value0, IntervalType value1) {
213+
static IntervalSecondType.IntervalSecond mul(Float value0, IntervalSecondType.IntervalSecond value1) {
55214
BigDecimal decimal = new BigDecimal(Math.round(CastWithString.doubleCastWithStringCompat(value0.toString())));
56-
return buildInterval(decimal, value1);
215+
return (IntervalSecondType.IntervalSecond) buildInterval(decimal, value1);
216+
}
217+
218+
static IntervalYearType.IntervalYear mul(Boolean value0, IntervalYearType.IntervalYear value1) {
219+
BigDecimal decimal = new BigDecimal(value0 ? 1 : 0);
220+
return (IntervalYearType.IntervalYear) buildInterval(decimal, value1);
221+
}
222+
223+
static IntervalMonthType.IntervalMonth mul(Boolean value0, IntervalMonthType.IntervalMonth value1) {
224+
BigDecimal decimal = new BigDecimal(value0 ? 1 : 0);
225+
return (IntervalMonthType.IntervalMonth) buildInterval(decimal, value1);
57226
}
58227

59-
static IntervalType mul(Boolean value0, IntervalType value1) {
228+
static IntervalDayType.IntervalDay mul(Boolean value0, IntervalDayType.IntervalDay value1) {
60229
BigDecimal decimal = new BigDecimal(value0 ? 1 : 0);
61-
return buildInterval(decimal, value1);
230+
return (IntervalDayType.IntervalDay) buildInterval(decimal, value1);
62231
}
63232

64-
static IntervalType mul(BigDecimal value0, IntervalType value1) {
233+
static IntervalWeekType.IntervalWeek mul(Boolean value0, IntervalWeekType.IntervalWeek value1) {
234+
BigDecimal decimal = new BigDecimal(value0 ? 1 : 0);
235+
return (IntervalWeekType.IntervalWeek) buildInterval(decimal, value1);
236+
}
237+
238+
static IntervalHourType.IntervalHour mul(Boolean value0, IntervalHourType.IntervalHour value1) {
239+
BigDecimal decimal = new BigDecimal(value0 ? 1 : 0);
240+
return (IntervalHourType.IntervalHour) buildInterval(decimal, value1);
241+
}
242+
243+
static IntervalMinuteType.IntervalMinute mul(Boolean value0, IntervalMinuteType.IntervalMinute value1) {
244+
BigDecimal decimal = new BigDecimal(value0 ? 1 : 0);
245+
return (IntervalMinuteType.IntervalMinute) buildInterval(decimal, value1);
246+
}
247+
248+
static IntervalSecondType.IntervalSecond mul(Boolean value0, IntervalSecondType.IntervalSecond value1) {
249+
BigDecimal decimal = new BigDecimal(value0 ? 1 : 0);
250+
return (IntervalSecondType.IntervalSecond) buildInterval(decimal, value1);
251+
}
252+
253+
static IntervalYearType.IntervalYear mul(BigDecimal value0, IntervalYearType.IntervalYear value1) {
254+
BigDecimal decimal = new BigDecimal(Math.round(CastWithString.doubleCastWithStringCompat(value0.toString())));
255+
return (IntervalYearType.IntervalYear) buildInterval(decimal, value1);
256+
}
257+
258+
static IntervalMonthType.IntervalMonth mul(BigDecimal value0, IntervalMonthType.IntervalMonth value1) {
259+
BigDecimal decimal = new BigDecimal(Math.round(CastWithString.doubleCastWithStringCompat(value0.toString())));
260+
return (IntervalMonthType.IntervalMonth) buildInterval(decimal, value1);
261+
}
262+
263+
static IntervalDayType.IntervalDay mul(BigDecimal value0, IntervalDayType.IntervalDay value1) {
264+
BigDecimal decimal = new BigDecimal(Math.round(CastWithString.doubleCastWithStringCompat(value0.toString())));
265+
return (IntervalDayType.IntervalDay) buildInterval(decimal, value1);
266+
}
267+
268+
static IntervalWeekType.IntervalWeek mul(BigDecimal value0, IntervalWeekType.IntervalWeek value1) {
269+
BigDecimal decimal = new BigDecimal(Math.round(CastWithString.doubleCastWithStringCompat(value0.toString())));
270+
return (IntervalWeekType.IntervalWeek) buildInterval(decimal, value1);
271+
}
272+
273+
static IntervalHourType.IntervalHour mul(BigDecimal value0, IntervalHourType.IntervalHour value1) {
65274
BigDecimal decimal = new BigDecimal(Math.round(CastWithString.doubleCastWithStringCompat(value0.toString())));
66-
return buildInterval(decimal, value1);
275+
return (IntervalHourType.IntervalHour) buildInterval(decimal, value1);
276+
}
277+
278+
static IntervalMinuteType.IntervalMinute mul(BigDecimal value0, IntervalMinuteType.IntervalMinute value1) {
279+
BigDecimal decimal = new BigDecimal(Math.round(CastWithString.doubleCastWithStringCompat(value0.toString())));
280+
return (IntervalMinuteType.IntervalMinute) buildInterval(decimal, value1);
281+
}
282+
283+
static IntervalSecondType.IntervalSecond mul(BigDecimal value0, IntervalSecondType.IntervalSecond value1) {
284+
BigDecimal decimal = new BigDecimal(Math.round(CastWithString.doubleCastWithStringCompat(value0.toString())));
285+
return (IntervalSecondType.IntervalSecond) buildInterval(decimal, value1);
67286
}
68287

69288
static IntervalType mul(Date value0, IntervalType value1) {
@@ -81,4 +300,9 @@ static IntervalType mul(Timestamp value0, IntervalType value1) {
81300
static IntervalType mul(Void value0, IntervalType value1) {
82301
return null;
83302
}
303+
304+
@Override
305+
public @NonNull OpType getOpType() {
306+
return OpType.MUL;
307+
}
84308
}

0 commit comments

Comments
 (0)