Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
decimal-functions.h
Go to the documentation of this file.
1 // Copyright 2012 Cloudera Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 
16 #ifndef IMPALA_EXPRS_DECIMAL_FUNCTIONS_H
17 #define IMPALA_EXPRS_DECIMAL_FUNCTIONS_H
18 
20 #include "udf/udf.h"
21 
22 using namespace impala_udf;
23 
24 namespace impala {
25 
26 class Expr;
27 class TupleRow;
28 
30  public:
31  static IntVal Precision(FunctionContext* context, const DecimalVal& val);
32  static IntVal Scale(FunctionContext* context, const DecimalVal& val);
33 
34  static DecimalVal Abs(FunctionContext* context, const DecimalVal& val);
35  static DecimalVal Ceil(FunctionContext* context, const DecimalVal& val);
36  static DecimalVal Floor(FunctionContext* context, const DecimalVal& val);
37 
38  static DecimalVal Round(FunctionContext* context, const DecimalVal& val);
39 
40  static DecimalVal RoundTo(
41  FunctionContext* context, const DecimalVal& val, const SmallIntVal& scale);
42  static DecimalVal RoundTo(
43  FunctionContext* context, const DecimalVal& val, const TinyIntVal& scale);
44  static DecimalVal RoundTo(
45  FunctionContext* context, const DecimalVal& val, const IntVal& scale);
46  static DecimalVal RoundTo(
47  FunctionContext* context, const DecimalVal& val, const BigIntVal& scale);
48 
49  static DecimalVal Truncate(FunctionContext* context, const DecimalVal& val);
50 
51  static DecimalVal TruncateTo(
52  FunctionContext* context, const DecimalVal& val, const SmallIntVal& scale);
53  static DecimalVal TruncateTo(
54  FunctionContext* context, const DecimalVal& val, const TinyIntVal& scale);
55  static DecimalVal TruncateTo(
56  FunctionContext* context, const DecimalVal& val, const IntVal& scale);
57  static DecimalVal TruncateTo(
58  FunctionContext* context, const DecimalVal& val, const BigIntVal& scale);
59 
60  private:
62  static DecimalVal RoundTo(FunctionContext* context, const DecimalVal& val, int scale,
64 };
65 
66 }
67 
68 #endif