tajo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hyun...@apache.org
Subject [44/51] [partial] TAJO-752: Escalate sub modules in tajo-core into the top-level modules. (hyunsik)
Date Fri, 18 Apr 2014 09:20:06 GMT
http://git-wip-us.apache.org/repos/asf/tajo/blob/6594ac1c/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Acos.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Acos.java b/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Acos.java
new file mode 100644
index 0000000..f1f2804
--- /dev/null
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Acos.java
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.engine.function.math;
+
+import org.apache.tajo.catalog.Column;
+import org.apache.tajo.common.TajoDataTypes;
+import org.apache.tajo.datum.Datum;
+import org.apache.tajo.datum.DatumFactory;
+import org.apache.tajo.datum.NullDatum;
+import org.apache.tajo.engine.function.GeneralFunction;
+import org.apache.tajo.engine.function.annotation.Description;
+import org.apache.tajo.engine.function.annotation.ParamTypes;
+import org.apache.tajo.storage.Tuple;
+
+/**
+ * Function definition
+ *
+ * Float8 acos(value FLOAT8)
+ */
+@Description(
+  functionName = "acos",
+  description = "Inverse cosine.",
+  detail = "",
+  example = "> SELECT acos(x);",
+  returnType = TajoDataTypes.Type.FLOAT8,
+  paramTypes = {@ParamTypes(paramTypes = {TajoDataTypes.Type.FLOAT4}),
+          @ParamTypes(paramTypes = {TajoDataTypes.Type.FLOAT8})}
+)
+public class Acos extends GeneralFunction {
+  public Acos() {
+    super(new Column[] {
+        new Column("x", TajoDataTypes.Type.FLOAT8)
+    });
+  }
+
+  @Override
+  public Datum eval(Tuple params) {
+    Datum valueDatum = params.get(0);
+    if(valueDatum instanceof NullDatum) {
+      return NullDatum.get();
+    }
+
+    return DatumFactory.createFloat8(Math.acos(valueDatum.asFloat8()));
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/6594ac1c/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Asin.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Asin.java b/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Asin.java
new file mode 100644
index 0000000..6f6c905
--- /dev/null
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Asin.java
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.engine.function.math;
+
+import org.apache.tajo.catalog.Column;
+import org.apache.tajo.common.TajoDataTypes;
+import org.apache.tajo.datum.Datum;
+import org.apache.tajo.datum.DatumFactory;
+import org.apache.tajo.datum.NullDatum;
+import org.apache.tajo.engine.function.GeneralFunction;
+import org.apache.tajo.engine.function.annotation.Description;
+import org.apache.tajo.engine.function.annotation.ParamTypes;
+import org.apache.tajo.storage.Tuple;
+
+/**
+ * Function definition
+ *
+ * Float8 asin(value FLOAT8)
+ */
+@Description(
+  functionName = "asin",
+  description = "Inverse sine.",
+  example = "> SELECT asin(x);",
+  returnType = TajoDataTypes.Type.FLOAT8,
+  paramTypes = {@ParamTypes(paramTypes = {TajoDataTypes.Type.FLOAT4}),
+          @ParamTypes(paramTypes = {TajoDataTypes.Type.FLOAT8})}
+)
+public class Asin extends GeneralFunction {
+  public Asin() {
+    super(new Column[] {
+        new Column("x", TajoDataTypes.Type.FLOAT8)
+    });
+  }
+
+  @Override
+  public Datum eval(Tuple params) {
+    Datum valueDatum = params.get(0);
+    if(valueDatum instanceof NullDatum) {
+      return NullDatum.get();
+    }
+
+    return DatumFactory.createFloat8(Math.asin(valueDatum.asFloat8()));
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/6594ac1c/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Atan.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Atan.java b/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Atan.java
new file mode 100644
index 0000000..9e70ae3
--- /dev/null
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Atan.java
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.engine.function.math;
+
+import org.apache.tajo.catalog.Column;
+import org.apache.tajo.common.TajoDataTypes;
+import org.apache.tajo.datum.Datum;
+import org.apache.tajo.datum.DatumFactory;
+import org.apache.tajo.datum.NullDatum;
+import org.apache.tajo.engine.function.GeneralFunction;
+import org.apache.tajo.engine.function.annotation.Description;
+import org.apache.tajo.engine.function.annotation.ParamTypes;
+import org.apache.tajo.storage.Tuple;
+
+/**
+ * Function definition
+ *
+ * Float8 atan(value FLOAT8)
+ */
+@Description(
+  functionName = "atan",
+  description = "Inverse tangent.",
+  example = "> SELECT atan(x);",
+  returnType = TajoDataTypes.Type.FLOAT8,
+  paramTypes = {@ParamTypes(paramTypes = {TajoDataTypes.Type.FLOAT4}),
+          @ParamTypes(paramTypes = {TajoDataTypes.Type.FLOAT8})}
+)
+public class Atan extends GeneralFunction {
+  public Atan() {
+    super(new Column[] {
+        new Column("x", TajoDataTypes.Type.FLOAT8)
+    });
+  }
+
+  @Override
+  public Datum eval(Tuple params) {
+    Datum valueDatum = params.get(0);
+    if(valueDatum instanceof NullDatum) {
+      return NullDatum.get();
+    }
+
+    return DatumFactory.createFloat8(Math.atan(valueDatum.asFloat8()));
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/6594ac1c/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Atan2.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Atan2.java b/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Atan2.java
new file mode 100644
index 0000000..bc2764c
--- /dev/null
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Atan2.java
@@ -0,0 +1,62 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.engine.function.math;
+
+import org.apache.tajo.catalog.Column;
+import org.apache.tajo.common.TajoDataTypes;
+import org.apache.tajo.datum.Datum;
+import org.apache.tajo.datum.DatumFactory;
+import org.apache.tajo.datum.NullDatum;
+import org.apache.tajo.engine.function.GeneralFunction;
+import org.apache.tajo.engine.function.annotation.Description;
+import org.apache.tajo.engine.function.annotation.ParamTypes;
+import org.apache.tajo.storage.Tuple;
+
+/**
+ * Function definition
+ *
+ * Float8 atan2(value FLOAT8, value FLOAT8)
+ */
+@Description(
+  functionName = "atan2",
+  description = "Inverse tangent of y/x.",
+  example = "> SELECT atan(y,x);",
+  returnType = TajoDataTypes.Type.FLOAT8,
+  paramTypes = {@ParamTypes(paramTypes = {TajoDataTypes.Type.FLOAT4, TajoDataTypes.Type.FLOAT4}),
+          @ParamTypes(paramTypes = {TajoDataTypes.Type.FLOAT8, TajoDataTypes.Type.FLOAT8})}
+)
+public class Atan2 extends GeneralFunction {
+  public Atan2() {
+    super(new Column[] {
+        new Column("y", TajoDataTypes.Type.FLOAT8),
+        new Column("x", TajoDataTypes.Type.FLOAT8)
+    });
+  }
+
+  @Override
+  public Datum eval(Tuple params) {
+    Datum valueDatumx = params.get(0);
+    Datum valueDatumy = params.get(1);
+    if(valueDatumx instanceof NullDatum || valueDatumy instanceof NullDatum) {
+      return NullDatum.get();
+    }
+
+    return DatumFactory.createFloat8(Math.atan2(valueDatumx.asFloat8(), valueDatumy.asFloat8()));
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/6594ac1c/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Cbrt.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Cbrt.java b/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Cbrt.java
new file mode 100644
index 0000000..b85fe58
--- /dev/null
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Cbrt.java
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.engine.function.math;
+
+import org.apache.tajo.catalog.Column;
+import org.apache.tajo.common.TajoDataTypes;
+import org.apache.tajo.datum.Datum;
+import org.apache.tajo.datum.DatumFactory;
+import org.apache.tajo.datum.NullDatum;
+import org.apache.tajo.engine.function.GeneralFunction;
+import org.apache.tajo.engine.function.annotation.Description;
+import org.apache.tajo.engine.function.annotation.ParamTypes;
+import org.apache.tajo.storage.Tuple;
+
+/**
+ * Function definition
+ *
+ * FLOAT8 cbrt(value FLOAT8)
+ */
+@Description(
+  functionName = "cbrt",
+  description = "Cube root",
+  example = "> SELECT cbrt(27.0);\n"
+      + "3",
+  returnType = TajoDataTypes.Type.FLOAT8,
+  paramTypes = {@ParamTypes(paramTypes = {TajoDataTypes.Type.FLOAT4}),
+      @ParamTypes(paramTypes = {TajoDataTypes.Type.FLOAT8})}
+)
+public class Cbrt extends GeneralFunction {
+  public Cbrt() {
+    super(new Column[] {
+      new Column("x", TajoDataTypes.Type.FLOAT8)
+    });
+  }
+
+  @Override
+  public Datum eval(Tuple params) {
+    Datum valueDatum = params.get(0);
+    if(valueDatum instanceof NullDatum) {
+      return NullDatum.get();
+    }
+
+    return DatumFactory.createFloat8(Math.cbrt(valueDatum.asFloat8()));
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/6594ac1c/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Ceil.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Ceil.java b/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Ceil.java
new file mode 100644
index 0000000..cca7f60
--- /dev/null
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Ceil.java
@@ -0,0 +1,63 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.engine.function.math;
+
+import org.apache.tajo.catalog.Column;
+import org.apache.tajo.common.TajoDataTypes;
+import org.apache.tajo.datum.Datum;
+import org.apache.tajo.datum.DatumFactory;
+import org.apache.tajo.datum.NullDatum;
+import org.apache.tajo.engine.function.GeneralFunction;
+import org.apache.tajo.engine.function.annotation.Description;
+import org.apache.tajo.engine.function.annotation.ParamTypes;
+import org.apache.tajo.storage.Tuple;
+
+/**
+ * Function definition
+ *
+ * INT8 ceil(value FLOAT4/FLOAT8)
+ */
+@Description(
+  functionName = "ceil",
+  synonyms = {"ceiling"},
+  description = "Smallest integer not less than argument.",
+  example = "> SELECT ceil(-42.8);\n"
+          + "-42",
+  returnType = TajoDataTypes.Type.INT8,
+  paramTypes = {@ParamTypes(paramTypes = {TajoDataTypes.Type.FLOAT4}),
+          @ParamTypes(paramTypes = {TajoDataTypes.Type.FLOAT8})}
+)
+public class Ceil extends GeneralFunction {
+  public Ceil() {
+    super(new Column[] {
+      new Column("x", TajoDataTypes.Type.FLOAT8)
+    });
+  }
+
+  @Override
+  public Datum eval(Tuple params) {
+    Datum valueDatum = params.get(0);
+    if(valueDatum instanceof NullDatum) {
+      return NullDatum.get();
+    }
+
+    return DatumFactory.createInt8((long)Math.ceil(valueDatum.asFloat8()));
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/6594ac1c/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Cos.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Cos.java b/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Cos.java
new file mode 100644
index 0000000..997784a
--- /dev/null
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Cos.java
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.engine.function.math;
+
+import org.apache.tajo.catalog.Column;
+import org.apache.tajo.common.TajoDataTypes;
+import org.apache.tajo.datum.Datum;
+import org.apache.tajo.datum.DatumFactory;
+import org.apache.tajo.datum.NullDatum;
+import org.apache.tajo.engine.function.GeneralFunction;
+import org.apache.tajo.engine.function.annotation.Description;
+import org.apache.tajo.engine.function.annotation.ParamTypes;
+import org.apache.tajo.storage.Tuple;
+
+/**
+ * Function definition
+ *
+ * Float8 cos(value FLOAT8)
+ */
+@Description(
+  functionName = "cos",
+  description = "Cosine.",
+  example = "> SELECT cos(x);",
+  returnType = TajoDataTypes.Type.FLOAT8,
+  paramTypes = {@ParamTypes(paramTypes = {TajoDataTypes.Type.FLOAT4}),
+          @ParamTypes(paramTypes = {TajoDataTypes.Type.FLOAT8})}
+)
+public class Cos extends GeneralFunction {
+  public Cos() {
+    super(new Column[] {
+        new Column("x", TajoDataTypes.Type.FLOAT8)
+    });
+  }
+
+  @Override
+  public Datum eval(Tuple params) {
+    Datum valueDatum = params.get(0);
+    if(valueDatum instanceof NullDatum) {
+      return NullDatum.get();
+    }
+
+    return DatumFactory.createFloat8(Math.cos(valueDatum.asFloat8()));
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/6594ac1c/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Degrees.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Degrees.java b/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Degrees.java
new file mode 100644
index 0000000..cd5fd2f
--- /dev/null
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Degrees.java
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.engine.function.math;
+
+import org.apache.tajo.catalog.Column;
+import org.apache.tajo.common.TajoDataTypes;
+import org.apache.tajo.datum.Datum;
+import org.apache.tajo.datum.DatumFactory;
+import org.apache.tajo.datum.NullDatum;
+import org.apache.tajo.engine.function.GeneralFunction;
+import org.apache.tajo.engine.function.annotation.Description;
+import org.apache.tajo.engine.function.annotation.ParamTypes;
+import org.apache.tajo.storage.Tuple;
+
+/**
+ * Function definition
+ *
+ * FLOAT8 degrees(value FLOAT8)
+ */
+@Description(
+  functionName = "degrees",
+  description = "Radians to degrees",
+  example = "> SELECT degrees(0.5);\n"
+      + "28.6478897565412",
+  returnType = TajoDataTypes.Type.FLOAT8,
+  paramTypes = {@ParamTypes(paramTypes = {TajoDataTypes.Type.FLOAT4}),
+      @ParamTypes(paramTypes = {TajoDataTypes.Type.FLOAT8})}
+)
+public class Degrees extends GeneralFunction {
+  public Degrees() {
+    super(new Column[] {
+      new Column("x", TajoDataTypes.Type.FLOAT8)
+    });
+  }
+
+  @Override
+  public Datum eval(Tuple params) {
+    Datum valueDatum = params.get(0);
+    if(valueDatum instanceof NullDatum) {
+      return NullDatum.get();
+    }
+
+    return DatumFactory.createFloat8(Math.toDegrees(valueDatum.asFloat8()));
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/6594ac1c/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Div.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Div.java b/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Div.java
new file mode 100644
index 0000000..d904a2c
--- /dev/null
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Div.java
@@ -0,0 +1,77 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.engine.function.math;
+
+import org.apache.tajo.catalog.Column;
+import org.apache.tajo.common.TajoDataTypes;
+import org.apache.tajo.datum.Datum;
+import org.apache.tajo.datum.DatumFactory;
+import org.apache.tajo.datum.NullDatum;
+import org.apache.tajo.engine.function.GeneralFunction;
+import org.apache.tajo.engine.function.annotation.Description;
+import org.apache.tajo.engine.function.annotation.ParamTypes;
+import org.apache.tajo.storage.Tuple;
+
+/**
+ * Function definition
+ *
+ * INT8 div(value INT8, value INT8)
+ */
+@Description(
+  functionName = "div",
+  description = "Division(integer division truncates results)",
+  example = "> SELECT div(4, 2);\n"
+    + "2",
+  returnType = TajoDataTypes.Type.INT8,
+  paramTypes = {@ParamTypes(paramTypes = {TajoDataTypes.Type.INT8, TajoDataTypes.Type.INT8}),
+      @ParamTypes(paramTypes = {TajoDataTypes.Type.INT8, TajoDataTypes.Type.INT4}),
+      @ParamTypes(paramTypes = {TajoDataTypes.Type.INT4, TajoDataTypes.Type.INT8}),
+      @ParamTypes(paramTypes = {TajoDataTypes.Type.INT4, TajoDataTypes.Type.INT4})
+  }
+)
+public class Div extends GeneralFunction {
+  public Div() {
+    super(new Column[] {
+      new Column("x", TajoDataTypes.Type.INT8),
+      new Column("y", TajoDataTypes.Type.INT8)
+    });
+  }
+
+  @Override
+  public Datum eval(Tuple params) {
+    Datum value1Datum = params.get(0);
+    if(value1Datum instanceof NullDatum) {
+      return NullDatum.get();
+    }
+
+    Datum value2Datum = params.get(1);
+    if(value2Datum instanceof NullDatum) {
+      return NullDatum.get();
+    }
+
+    long value1 = value1Datum.asInt8();
+    long value2 = value2Datum.asInt8();
+
+    if (value2 == 0) {
+      return NullDatum.get();
+    }
+
+    return DatumFactory.createInt8(value1/value2);
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/6594ac1c/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Exp.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Exp.java b/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Exp.java
new file mode 100644
index 0000000..3c3b07c
--- /dev/null
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Exp.java
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.engine.function.math;
+
+import org.apache.tajo.catalog.Column;
+import org.apache.tajo.common.TajoDataTypes;
+import org.apache.tajo.datum.Datum;
+import org.apache.tajo.datum.DatumFactory;
+import org.apache.tajo.datum.NullDatum;
+import org.apache.tajo.engine.function.GeneralFunction;
+import org.apache.tajo.engine.function.annotation.Description;
+import org.apache.tajo.engine.function.annotation.ParamTypes;
+import org.apache.tajo.storage.Tuple;
+
+/**
+ * Function definition
+ *
+ * FLOAT8 exp(value FLOAT8)
+ */
+@Description(
+  functionName = "exp",
+  description = "Exponential",
+  example = "> SELECT exp(1.0);\n"
+      + "2.71828182845905",
+  returnType = TajoDataTypes.Type.FLOAT8,
+  paramTypes = {@ParamTypes(paramTypes = {TajoDataTypes.Type.FLOAT4}),
+      @ParamTypes(paramTypes = {TajoDataTypes.Type.FLOAT8})}
+)
+public class Exp extends GeneralFunction {
+  public Exp() {
+    super(new Column[] {
+      new Column("x", TajoDataTypes.Type.FLOAT8)
+    });
+  }
+
+  @Override
+  public Datum eval(Tuple params) {
+    Datum valueDatum = params.get(0);
+    if(valueDatum instanceof NullDatum) {
+      return NullDatum.get();
+    }
+
+    return DatumFactory.createFloat8(Math.exp(valueDatum.asFloat8()));
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/6594ac1c/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Floor.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Floor.java b/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Floor.java
new file mode 100644
index 0000000..7e4cee0
--- /dev/null
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Floor.java
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.engine.function.math;
+
+import org.apache.tajo.catalog.Column;
+import org.apache.tajo.common.TajoDataTypes;
+import org.apache.tajo.datum.Datum;
+import org.apache.tajo.datum.DatumFactory;
+import org.apache.tajo.datum.NullDatum;
+import org.apache.tajo.engine.function.GeneralFunction;
+import org.apache.tajo.engine.function.annotation.Description;
+import org.apache.tajo.engine.function.annotation.ParamTypes;
+import org.apache.tajo.storage.Tuple;
+
+/**
+ * Function definition
+ *
+ * INT8 floor(value FLOAT8)
+ */
+@Description(
+  functionName = "floor",
+  description = " Largest integer not greater than argument.",
+  example = "> SELECT floor(-42.8);\n" +
+      "-43",
+  returnType = TajoDataTypes.Type.INT8,
+  paramTypes = {@ParamTypes(paramTypes = {TajoDataTypes.Type.FLOAT4}),
+          @ParamTypes(paramTypes = {TajoDataTypes.Type.FLOAT8})}
+)
+public class Floor extends GeneralFunction {
+  public Floor() {
+    super(new Column[] {
+      new Column("x", TajoDataTypes.Type.FLOAT8)
+    });
+  }
+
+  @Override
+  public Datum eval(Tuple params) {
+    Datum valueDatum = params.get(0);
+    if(valueDatum instanceof NullDatum) {
+      return NullDatum.get();
+    }
+
+    return DatumFactory.createInt8((long)Math.floor(valueDatum.asFloat8()));
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/6594ac1c/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Mod.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Mod.java b/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Mod.java
new file mode 100644
index 0000000..c748a2d
--- /dev/null
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Mod.java
@@ -0,0 +1,77 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.engine.function.math;
+
+import org.apache.tajo.catalog.Column;
+import org.apache.tajo.common.TajoDataTypes;
+import org.apache.tajo.datum.Datum;
+import org.apache.tajo.datum.DatumFactory;
+import org.apache.tajo.datum.NullDatum;
+import org.apache.tajo.engine.function.GeneralFunction;
+import org.apache.tajo.engine.function.annotation.Description;
+import org.apache.tajo.engine.function.annotation.ParamTypes;
+import org.apache.tajo.storage.Tuple;
+
+/**
+ * Function definition
+ *
+ * INT8 mod(value INT8, value INT8)
+ */
+@Description(
+  functionName = "mod",
+  description = "Remainder of y/x",
+  example = "> SELECT mod(9, 4);\n" +
+            "1",
+  returnType = TajoDataTypes.Type.INT8,
+  paramTypes = {@ParamTypes(paramTypes = {TajoDataTypes.Type.INT8, TajoDataTypes.Type.INT8}),
+      @ParamTypes(paramTypes = {TajoDataTypes.Type.INT8, TajoDataTypes.Type.INT4}),
+      @ParamTypes(paramTypes = {TajoDataTypes.Type.INT4, TajoDataTypes.Type.INT8}),
+      @ParamTypes(paramTypes = {TajoDataTypes.Type.INT4, TajoDataTypes.Type.INT4})
+  }
+)
+public class Mod extends GeneralFunction {
+  public Mod() {
+    super(new Column[] {
+      new Column("y", TajoDataTypes.Type.INT8),
+      new Column("x", TajoDataTypes.Type.INT8)
+    });
+  }
+
+  @Override
+  public Datum eval(Tuple params) {
+    Datum value1Datum = params.get(0);
+    if(value1Datum instanceof NullDatum) {
+      return NullDatum.get();
+    }
+
+    Datum value2Datum = params.get(1);
+    if(value2Datum instanceof NullDatum) {
+      return NullDatum.get();
+    }
+
+    long value1 = value1Datum.asInt8();
+    long value2 = value2Datum.asInt8();
+
+    if (value2 == 0) {
+      return NullDatum.get();
+    }
+
+    return DatumFactory.createInt8(value1%value2);
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/6594ac1c/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Pi.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Pi.java b/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Pi.java
new file mode 100644
index 0000000..abc06b5
--- /dev/null
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Pi.java
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.engine.function.math;
+
+import org.apache.tajo.common.TajoDataTypes;
+import org.apache.tajo.datum.Datum;
+import org.apache.tajo.datum.DatumFactory;
+import org.apache.tajo.engine.function.GeneralFunction;
+import org.apache.tajo.engine.function.annotation.Description;
+import org.apache.tajo.engine.function.annotation.ParamTypes;
+import org.apache.tajo.storage.Tuple;
+
+/**
+ * Function definition
+ *
+ * INT8 ceil(value FLOAT8)
+ */
+@Description(
+  functionName = "pi",
+  description = "\"π\" constant",
+  example = "> SELECT pi();\n"
+          + "3.14159265358979",
+  returnType = TajoDataTypes.Type.FLOAT8,
+  paramTypes = {@ParamTypes(paramTypes = {})}
+)
+public class Pi extends GeneralFunction {
+  public Pi() {
+    super(NoArgs);
+  }
+
+  @Override
+  public Datum eval(Tuple params) {
+    return DatumFactory.createFloat8(Math.PI);
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/6594ac1c/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Pow.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Pow.java b/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Pow.java
new file mode 100644
index 0000000..101e508
--- /dev/null
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Pow.java
@@ -0,0 +1,78 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.engine.function.math;
+
+import org.apache.tajo.catalog.Column;
+import org.apache.tajo.common.TajoDataTypes;
+import org.apache.tajo.datum.Datum;
+import org.apache.tajo.datum.DatumFactory;
+import org.apache.tajo.datum.NullDatum;
+import org.apache.tajo.engine.function.GeneralFunction;
+import org.apache.tajo.engine.function.annotation.Description;
+import org.apache.tajo.engine.function.annotation.ParamTypes;
+import org.apache.tajo.storage.Tuple;
+
+/**
+ * Function definition
+ *
+ * Float8 pow(value FLOAT8, value FLOAT8)
+ */
+@Description(
+  functionName = "pow",
+  description = "x raised to the power of y",
+  example = "> SELECT pow(9.0, 3.0)\n"
+           + "729",
+  returnType = TajoDataTypes.Type.FLOAT8,
+  paramTypes = {@ParamTypes(paramTypes = {TajoDataTypes.Type.FLOAT4, TajoDataTypes.Type.FLOAT4}),
+      @ParamTypes(paramTypes = {TajoDataTypes.Type.FLOAT4, TajoDataTypes.Type.FLOAT8}),
+      @ParamTypes(paramTypes = {TajoDataTypes.Type.FLOAT8, TajoDataTypes.Type.FLOAT4}),
+      @ParamTypes(paramTypes = {TajoDataTypes.Type.FLOAT8, TajoDataTypes.Type.FLOAT8}),
+      @ParamTypes(paramTypes = {TajoDataTypes.Type.INT4, TajoDataTypes.Type.INT4}),
+      @ParamTypes(paramTypes = {TajoDataTypes.Type.INT4, TajoDataTypes.Type.INT8}),
+      @ParamTypes(paramTypes = {TajoDataTypes.Type.INT8, TajoDataTypes.Type.INT4}),
+      @ParamTypes(paramTypes = {TajoDataTypes.Type.INT8, TajoDataTypes.Type.INT8}),
+      @ParamTypes(paramTypes = {TajoDataTypes.Type.INT4, TajoDataTypes.Type.FLOAT4}),
+      @ParamTypes(paramTypes = {TajoDataTypes.Type.INT4, TajoDataTypes.Type.FLOAT8}),
+      @ParamTypes(paramTypes = {TajoDataTypes.Type.INT8, TajoDataTypes.Type.FLOAT4}),
+      @ParamTypes(paramTypes = {TajoDataTypes.Type.INT8, TajoDataTypes.Type.FLOAT8}),
+      @ParamTypes(paramTypes = {TajoDataTypes.Type.FLOAT4, TajoDataTypes.Type.INT4}),
+      @ParamTypes(paramTypes = {TajoDataTypes.Type.FLOAT4, TajoDataTypes.Type.INT8}),
+      @ParamTypes(paramTypes = {TajoDataTypes.Type.FLOAT8, TajoDataTypes.Type.INT4}),
+      @ParamTypes(paramTypes = {TajoDataTypes.Type.FLOAT8, TajoDataTypes.Type.INT8})
+  }
+)
+public class Pow extends GeneralFunction {
+  public Pow() {
+    super(new Column[] {
+        new Column("x", TajoDataTypes.Type.FLOAT8),
+        new Column("y", TajoDataTypes.Type.FLOAT8)
+    });
+  }
+
+  @Override
+  public Datum eval(Tuple params) {
+    Datum value1Datum = params.get(0);
+    Datum value2Datum = params.get(1);
+    if(value1Datum instanceof NullDatum || value2Datum instanceof NullDatum) {
+      return NullDatum.get();
+    }
+
+    return DatumFactory.createFloat8(Math.pow(value1Datum.asFloat8(), value2Datum.asFloat8()));
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/6594ac1c/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Radians.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Radians.java b/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Radians.java
new file mode 100644
index 0000000..a8bf363
--- /dev/null
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Radians.java
@@ -0,0 +1,62 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.engine.function.math;
+
+import org.apache.tajo.catalog.Column;
+import org.apache.tajo.common.TajoDataTypes;
+import org.apache.tajo.datum.Datum;
+import org.apache.tajo.datum.DatumFactory;
+import org.apache.tajo.datum.NullDatum;
+import org.apache.tajo.engine.function.GeneralFunction;
+import org.apache.tajo.engine.function.annotation.Description;
+import org.apache.tajo.engine.function.annotation.ParamTypes;
+import org.apache.tajo.storage.Tuple;
+
+/**
+ * Function definition
+ *
+ * FLOAT8 radians(value FLOAT8)
+ */
+@Description(
+  functionName = "radians",
+  description = "Degrees to radians",
+  example = "> SELECT radians(45.0)\n"
+      + "0.785398163397448",
+  returnType = TajoDataTypes.Type.FLOAT8,
+  paramTypes = {@ParamTypes(paramTypes = {TajoDataTypes.Type.FLOAT8}),
+      @ParamTypes(paramTypes = {TajoDataTypes.Type.FLOAT4})
+  }
+)
+public class Radians extends GeneralFunction {
+  public Radians() {
+    super(new Column[] {
+      new Column("x", TajoDataTypes.Type.FLOAT8)
+    });
+  }
+
+  @Override
+  public Datum eval(Tuple params) {
+    Datum valueDatum = params.get(0);
+    if(valueDatum instanceof NullDatum) {
+      return NullDatum.get();
+    }
+
+    return DatumFactory.createFloat8(Math.toRadians(valueDatum.asFloat8()));
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/6594ac1c/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Round.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Round.java b/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Round.java
new file mode 100644
index 0000000..9740888
--- /dev/null
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Round.java
@@ -0,0 +1,71 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.engine.function.math;
+
+import org.apache.tajo.catalog.Column;
+import org.apache.tajo.common.TajoDataTypes;
+import org.apache.tajo.datum.Datum;
+import org.apache.tajo.datum.DatumFactory;
+import org.apache.tajo.datum.NullDatum;
+import org.apache.tajo.engine.function.GeneralFunction;
+import org.apache.tajo.engine.function.annotation.Description;
+import org.apache.tajo.engine.function.annotation.ParamTypes;
+import org.apache.tajo.storage.Tuple;
+
+/**
+ * Function definition
+ *
+ * INT8 round(value FLOAT8)
+ */
+@Description(
+  functionName = "round",
+  description = "Round to nearest integer.",
+  example = "> SELECT round(42.4)\n"
+          + "42",
+  returnType = TajoDataTypes.Type.INT8,
+  paramTypes = {@ParamTypes(paramTypes = {TajoDataTypes.Type.FLOAT4}),
+          @ParamTypes(paramTypes = {TajoDataTypes.Type.FLOAT8})}
+)
+public class Round extends GeneralFunction {
+  public Round() {
+    super(new Column[] {
+      new Column("x", TajoDataTypes.Type.FLOAT8)
+    });
+  }
+
+  @Override
+  public Datum eval(Tuple params) {
+    Datum valueDatum = params.get(0);
+    if(valueDatum instanceof NullDatum) {
+      return NullDatum.get();
+    }
+
+    double value = valueDatum.asFloat8();
+
+    // Note: there are various round up/down approaches (https://en.wikipedia.org/wiki/Rounding#Tie-breaking).
+    //       Math.round uses an approach different from other programming languages, so the results of round function
+    //       can be different from other DBMSs. For example, Math.round(-5.5) returns -5. In contrast,
+    //       round function in MySQL and PostgreSQL returns -6. The below code is a workaround code for this.
+    if (value < 0) {
+      return DatumFactory.createInt8((long) Math.ceil(value - 0.5d));
+    } else {
+      return DatumFactory.createInt8((long) Math.floor(value + 0.5d));
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/6594ac1c/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Sign.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Sign.java b/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Sign.java
new file mode 100644
index 0000000..f9c49bf
--- /dev/null
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Sign.java
@@ -0,0 +1,64 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.engine.function.math;
+
+import org.apache.tajo.catalog.Column;
+import org.apache.tajo.common.TajoDataTypes;
+import org.apache.tajo.datum.Datum;
+import org.apache.tajo.datum.DatumFactory;
+import org.apache.tajo.datum.NullDatum;
+import org.apache.tajo.engine.function.GeneralFunction;
+import org.apache.tajo.engine.function.annotation.Description;
+import org.apache.tajo.engine.function.annotation.ParamTypes;
+import org.apache.tajo.storage.Tuple;
+
+/**
+ * Function definition
+ *
+ * FLOAT8 sign(value FLOAT8)
+ */
+@Description(
+  functionName = "sign",
+  description = "sign of the argument (-1, 0, +1)",
+  example = "> SELECT sign(-8.4);\n"
+          + "-1",
+  returnType = TajoDataTypes.Type.FLOAT8,
+  paramTypes = {@ParamTypes(paramTypes = {TajoDataTypes.Type.FLOAT8}),
+      @ParamTypes(paramTypes = {TajoDataTypes.Type.FLOAT4}),
+      @ParamTypes(paramTypes = {TajoDataTypes.Type.INT8}),
+      @ParamTypes(paramTypes = {TajoDataTypes.Type.INT4})
+  }
+)
+public class Sign extends GeneralFunction {
+  public Sign() {
+    super(new Column[] {
+      new Column("x", TajoDataTypes.Type.FLOAT8)
+    });
+  }
+
+  @Override
+  public Datum eval(Tuple params) {
+    Datum valueDatum = params.get(0);
+    if(valueDatum instanceof NullDatum) {
+      return NullDatum.get();
+    }
+
+    return DatumFactory.createFloat8(Math.signum(valueDatum.asFloat8()));
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/6594ac1c/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Sin.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Sin.java b/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Sin.java
new file mode 100644
index 0000000..31d56b4
--- /dev/null
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Sin.java
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.engine.function.math;
+
+import org.apache.tajo.catalog.Column;
+import org.apache.tajo.common.TajoDataTypes;
+import org.apache.tajo.datum.Datum;
+import org.apache.tajo.datum.DatumFactory;
+import org.apache.tajo.datum.NullDatum;
+import org.apache.tajo.engine.function.GeneralFunction;
+import org.apache.tajo.engine.function.annotation.Description;
+import org.apache.tajo.engine.function.annotation.ParamTypes;
+import org.apache.tajo.storage.Tuple;
+
+/**
+ * Function definition
+ *
+ * Float8 sin(value FLOAT8)
+ */
+@Description(
+  functionName = "sin",
+  description = "Sine.",
+  example = "> SELECT sin(x);",
+  returnType = TajoDataTypes.Type.FLOAT8,
+  paramTypes = {@ParamTypes(paramTypes = {TajoDataTypes.Type.FLOAT4}),
+          @ParamTypes(paramTypes = {TajoDataTypes.Type.FLOAT8})}
+)
+public class Sin extends GeneralFunction {
+  public Sin() {
+    super(new Column[] {
+        new Column("x", TajoDataTypes.Type.FLOAT8)
+    });
+  }
+
+  @Override
+  public Datum eval(Tuple params) {
+    Datum valueDatum = params.get(0);
+    if(valueDatum instanceof NullDatum) {
+      return NullDatum.get();
+    }
+
+    return DatumFactory.createFloat8(Math.sin(valueDatum.asFloat8()));
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/6594ac1c/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Sqrt.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Sqrt.java b/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Sqrt.java
new file mode 100644
index 0000000..aba33f4
--- /dev/null
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Sqrt.java
@@ -0,0 +1,62 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.engine.function.math;
+
+import org.apache.tajo.catalog.Column;
+import org.apache.tajo.common.TajoDataTypes;
+import org.apache.tajo.datum.Datum;
+import org.apache.tajo.datum.DatumFactory;
+import org.apache.tajo.datum.NullDatum;
+import org.apache.tajo.engine.function.GeneralFunction;
+import org.apache.tajo.engine.function.annotation.Description;
+import org.apache.tajo.engine.function.annotation.ParamTypes;
+import org.apache.tajo.storage.Tuple;
+
+/**
+ * Function definition
+ *
+ * FLOAT8 sqrt(value FLOAT8)
+ */
+@Description(
+  functionName = "sqrt",
+  description = "Square root",
+  example = "> SELECT sqrt(2.0);\n"
+          + "1.4142135623731",
+  returnType = TajoDataTypes.Type.FLOAT8,
+  paramTypes = {@ParamTypes(paramTypes = {TajoDataTypes.Type.FLOAT8}),
+      @ParamTypes(paramTypes = {TajoDataTypes.Type.FLOAT4})
+  }
+)
+public class Sqrt extends GeneralFunction {
+  public Sqrt() {
+    super(new Column[] {
+      new Column("x", TajoDataTypes.Type.FLOAT8)
+    });
+  }
+
+  @Override
+  public Datum eval(Tuple params) {
+    Datum valueDatum = params.get(0);
+    if(valueDatum instanceof NullDatum) {
+      return NullDatum.get();
+    }
+
+    return DatumFactory.createFloat8(Math.sqrt(valueDatum.asFloat8()));
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/6594ac1c/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Tan.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Tan.java b/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Tan.java
new file mode 100644
index 0000000..d551d8b
--- /dev/null
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/function/math/Tan.java
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.engine.function.math;
+
+import org.apache.tajo.catalog.Column;
+import org.apache.tajo.common.TajoDataTypes;
+import org.apache.tajo.datum.Datum;
+import org.apache.tajo.datum.DatumFactory;
+import org.apache.tajo.datum.NullDatum;
+import org.apache.tajo.engine.function.GeneralFunction;
+import org.apache.tajo.engine.function.annotation.Description;
+import org.apache.tajo.engine.function.annotation.ParamTypes;
+import org.apache.tajo.storage.Tuple;
+
+/**
+ * Function definition
+ *
+ * Float8 tan(value FLOAT8)
+ */
+@Description(
+  functionName = "tan",
+  description = "Tangent.",
+  example = "> SELECT tan(x);",
+  returnType = TajoDataTypes.Type.FLOAT8,
+  paramTypes = {@ParamTypes(paramTypes = {TajoDataTypes.Type.FLOAT4}),
+          @ParamTypes(paramTypes = {TajoDataTypes.Type.FLOAT8})}
+)
+public class Tan extends GeneralFunction {
+  public Tan() {
+    super(new Column[] {
+        new Column("x", TajoDataTypes.Type.FLOAT8)
+    });
+  }
+
+  @Override
+  public Datum eval(Tuple params) {
+    Datum valueDatum = params.get(0);
+    if(valueDatum instanceof NullDatum) {
+      return NullDatum.get();
+    }
+
+    return DatumFactory.createFloat8(Math.tan(valueDatum.asFloat8()));
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/6594ac1c/tajo-core/src/main/java/org/apache/tajo/engine/function/string/Ascii.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/function/string/Ascii.java b/tajo-core/src/main/java/org/apache/tajo/engine/function/string/Ascii.java
new file mode 100644
index 0000000..ecb32a4
--- /dev/null
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/function/string/Ascii.java
@@ -0,0 +1,67 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.engine.function.string;
+
+import org.apache.tajo.catalog.Column;
+import org.apache.tajo.common.TajoDataTypes;
+import org.apache.tajo.datum.Datum;
+import org.apache.tajo.datum.DatumFactory;
+import org.apache.tajo.datum.NullDatum;
+import org.apache.tajo.engine.function.GeneralFunction;
+import org.apache.tajo.engine.function.annotation.Description;
+import org.apache.tajo.engine.function.annotation.ParamTypes;
+import org.apache.tajo.storage.Tuple;
+
+/**
+ * Function definition
+ *
+ * int4 ascii(string text)
+ */
+@Description(
+  functionName = "ascii",
+  description = "ASCII code of the first character of the argument.",
+  detail = "For UTF8 returns the Unicode code point of the character.\n"
+        + "For other multibyte encodings, the argument must be an ASCII character.",
+  example = "> SELECT ascii('x');\n"
+          + "120",
+  returnType = TajoDataTypes.Type.INT4,
+  paramTypes = {@ParamTypes(paramTypes = {TajoDataTypes.Type.TEXT})}
+)
+public class Ascii extends GeneralFunction {
+
+
+  public Ascii() {
+    super(new Column[]{
+            new Column("char", TajoDataTypes.Type.TEXT)
+    });
+  }
+
+  @Override
+  public Datum eval(Tuple params) {
+    Datum datum = params.get(0);
+    if (datum instanceof NullDatum) return NullDatum.get();
+
+    byte[] bytes = datum.asByteArray();
+    if (bytes.length > 0) {
+      return DatumFactory.createInt4(bytes[0]);
+    } else {
+      return DatumFactory.createInt4(0);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/6594ac1c/tajo-core/src/main/java/org/apache/tajo/engine/function/string/BTrim.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/function/string/BTrim.java b/tajo-core/src/main/java/org/apache/tajo/engine/function/string/BTrim.java
new file mode 100644
index 0000000..b7c5611
--- /dev/null
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/function/string/BTrim.java
@@ -0,0 +1,77 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.engine.function.string;
+
+import com.google.gson.annotations.Expose;
+import org.apache.commons.lang.StringUtils;
+import org.apache.tajo.catalog.Column;
+import org.apache.tajo.common.TajoDataTypes;
+import org.apache.tajo.datum.Datum;
+import org.apache.tajo.datum.DatumFactory;
+import org.apache.tajo.datum.NullDatum;
+import org.apache.tajo.engine.eval.FunctionEval;
+import org.apache.tajo.engine.function.GeneralFunction;
+import org.apache.tajo.engine.function.annotation.Description;
+import org.apache.tajo.engine.function.annotation.ParamTypes;
+import org.apache.tajo.storage.Tuple;
+
+/**
+ * Function definition
+ *
+ * text btrim(string text [, characters text])
+ */
+@Description(
+  functionName = "trim",
+  synonyms = {"btrim"},
+  description = " Remove the longest string consisting only of "
+          + " characters in characters (a space by default) "
+          + "from the start and end of string.",
+  example = "> SELECT trim('xyxtrimyyx', 'xy');\n"
+          + "trim",
+  returnType = TajoDataTypes.Type.TEXT,
+  paramTypes = {@ParamTypes(paramTypes = {TajoDataTypes.Type.TEXT}),
+          @ParamTypes(paramTypes = {TajoDataTypes.Type.TEXT,TajoDataTypes.Type.TEXT})}
+)
+public class BTrim extends GeneralFunction {
+  @Expose private boolean hasTrimCharacters;
+
+  public BTrim() {
+    super(new Column[] {
+        new Column("string", TajoDataTypes.Type.TEXT),
+    });
+  }
+
+  public void init(FunctionEval.ParamType[] paramTypes) {
+    if (paramTypes.length == 2) {
+      hasTrimCharacters = true;
+    }
+  }
+
+  @Override
+  public Datum eval(Tuple params) {
+    Datum datum = params.get(0);
+    if(datum instanceof NullDatum) return NullDatum.get();
+
+    if (!hasTrimCharacters) {
+      return DatumFactory.createText(StringUtils.strip(datum.asChars(), null));
+    } else {
+      return DatumFactory.createText(StringUtils.strip(datum.asChars(), params.get(1).asChars()));
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/6594ac1c/tajo-core/src/main/java/org/apache/tajo/engine/function/string/BitLength.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/function/string/BitLength.java b/tajo-core/src/main/java/org/apache/tajo/engine/function/string/BitLength.java
new file mode 100644
index 0000000..3a5c216
--- /dev/null
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/function/string/BitLength.java
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.engine.function.string;
+
+import org.apache.tajo.catalog.Column;
+import org.apache.tajo.common.TajoDataTypes;
+import org.apache.tajo.datum.Datum;
+import org.apache.tajo.datum.DatumFactory;
+import org.apache.tajo.datum.NullDatum;
+import org.apache.tajo.engine.function.GeneralFunction;
+import org.apache.tajo.engine.function.annotation.Description;
+import org.apache.tajo.engine.function.annotation.ParamTypes;
+import org.apache.tajo.storage.Tuple;
+
+/**
+ * Function definition
+ *
+ * INT4 bit_length(string text)
+ */
+@Description(
+  functionName = "bit_length",
+  description = "Number of bits in string",
+  example = "> SELECT bit_length('jose');\n"
+          + "32",
+  returnType = TajoDataTypes.Type.INT4,
+  paramTypes = {@ParamTypes(paramTypes = {TajoDataTypes.Type.TEXT})}
+)
+public class BitLength extends GeneralFunction {
+  public BitLength() {
+    super(new Column[] {
+        new Column("string", TajoDataTypes.Type.TEXT)
+    });
+  }
+
+  @Override
+  public Datum eval(Tuple params) {
+    Datum datum = params.get(0);
+    if(datum instanceof NullDatum) return NullDatum.get();
+
+    return DatumFactory.createInt4(datum.asByteArray().length*8);
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/6594ac1c/tajo-core/src/main/java/org/apache/tajo/engine/function/string/CharLength.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/function/string/CharLength.java b/tajo-core/src/main/java/org/apache/tajo/engine/function/string/CharLength.java
new file mode 100644
index 0000000..76d3b55
--- /dev/null
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/function/string/CharLength.java
@@ -0,0 +1,59 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.engine.function.string;
+
+import org.apache.tajo.catalog.Column;
+import org.apache.tajo.common.TajoDataTypes;
+import org.apache.tajo.datum.Datum;
+import org.apache.tajo.datum.DatumFactory;
+import org.apache.tajo.datum.NullDatum;
+import org.apache.tajo.engine.function.GeneralFunction;
+import org.apache.tajo.engine.function.annotation.Description;
+import org.apache.tajo.engine.function.annotation.ParamTypes;
+import org.apache.tajo.storage.Tuple;
+
+/**
+ * Function definition
+ *
+ * INT4 char_length(string text) or INT4 character_length(string text)
+ */
+@Description(
+  functionName = "char_length",
+  synonyms = {"character_length"},
+  description = "Number of characters in string",
+  example = "> SELECT char_length('jose');\n"
+          + "4",
+  returnType = TajoDataTypes.Type.INT4,
+  paramTypes = {@ParamTypes(paramTypes = {TajoDataTypes.Type.TEXT})}
+)
+public class CharLength extends GeneralFunction {
+  public CharLength() {
+    super(new Column[] {
+        new Column("string", TajoDataTypes.Type.TEXT)
+    });
+  }
+
+  @Override
+  public Datum eval(Tuple params) {
+    Datum datum = params.get(0);
+    if(datum instanceof NullDatum) return NullDatum.get();
+
+    return DatumFactory.createInt4(datum.asChars().length());
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/6594ac1c/tajo-core/src/main/java/org/apache/tajo/engine/function/string/Chr.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/function/string/Chr.java b/tajo-core/src/main/java/org/apache/tajo/engine/function/string/Chr.java
new file mode 100644
index 0000000..fac4b27
--- /dev/null
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/function/string/Chr.java
@@ -0,0 +1,65 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.engine.function.string;
+
+import org.apache.tajo.catalog.Column;
+import org.apache.tajo.common.TajoDataTypes;
+import org.apache.tajo.datum.Datum;
+import org.apache.tajo.datum.DatumFactory;
+import org.apache.tajo.datum.NullDatum;
+import org.apache.tajo.engine.function.GeneralFunction;
+import org.apache.tajo.engine.function.annotation.Description;
+import org.apache.tajo.engine.function.annotation.ParamTypes;
+import org.apache.tajo.storage.Tuple;
+
+/**
+ * Function definition
+ *
+ * char chr(value int4)
+ */
+@Description(
+  functionName = "chr",
+  description = "Character with the given code.",
+  detail = "For UTF8 the argument is treated as a Unicode code point. "
+    + "For other multibyte encodings the argument must designate an ASCII character.",
+  example = "> SELECT chr(65);\n"
+          + "A",
+  returnType = TajoDataTypes.Type.CHAR,
+  paramTypes = {@ParamTypes(paramTypes = {TajoDataTypes.Type.INT4})}
+)
+public class Chr extends GeneralFunction {
+  public Chr() {
+    super(new Column[]{
+            new Column("n", TajoDataTypes.Type.INT4)
+    });
+  }
+
+  @Override
+  public Datum eval(Tuple params) {
+    Datum datum = params.get(0);
+    if (datum instanceof NullDatum) return NullDatum.get();
+
+    int value = datum.asInt4();
+    if (value <= 0 || value > 65525) {
+        return NullDatum.get();
+    } else {
+        return DatumFactory.createText(String.valueOf((char)value));
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/6594ac1c/tajo-core/src/main/java/org/apache/tajo/engine/function/string/Concat.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/function/string/Concat.java b/tajo-core/src/main/java/org/apache/tajo/engine/function/string/Concat.java
new file mode 100644
index 0000000..56b07eb
--- /dev/null
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/function/string/Concat.java
@@ -0,0 +1,73 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.engine.function.string;
+
+import com.google.gson.annotations.Expose;
+import org.apache.tajo.catalog.Column;
+import org.apache.tajo.common.TajoDataTypes;
+import org.apache.tajo.datum.Datum;
+import org.apache.tajo.datum.DatumFactory;
+import org.apache.tajo.datum.NullDatum;
+import org.apache.tajo.engine.function.GeneralFunction;
+import org.apache.tajo.engine.function.annotation.Description;
+import org.apache.tajo.engine.function.annotation.ParamTypes;
+import org.apache.tajo.storage.Tuple;
+
+
+/**
+ * Function definition
+ *
+ * text concat(str "any" [, str "any" [, ...] ])
+ */
+@Description(
+    functionName = "concat",
+    description = "Concatenate all arguments.",
+    detail = "Concatenate all arguments. NULL arguments are ignored.",
+    example = "> SELECT concat('abcde', '2');\n"
+        + "abcde2",
+    returnType = TajoDataTypes.Type.TEXT,
+    paramTypes = {@ParamTypes(paramTypes = {TajoDataTypes.Type.TEXT, TajoDataTypes.Type.TEXT})
+        }
+)
+public class Concat extends GeneralFunction {
+  @Expose private boolean hasMoreCharacters;
+
+  public Concat() {
+    super(new Column[] {
+        new Column("text", TajoDataTypes.Type.TEXT),
+    });
+  }
+
+  @Override
+  public Datum eval(Tuple params) {
+    Datum datum = params.get(0);
+
+    if(datum instanceof NullDatum) return NullDatum.get();
+
+    StringBuilder result = new StringBuilder(datum.asChars());
+
+    for(int i = 1 ; i < params.size() ; i++) {
+      Datum tmpDatum = params.get(i);
+      if(tmpDatum instanceof NullDatum)
+        continue;
+      result.append(tmpDatum.asChars());
+    }
+    return DatumFactory.createText(result.toString());
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/6594ac1c/tajo-core/src/main/java/org/apache/tajo/engine/function/string/Concat_ws.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/function/string/Concat_ws.java b/tajo-core/src/main/java/org/apache/tajo/engine/function/string/Concat_ws.java
new file mode 100644
index 0000000..dd48151
--- /dev/null
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/function/string/Concat_ws.java
@@ -0,0 +1,78 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.engine.function.string;
+
+import com.google.gson.annotations.Expose;
+import org.apache.tajo.catalog.Column;
+import org.apache.tajo.common.TajoDataTypes;
+import org.apache.tajo.datum.Datum;
+import org.apache.tajo.datum.DatumFactory;
+import org.apache.tajo.datum.NullDatum;
+import org.apache.tajo.engine.function.GeneralFunction;
+import org.apache.tajo.engine.function.annotation.Description;
+import org.apache.tajo.engine.function.annotation.ParamTypes;
+import org.apache.tajo.storage.Tuple;
+
+/**
+ * Function definition
+ *
+ * text concat(str "any" [, str "any" [, ...] ])
+ */
+@Description(
+    functionName = "concat_ws",
+    description = "Concatenate all but first arguments with separators.",
+    detail = "The first parameter is used as a separator. NULL arguments are ignored.",
+    example = "> concat_ws(',', 'abcde', 2);\n"
+        + "abcde,2",
+    returnType = TajoDataTypes.Type.TEXT,
+    paramTypes = {@ParamTypes(paramTypes = {TajoDataTypes.Type.TEXT, TajoDataTypes.Type.TEXT, TajoDataTypes.Type.TEXT})}
+)
+public class Concat_ws extends GeneralFunction {
+  @Expose private boolean hasMoreCharacters;
+
+  public Concat_ws() {
+    super(new Column[] {
+        new Column("text", TajoDataTypes.Type.TEXT),
+        new Column("text", TajoDataTypes.Type.TEXT),
+        new Column("text", TajoDataTypes.Type.TEXT),
+    });
+  }
+
+  @Override
+  public Datum eval(Tuple params) {
+    Datum sepDatum = params.get(0);
+    Datum datum = params.get(1);
+
+
+    if(datum instanceof NullDatum) return NullDatum.get();
+    if(sepDatum instanceof NullDatum) return NullDatum.get();
+
+    StringBuilder result = new StringBuilder(datum.asChars());
+
+
+    for(int i = 2 ; i < params.size() ; i++) {
+      Datum tmpDatum = params.get(i);
+      if(tmpDatum instanceof NullDatum)
+        continue;
+      result.append(sepDatum.asChars());
+      result.append(tmpDatum.asChars());
+    }
+    return DatumFactory.createText(result.toString());
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/6594ac1c/tajo-core/src/main/java/org/apache/tajo/engine/function/string/Decode.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/function/string/Decode.java b/tajo-core/src/main/java/org/apache/tajo/engine/function/string/Decode.java
new file mode 100644
index 0000000..13f0749
--- /dev/null
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/function/string/Decode.java
@@ -0,0 +1,91 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.engine.function.string;
+
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.tajo.catalog.Column;
+import org.apache.tajo.common.TajoDataTypes;
+import org.apache.tajo.datum.Datum;
+import org.apache.tajo.datum.DatumFactory;
+import org.apache.tajo.datum.NullDatum;
+import org.apache.tajo.engine.function.GeneralFunction;
+import org.apache.tajo.engine.function.annotation.Description;
+import org.apache.tajo.engine.function.annotation.ParamTypes;
+import org.apache.tajo.storage.Tuple;
+
+
+/**
+ * Function definition
+ *
+ * bytearray decode(string text, format text)
+ */
+@Description(
+  functionName = "decode",
+  description = "Decode binary data from textual representation in string. "
+          + "Options for format are same as in encode.",
+  detail = "format is one of 'base64', 'hex'",
+  example = "> SELECT decode('MTIzAAE=', 'base64');\n"
+          + "\\x3132330001",
+  returnType = TajoDataTypes.Type.TEXT,
+  paramTypes = {@ParamTypes(paramTypes = {TajoDataTypes.Type.TEXT, TajoDataTypes.Type.TEXT})}
+)
+public class Decode extends GeneralFunction {
+  public Decode() {
+    super(new Column[] {
+        new Column("string", TajoDataTypes.Type.TEXT),
+        new Column("format", TajoDataTypes.Type.TEXT)
+    });
+  }
+
+  @Override
+  public Datum eval(Tuple params) {
+    Datum datum = params.get(0);
+    Datum formatType = params.get(1);
+    String decodedBase64Text="";
+    String decodedHexString="";
+
+    if(datum instanceof NullDatum) return NullDatum.get();
+    if(formatType instanceof NullDatum) return NullDatum.get();
+
+    if(formatType.asChars().toLowerCase().equals("base64")) {
+      try {
+        // Base64
+        decodedBase64Text = new String(Base64.decodeBase64(datum.asChars().getBytes()));
+      }
+      catch (Exception e) {
+        return NullDatum.get();
+      }
+
+      return DatumFactory.createText(StringEscapeUtils.escapeJava(decodedBase64Text));
+    }
+    else if(formatType.asChars().toLowerCase().equals("hex")) {
+      try {
+        // Hex
+        decodedHexString = HexStringConverter.getInstance().decodeHex(datum.asChars());
+      }
+      catch (Exception e) {
+        return NullDatum.get();
+      }
+      return DatumFactory.createText(StringEscapeUtils.escapeJava(decodedHexString));
+    }
+    else
+      return NullDatum.get();
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/6594ac1c/tajo-core/src/main/java/org/apache/tajo/engine/function/string/Digest.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/function/string/Digest.java b/tajo-core/src/main/java/org/apache/tajo/engine/function/string/Digest.java
new file mode 100644
index 0000000..163c6fe
--- /dev/null
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/function/string/Digest.java
@@ -0,0 +1,87 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.engine.function.string;
+
+import org.apache.tajo.catalog.Column;
+import org.apache.tajo.common.TajoDataTypes;
+import org.apache.tajo.datum.Datum;
+import org.apache.tajo.datum.DatumFactory;
+import org.apache.tajo.datum.NullDatum;
+import org.apache.tajo.engine.function.GeneralFunction;
+import org.apache.tajo.engine.function.annotation.Description;
+import org.apache.tajo.engine.function.annotation.ParamTypes;
+import org.apache.tajo.storage.Tuple;
+import java.security.*;
+import org.apache.commons.codec.binary.Hex;
+import org.apache.commons.codec.digest.DigestUtils;
+
+/**
+ * Function definition
+ *
+ * text digest(string text, type text)
+ */
+@Description(
+  functionName = "digest",
+  description = "Calculates the Digest hash of string",
+  example = "> SELECT digest('tajo', 'sha1');\n"
+          + "02b0e20540b89f0b735092bbac8093eb2e3804cf",
+  returnType = TajoDataTypes.Type.TEXT,
+  paramTypes = {@ParamTypes(paramTypes = {TajoDataTypes.Type.TEXT, TajoDataTypes.Type.TEXT})}
+)
+
+public class Digest extends GeneralFunction {
+  public Digest() {
+    super(new Column[] {
+        new Column("text", TajoDataTypes.Type.TEXT)
+    });
+  }
+
+  String digest(byte [] data, String type) throws NoSuchAlgorithmException{
+    if ("SHA1".equalsIgnoreCase(type) == true) {
+      MessageDigest md = MessageDigest.getInstance("SHA-1");
+      return new String(Hex.encodeHex(md.digest(data)));
+    } else if ("SHA256".equalsIgnoreCase(type) == true) {
+      return DigestUtils.sha256Hex(data);
+    } else if ("SHA384".equalsIgnoreCase(type) == true) {
+      return DigestUtils.sha384Hex(data);
+    } else if ("SHA512".equalsIgnoreCase(type) == true) {
+      return DigestUtils.sha512Hex(data);
+    } else if ("MD5".equalsIgnoreCase(type) == true) {
+      return DigestUtils.md5Hex(data);
+    } else if ("MD2".equalsIgnoreCase(type) == true) {
+      MessageDigest md = MessageDigest.getInstance("MD2");
+      return new String(Hex.encodeHex(md.digest(data)));
+    }
+
+    throw new NoSuchAlgorithmException("Not supported DigestType");
+  }
+
+  @Override
+  public Datum eval(Tuple params) {
+    Datum datum = params.get(0);
+    Datum typeDatum = params.get(1);
+    if(datum instanceof NullDatum || typeDatum instanceof NullDatum) return NullDatum.get();
+
+    try {
+        return DatumFactory.createText(digest(datum.asByteArray(), typeDatum.asChars()));
+    } catch (NoSuchAlgorithmException e){
+        return NullDatum.get();
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/tajo/blob/6594ac1c/tajo-core/src/main/java/org/apache/tajo/engine/function/string/Encode.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/function/string/Encode.java b/tajo-core/src/main/java/org/apache/tajo/engine/function/string/Encode.java
new file mode 100644
index 0000000..0023ae6
--- /dev/null
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/function/string/Encode.java
@@ -0,0 +1,93 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.engine.function.string;
+
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.tajo.catalog.Column;
+import org.apache.tajo.common.TajoDataTypes;
+import org.apache.tajo.datum.Datum;
+import org.apache.tajo.datum.DatumFactory;
+import org.apache.tajo.datum.NullDatum;
+import org.apache.tajo.engine.function.GeneralFunction;
+import org.apache.tajo.engine.function.annotation.Description;
+import org.apache.tajo.engine.function.annotation.ParamTypes;
+import org.apache.tajo.storage.Tuple;
+
+
+/**
+ * Function definition
+ *
+ * bytearray encode(data bytea, format text)
+ */
+@Description(
+  functionName = "encode",
+  description = "Encode binary data into a textual representation.",
+  detail = "Supported formats are: base64, hex, escape. escape converts zero bytes and "
+        + "high-bit-set bytes to octal sequences (\\nnn) and doubles backslashes.",
+  example = "> SELECT encode(E'123\\\\000\\\\001', 'base64');\n"
+          + "MTIzAAE=",
+  returnType = TajoDataTypes.Type.TEXT,
+  paramTypes = {@ParamTypes(paramTypes = {TajoDataTypes.Type.TEXT, TajoDataTypes.Type.TEXT})}
+)
+public class Encode extends GeneralFunction {
+  public Encode() {
+    super(new Column[] {
+        new Column("string", TajoDataTypes.Type.TEXT),
+        new Column("format", TajoDataTypes.Type.TEXT)
+    });
+  }
+
+  @Override
+  public Datum eval(Tuple params) {
+    Datum datum = params.get(0);
+    Datum formatType = params.get(1);
+    String encodedBase64Text="";
+    String encodedHexString="";
+
+    if(datum instanceof NullDatum) return NullDatum.get();
+    if(formatType instanceof NullDatum) return NullDatum.get();
+
+
+    if(formatType.asChars().toLowerCase().equals("base64")) {
+      try {
+        // Base64
+        encodedBase64Text = new String(Base64.encodeBase64(StringEscapeUtils.unescapeJava(datum.asChars()).getBytes()));
+      }
+      catch (Exception e) {
+        return NullDatum.get();
+      }
+
+      return DatumFactory.createText(encodedBase64Text);
+    }
+    else if(formatType.asChars().toLowerCase().equals("hex")) {
+      try {
+        // Hex
+        encodedHexString = HexStringConverter.getInstance().encodeHex(StringEscapeUtils.unescapeJava(datum.asChars()));
+      }
+      catch (Exception e) {
+        return NullDatum.get();
+      }
+
+      return DatumFactory.createText(encodedHexString);
+    }
+    else
+      return NullDatum.get();
+  }
+}


Mime
View raw message