blob: 435f025bdc3290dba04b96e9a7b9539ebd09ccab [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<document>
<properties>
<title>Hadoop Hive- Reflect User Defined Function</title>
<author email="hive-user@hadoop.apache.org">Hadoop Hive Documentation Team</author>
</properties>
<body>
<section name="Reflect (Generic) UDF" href="reflect">
<p>A java class and method often exists to handle the exact function a user would like to use in hive. Rather
then having to write a wrapper UDF to call this method, the majority of these methods can be called using reflect udf. Reflect uses
java reflection to instantiate and call methods of objects, it can also call static functions. The method must return a primative type
or a type that hive knows how to serialize.
</p>
<source><![CDATA[SELECT reflect("java.lang.String", "valueOf", 1),
reflect("java.lang.String", "isEmpty"),
reflect("java.lang.Math", "max", 2, 3),
reflect("java.lang.Math", "min", 2, 3),
reflect("java.lang.Math", "round", 2.5),
reflect("java.lang.Math", "exp", 1.0),
reflect("java.lang.Math", "floor", 1.9)
FROM src LIMIT 1;
1 true 3 2 3 2.7182818284590455 1.0]]></source>
</section>
</body>
</document>