forked from oceanbase/oceanbase
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathob_expr_abs.cpp
More file actions
714 lines (674 loc) · 19.2 KB
/
Copy pathob_expr_abs.cpp
File metadata and controls
714 lines (674 loc) · 19.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
/**
* Copyright (c) 2021 OceanBase
* OceanBase CE is licensed under Mulan PubL v2.
* You can use this software according to the terms and conditions of the Mulan PubL v2.
* You may obtain a copy of Mulan PubL v2 at:
* http://license.coscl.org.cn/MulanPubL-2.0
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*/
#define USING_LOG_PREFIX SQL_ENG
#include "sql/engine/expr/ob_expr_abs.h"
#include "share/object/ob_obj_cast.h"
#include "share/config/ob_server_config.h"
#include "share/datum/ob_datum_util.h"
#include "sql/engine/expr/ob_expr_result_type_util.h"
#include "sql/session/ob_sql_session_info.h"
namespace oceanbase
{
using namespace oceanbase::common;
namespace sql
{
#define DEF_EVAL_ABS_FUNC(type) \
template <> \
int eval_datum_abs<type>(const ObExpr &expr, ObEvalCtx &ctx, \
ObDatum &expr_datum)
static int check_expr_and_eval(const ObExpr &expr, ObEvalCtx &ctx,
ObDatum *¶m_datum, bool &found_null)
{
int ret = OB_SUCCESS;
found_null = false;
if (OB_UNLIKELY(expr.type_ != T_OP_ABS)
|| OB_UNLIKELY(expr.arg_cnt_ != 1) || OB_ISNULL(expr.args_)
|| OB_ISNULL(expr.args_[0])) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid argument", K(ret));
} else if (OB_FAIL(expr.args_[0]->eval(ctx, param_datum))) {
LOG_WARN("failed to eval", K(ret));
} else if (param_datum->is_null()) {
found_null = true;
} else {
// do nothing
}
return ret;
}
template<ObObjType obj_type>
int eval_datum_abs(const ObExpr &expr,
ObEvalCtx &ctx,
ObDatum &expr_datum)
{
UNUSED(expr);
UNUSED(ctx);
UNUSED(expr_datum);
return OB_NOT_SUPPORTED;
}
DEF_EVAL_ABS_FUNC(ObNullType)
{
int ret = OB_SUCCESS;
UNUSED(ctx);
UNUSED(expr);
expr_datum.set_null();
return ret;
}
DEF_EVAL_ABS_FUNC(ObNumberType)
{
int ret = OB_SUCCESS;
ObDatum *param_datum = NULL;
bool found_null = false;
if (OB_FAIL(check_expr_and_eval(expr, ctx, param_datum, found_null))) {
LOG_WARN("failed to check expr and eval", K(ret));
} else if (found_null) {
expr_datum.set_null();
} else {
number::ObNumber param_nmb(param_datum->get_number());
number::ObNumber res_num = param_nmb;
if (param_nmb.is_negative()) {
res_num = param_nmb.negate();
}
expr_datum.set_number(res_num);
}
return ret;
}
DEF_EVAL_ABS_FUNC(ObUNumberType)
{
int ret = OB_SUCCESS;
ObDatum *param_datum = NULL;
bool found_null = false;
if (OB_FAIL(check_expr_and_eval(expr, ctx, param_datum, found_null))) {
LOG_WARN("failed to check expr and eval", K(ret));
} else if (found_null) {
expr_datum.set_null();
} else {
number::ObNumber param_nmb(param_datum->get_number());
number::ObNumber res_num = param_nmb;
if (param_nmb.is_negative()) {
res_num = param_nmb.negate();
}
expr_datum.set_number(res_num);
}
return ret;
}
DEF_EVAL_ABS_FUNC(ObFloatType)
{
int ret = OB_SUCCESS;
ObDatum *param = NULL;
bool found_null = false;
if (OB_FAIL(check_expr_and_eval(expr, ctx, param, found_null))) {
LOG_WARN("check expr and eval", K(ret));
} else if (found_null) {
expr_datum.set_null();
} else {
expr_datum.set_float(param->get_float() >= 0.0
? param->get_float() : -param->get_float());
}
return ret;
}
DEF_EVAL_ABS_FUNC(ObDoubleType)
{
int ret = OB_SUCCESS;
ObDatum *param = NULL;
bool found_null = false;
if (OB_FAIL(check_expr_and_eval(expr, ctx, param, found_null))) {
LOG_WARN("failed to check expr and eval", K(ret));
} else if (found_null) {
expr_datum.set_null();
} else {
expr_datum.set_double(param->get_double() >= 0
? param->get_double() : -param->get_double());
}
return ret;
}
DEF_EVAL_ABS_FUNC(ObUDoubleType)
{
int ret = OB_SUCCESS;
ObDatum *param = NULL;
bool found_null = false;
if (OB_FAIL(check_expr_and_eval(expr, ctx, param, found_null))) {
LOG_WARN("failed to check expr and eval", K(ret));
} else if (found_null) {
expr_datum.set_null();
} else {
expr_datum.set_double(param->get_udouble());
}
return ret;
}
DEF_EVAL_ABS_FUNC(ObIntType)
{
int ret = OB_SUCCESS;
ObDatum *param = NULL;
bool found_null = false;
if (OB_FAIL(check_expr_and_eval(expr, ctx, param, found_null))) {
LOG_WARN("failed to check expr and eval", K(ret));
} else if (found_null) {
expr_datum.set_null();
} else {
int64_t param_int = param->get_int();
// 只有mysql模式会调到这个函数,如果发现是INT64_MIN,需要报out of range
if (INT64_MIN == param_int) {
ret = OB_OPERATE_OVERFLOW;
LOG_WARN("value out of range", K(ret));
} else {
expr_datum.set_int(param_int >= 0 ? param_int : -param_int);
}
}
return ret;
}
DEF_EVAL_ABS_FUNC(ObUInt64Type)
{
int ret = OB_SUCCESS;
ObDatum *param = NULL;
bool found_null = false;
if (OB_FAIL(check_expr_and_eval(expr, ctx, param, found_null))) {
LOG_WARN("failed to check expr and eval", K(ret));
} else if (found_null) {
expr_datum.set_null();
} else {
expr_datum.set_uint(param->get_uint64());
}
return ret;
}
#define MAKE_DECIMAL_INT_OPPOSITE(TYPE) \
case sizeof(TYPE##_t): { \
res_val.from(-(*(decint->TYPE##_v_))); \
break; \
}
DEF_EVAL_ABS_FUNC(ObDecimalIntType)
{
int ret = OB_SUCCESS;
ObDatum *param_datum = NULL;
bool found_null = false;
if (OB_FAIL(check_expr_and_eval(expr, ctx, param_datum, found_null))) {
LOG_WARN("failed to check expr and eval", K(ret));
} else if (found_null) {
expr_datum.set_null();
} else {
const ObDecimalInt *decint = param_datum->get_decimal_int();
const int32_t int_bytes = param_datum->get_int_bytes();
bool is_neg = wide::is_negative(decint, int_bytes);
if (is_neg) {
ObDecimalIntBuilder res_val;
switch (int_bytes) {
MAKE_DECIMAL_INT_OPPOSITE(int32)
MAKE_DECIMAL_INT_OPPOSITE(int64)
MAKE_DECIMAL_INT_OPPOSITE(int128)
MAKE_DECIMAL_INT_OPPOSITE(int256)
MAKE_DECIMAL_INT_OPPOSITE(int512)
default: {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("int_bytes is unexpected", K(ret), K(int_bytes));
break;
}
}
if (OB_SUCC(ret)) {
expr_datum.set_decimal_int(res_val.get_decimal_int(), int_bytes);
}
} else {
expr_datum.set_decimal_int(decint, int_bytes);
}
}
return ret;
}
ObExpr::EvalFunc abs_funcs[ObMaxType];
template<int IDX>
struct AbsFuncIniter
{
static bool init_array()
{
abs_funcs[IDX] = &eval_datum_abs<static_cast<ObObjType>(IDX)>;
return true;
}
};
static bool abs_eval_func_init_ret = ObArrayConstIniter<ObMaxType, AbsFuncIniter>::init();
static_assert(ObMaxType == sizeof(abs_funcs) / sizeof(void *), "unexpected size");
REG_SER_FUNC_ARRAY(OB_SFA_SQL_EXPR_ABS_EVAL, abs_funcs, ARRAYSIZEOF(abs_funcs));
ObExprAbs::ObExprAbs(ObIAllocator &alloc)
: ObExprOperator(alloc, T_OP_ABS, N_ABS, 1, VALID_FOR_GENERATED_COL, NOT_ROW_DIMENSION),
func_(NULL) {}
int ObExprAbs::assign(const ObExprOperator &other)
{
int ret = OB_SUCCESS;
const ObExprAbs *tmp_other = dynamic_cast<const ObExprAbs *>(&other);
if (OB_UNLIKELY(NULL == tmp_other)) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid argument. wrong type for other", K(ret), K(other));
} else if (OB_LIKELY(this != tmp_other)) {
if (OB_FAIL(ObExprOperator::assign(other))) {
LOG_WARN("copy in Base class ObExprOperator failed", K(ret));
} else {
this->func_ = tmp_other->func_;
}
}
return ret;
}
int ObExprAbs::calc_result_type1(ObExprResType &type, ObExprResType &type1,
ObExprTypeCtx &type_ctx) const
{
UNUSED(type_ctx);
int ret = OB_SUCCESS;
const ObSQLSessionInfo *session = type_ctx.get_session();
if (OB_ISNULL(session)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("session is NULL", K(ret));
} else if (NOT_ROW_DIMENSION == row_dimension_) {
// result type
ObObjType itype;
if (OB_SUCC(ObExprResultTypeUtil::get_abs_result_type(itype, type1.get_type()))) {
if (lib::is_oracle_mode() && ob_is_json(type1.get_type())) {
ret = OB_ERR_INVALID_TYPE_FOR_OP;
} else if (ObMaxType == itype) {
ret = OB_ERR_INVALID_TYPE_FOR_OP;
} else {
type.set_type(itype);
}
}
// collation
// 结果不可能为字符类型,无需专门设置collation
if (lib::is_oracle_mode() && (type1.is_varchar_or_char() || type1.is_number_float())) {
type.set_precision(PRECISION_UNKNOWN_YET);
type.set_scale(ORA_NUMBER_SCALE_UNKNOWN_YET);
} else if (lib::is_mysql_mode() && type.is_double() && type1.get_scale() != SCALE_UNKNOWN_YET) {
type.set_scale(type1.get_scale());
type.set_precision(static_cast<ObPrecision>(ObMySQLUtil::float_length(type1.get_scale())));
} else {
type.set_accuracy(type1.get_accuracy());
}
// null flag
ObExprOperator::calc_result_flag1(type, type1);
if (OB_SUCC(ret)) {
// set calc type for param
ObObjType param_calc_type = calc_param_type(type1.get_type(),
lib::is_oracle_mode());
if (OB_UNLIKELY(ObMaxType == param_calc_type)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("invalid param calc type", K(ret), K(type1.get_type()), K(param_calc_type));
} else {
type1.set_calc_type(param_calc_type);
if (type1.get_type() == ObJsonType) {
type1.set_calc_type(ObDoubleType);
type.set_type(ObDoubleType);
}
}
}
} else {
ret = OB_ERR_INVALID_TYPE_FOR_OP;
}
return ret;
}
//tinyint, mediumint, smallint, int32
int ObExprAbs::abs_int(ObObj &res,
const ObObj ¶m,
ObExprCtx &expr_ctx)
{
res.set_int(param.get_int() >= 0 ? param.get_int() : -param.get_int());
UNUSED(expr_ctx);
return OB_SUCCESS;
}
//int64
int ObExprAbs::abs_int64(ObObj &res,
const ObObj ¶m,
ObExprCtx &expr_ctx)
{
int ret = OB_SUCCESS;
if (INT64_MIN == param.get_int()) {
ret = OB_OPERATE_OVERFLOW; //INT64_MIN时,mysql会返回一个out of range的错误
LOG_WARN("value out of range", K(ret), K(INT64_MIN), K(param));
} else {
res.set_int(param.get_int() >= 0LL ? param.get_int() : -param.get_int());
}
UNUSED(expr_ctx);
return ret;
}
//utiniyint, umediumint, usmallint
int ObExprAbs::abs_uint(ObObj &res,
const ObObj ¶m,
ObExprCtx &expr_ctx)
{
res.set_uint64(static_cast<uint64_t>(param.get_uint32()));
UNUSED(expr_ctx);
return OB_SUCCESS;
}
//uint32 uint64
int ObExprAbs::abs_uint32_uint64(ObObj &res,
const ObObj ¶m,
ObExprCtx &expr_ctx)
{
res.set_uint64(param.get_uint64());
UNUSED(expr_ctx);
return OB_SUCCESS;
}
//float
int ObExprAbs::abs_float(ObObj &res,
const ObObj ¶m,
ObExprCtx &expr_ctx)
{
res.set_float(param.get_float() >= 0.0f ? param.get_float() : -param.get_float());
UNUSED(expr_ctx);
return OB_SUCCESS;
}
int ObExprAbs::abs_float_double(ObObj &res,
const ObObj ¶m,
ObExprCtx &expr_ctx)
{
res.set_double(static_cast<double>(param.get_float() >= 0.0f ?
param.get_float() :
-param.get_float()));
UNUSED(expr_ctx);
return OB_SUCCESS;
}
//double
int ObExprAbs::abs_double(ObObj &res,
const ObObj ¶m,
ObExprCtx &expr_ctx)
{
res.set_double(param.get_double() >= 0.0 ? param.get_double() : -param.get_double());
UNUSED(expr_ctx);
return OB_SUCCESS;
}
//ufloat
int ObExprAbs::abs_ufloat_udouble(ObObj &res,
const ObObj ¶m,
ObExprCtx &expr_ctx)
{
res.set_udouble(static_cast<double>(param.get_ufloat()));
UNUSED(expr_ctx);
return OB_SUCCESS;
}
//udouble
int ObExprAbs::abs_udouble(ObObj &res,
const ObObj ¶m,
ObExprCtx &expr_ctx)
{
res.set_udouble(param.get_udouble());
UNUSED(expr_ctx);
return OB_SUCCESS;
}
//number
int ObExprAbs::abs_number(ObObj &res,
const ObObj ¶m,
ObExprCtx &expr_ctx)
{
int ret = OB_SUCCESS;
if (OB_UNLIKELY(!param.is_number() && !param.is_number_float())) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid arguemnt", K(param), K(ret));
} else if (OB_ISNULL(expr_ctx.calc_buf_)) {
LOG_WARN("allocator should not be null");
ret = OB_ALLOCATE_MEMORY_FAILED;
} else {
number::ObNumber param_nmb = param.get_number();
number::ObNumber res_nmb;
if (param_nmb.is_negative()) {
ret = param_nmb.negate(res_nmb, *expr_ctx.calc_buf_);
} else {
ret = res_nmb.from(param_nmb, *expr_ctx.calc_buf_);
}
if (OB_SUCC(ret)) {
res.set_number(res_nmb);
}
}
return ret;
}
//unumber
int ObExprAbs::abs_unumber(ObObj &res,
const ObObj ¶m,
ObExprCtx &expr_ctx)
{
int ret = OB_SUCCESS;
TYPE_CHECK(param, ObUNumberType);
if (OB_ISNULL(expr_ctx.calc_buf_)) {
LOG_WARN("allocator should not be null");
ret = OB_ALLOCATE_MEMORY_FAILED;
} else {
number::ObNumber param_nmb = param.get_unumber();
number::ObNumber res_nmb;
if (OB_FAIL(res_nmb.from(param_nmb, *expr_ctx.calc_buf_))) {
LOG_WARN("deep copy number failed", K(ret), K(param_nmb));
} else {
res.set_unumber(res_nmb);
}
}
return ret;
}
//null
int ObExprAbs::abs_null(ObObj &res,
const ObObj ¶m,
ObExprCtx &expr_ctx)
{
res.set_null();
UNUSED(param);
UNUSED(expr_ctx);
return OB_SUCCESS;
}
//others. (datetime time varchar, etc)
int ObExprAbs::abs_others_double(ObObj &res,
const ObObj ¶m,
ObExprCtx &expr_ctx)
{
int ret = OB_SUCCESS;
double value = 0.0;
EXPR_DEFINE_CAST_CTX(expr_ctx, CM_NONE);
EXPR_GET_DOUBLE_V2(param, value);
if (OB_SUCC(ret)) {
res.set_double(value >= 0.0 ? value : -value);
}
return ret;
}
//others for oracle. (datetime time varchar, etc)
int ObExprAbs::abs_others_number(ObObj &res,
const ObObj ¶m,
ObExprCtx &expr_ctx)
{
int ret = OB_SUCCESS;
number::ObNumber value;
EXPR_DEFINE_CAST_CTX(expr_ctx, CM_NONE);
EXPR_GET_NUMBER_V2(param, value);
if (OB_SUCC(ret)) {
res.set_number(value.is_negative() ? value.negate() : value);
}
return ret;
}
int ObExprAbs::abs_hexstring(ObObj &res,
const ObObj ¶m,
ObExprCtx &expr_ctx)
{
int ret = OB_SUCCESS;
double value = 0.0;
EXPR_DEFINE_CAST_CTX(expr_ctx, CM_NONE);
EXPR_GET_DOUBLE_V2(param, value);
if (OB_SUCC(ret)) {
//udouble, not double. compatible with mysql.
res.set_udouble(value >= 0.0 ? value : -value);
}
return ret;
}
int ObExprAbs::abs_year(ObObj &res,
const ObObj ¶m,
ObExprCtx &expr_ctx)
{
int ret = OB_SUCCESS;
uint64_t value = 0.0;
EXPR_DEFINE_CAST_CTX(expr_ctx, CM_NONE);
EXPR_GET_UINT64_V2(param, value);
if (OB_SUCC(ret)) {
res.set_uint64(value);//abs(year) returns uint64. compatible with mysql.
}
return ret;
}
//bit
int ObExprAbs::abs_bit(ObObj &res,
const ObObj ¶m,
ObExprCtx &expr_ctx)
{
res.set_uint64(param.get_bit());
UNUSED(expr_ctx);
return OB_SUCCESS;
}
//enum_set
int ObExprAbs::abs_enum_set(ObObj &res,
const ObObj ¶m,
ObExprCtx &expr_ctx)
{
res.set_uint64(param.get_uint64());
UNUSED(expr_ctx);
return OB_SUCCESS;
}
int ObExprAbs::cg_expr(ObExprCGCtx &ctx,
const ObRawExpr &raw_expr,
ObExpr &rt_expr) const
{
int ret = OB_SUCCESS;
UNUSED(ctx);
UNUSED(raw_expr);
if (OB_UNLIKELY(T_OP_ABS != rt_expr.type_)
|| OB_ISNULL(rt_expr.args_)
|| OB_UNLIKELY(rt_expr.arg_cnt_ != 1)
|| OB_ISNULL(rt_expr.args_[0])) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid argument", K(ret));
} else if (OB_UNLIKELY(rt_expr.args_[0]->datum_meta_.type_ >= ObMaxType)) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid arg type for abs", K(ret));
} else {
rt_expr.eval_func_ = abs_funcs[rt_expr.args_[0]->datum_meta_.type_];
}
return ret;
}
ObObjType ObExprAbs::calc_param_type(const ObObjType orig_param_type,
const bool is_oracle_mode)
{
ObObjType calc_type = ObMaxType;
if (is_oracle_mode) {
switch (orig_param_type)
{
case ObNullType: {
calc_type = ObNullType;
break;
}
case ObFloatType: {
calc_type = ObFloatType;
break;
}
case ObDoubleType: {
calc_type = ObDoubleType;
break;
}
case ObNumberType:
case ObTinyIntType:
case ObSmallIntType:
case ObInt32Type:
case ObIntType:
case ObNumberFloatType:
case ObTimestampTZType:
case ObTimestampLTZType:
case ObTimestampNanoType:
case ObCharType:
case ObVarcharType:
case ObIntervalDSType:
case ObIntervalYMType:
case ObNVarchar2Type:
case ObNCharType:
case ObURowIDType:
case ObDecimalIntType: {
calc_type = ObNumberType;
break;
}
default: {
// do nothing
break;
}
}
} else {
switch (orig_param_type)
{
case ObTinyIntType:
case ObSmallIntType:
case ObMediumIntType:
case ObInt32Type:
case ObIntType: {
calc_type = ObIntType;
break;
}
case ObUTinyIntType:
case ObUSmallIntType:
case ObUMediumIntType:
case ObUInt32Type:
case ObUInt64Type: {
calc_type = ObUInt64Type;
break;
}
case ObFloatType:
case ObDoubleType: {
calc_type = ObDoubleType;
break;
}
case ObUFloatType:
case ObUDoubleType: {
calc_type = ObUDoubleType;
break;
}
case ObNumberType: {
calc_type = ObNumberType;
break;
}
case ObUNumberType: {
calc_type = ObUNumberType;
break;
}
case ObNullType: {
calc_type = ObNullType;
break;
}
case ObYearType: {
calc_type = ObUInt64Type;
break;
}
case ObDateTimeType:
case ObTimestampType:
case ObDateType:
case ObTimeType:
case ObVarcharType:
case ObCharType:
case ObUnknownType:
case ObHexStringType:
case ObTextType:
case ObTinyTextType:
case ObMediumTextType:
case ObLongTextType: {
calc_type = ObDoubleType;
break;
}
case ObBitType: {
calc_type = ObUInt64Type;
break;
}
case ObEnumType:
case ObSetType:
case ObJsonType: {
calc_type = ObDoubleType;
break;
}
case ObDecimalIntType: {
calc_type = ObDecimalIntType;
break;
}
default: {
break;
}
}
}
return calc_type;
}
} // namespace sql
} // namespace oceanbase