Files
impala/common/thrift/Types.thrift
Skye Wanderman-Milne 6ceed1e632 UDF API additions
This patch introduces the ability to specify a prepare and close
function for a UDF, as well as FunctionContext methods for maintaining
state across UDF invocations within a query. Many of the changes are
related to adding an Expr::Open() function which calls the UDF's
prepare function, if specified (it has to be called in Open() since
the LLVM module must be compiled first).

Change-Id: I581d90d03dff71f7ff5d4a6bef839ba6bc46b443
Reviewed-on: http://gerrit.ent.cloudera.com:8080/1693
Reviewed-by: Skye Wanderman-Milne <skye@cloudera.com>
Tested-by: jenkins
(cherry picked from commit 8e2ed7fb9051d98f89327715fdebd6f5ed22d6ee)
Reviewed-on: http://gerrit.ent.cloudera.com:8080/1757
2014-03-05 07:32:34 -08:00

163 lines
3.7 KiB
Thrift

// Copyright 2012 Cloudera Inc.
//
// Licensed 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.
namespace cpp impala
namespace java com.cloudera.impala.thrift
typedef i64 TTimestamp
typedef i32 TPlanNodeId
typedef i32 TTupleId
typedef i32 TSlotId
typedef i32 TTableId
enum TPrimitiveType {
INVALID_TYPE,
NULL_TYPE,
BOOLEAN,
TINYINT,
SMALLINT,
INT,
BIGINT,
FLOAT,
DOUBLE,
DATE,
DATETIME,
TIMESTAMP,
STRING,
// Unsupported types
BINARY,
DECIMAL,
// CHAR(n). Currently only supported in UDAs
CHAR,
}
struct TColumnType {
1: required TPrimitiveType type
// Only set if type == CHAR
2: optional i32 len
// Only set if type == DECIMAL
3: optional i32 precision
4: optional i32 scale
}
enum TStmtType {
QUERY,
DDL, // Data definition, e.g. CREATE TABLE (includes read-only functions e.g. SHOW)
DML, // Data modification e.g. INSERT
EXPLAIN,
LOAD // Statement type for LOAD commands
}
// Level of verboseness for "explain" output.
enum TExplainLevel {
MINIMAL,
STANDARD,
EXTENDED,
VERBOSE
}
// A TNetworkAddress is the standard host, port representation of a
// network address. The hostname field must be resolvable to an IPv4
// address.
struct TNetworkAddress {
1: required string hostname
2: required i32 port
}
// Wire format for UniqueId
struct TUniqueId {
1: required i64 hi
2: required i64 lo
}
enum TFunctionType {
SCALAR,
AGGREGATE,
}
enum TFunctionBinaryType {
// Impala builtin. We can either run this interpreted or via codegen
// depending on the query option.
BUILTIN,
// Hive UDFs, loaded from *.jar
HIVE,
// Native-interface, precompiled UDFs loaded from *.so
NATIVE,
// Native-interface, precompiled to IR; loaded from *.ll
IR,
}
// Represents a fully qualified function name.
struct TFunctionName {
// Name of the function's parent database. Not set if in global
// namespace (e.g. builtins)
1: optional string db_name
// Name of the function
2: required string function_name
}
struct TScalarFunction {
1: required string symbol;
2: optional string prepare_fn_symbol
3: optional string close_fn_symbol
}
struct TAggregateFunction {
1: required TColumnType intermediate_type
2: required string update_fn_symbol
3: required string init_fn_symbol
4: optional string serialize_fn_symbol
5: required string merge_fn_symbol
6: optional string finalize_fn_symbol
7: optional bool ignores_distinct
}
// Represents a function in the Catalog.
struct TFunction {
// Fully qualified function name.
1: required TFunctionName name
// Type of the udf. e.g. hive, native, ir
2: required TFunctionBinaryType binary_type
// The types of the arguments to the function
3: required list<TColumnType> arg_types
// Return type for the function.
4: required TColumnType ret_type
// If true, this function takes var args.
5: required bool has_var_args
// Optional comment to attach to the function
6: optional string comment
7: optional string signature
// HDFS path for the function binary. This binary must exist at the time the
// function is created.
8: optional string hdfs_location
// One of these should be set.
9: optional TScalarFunction scalar_fn
10: optional TAggregateFunction aggregate_fn
}