mirror of
https://github.com/apache/impala.git
synced 2025-12-25 02:03:09 -05:00
IMP-267 Add version() function.
This commit is contained in:
committed by
Henry Robinson
parent
a9ff7323f2
commit
48c454d319
@@ -33,6 +33,7 @@ add_library(Exprs
|
||||
timestamp-functions.cc
|
||||
timestamp-literal.cc
|
||||
timezone_db.cc
|
||||
utility-functions.cc
|
||||
)
|
||||
|
||||
target_link_libraries(Exprs
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "codegen/llvm-codegen.h"
|
||||
#include "util/cpu-info.h"
|
||||
#include "util/disk-info.h"
|
||||
#include "util/debug-util.h"
|
||||
|
||||
using namespace llvm;
|
||||
using namespace std;
|
||||
@@ -1118,6 +1119,8 @@ TEST_F(ExprTest, StringFunctions) {
|
||||
// First param contains comma.
|
||||
TestValue("find_in_set('abc,def', 'abc,ad,,ade,cde,')", TYPE_INT, 0);
|
||||
|
||||
TestStringValue("version()", GetVersionString());
|
||||
|
||||
// TODO: tests with NULL arguments, currently we can't parse them
|
||||
// inside function calls.
|
||||
// e.g. TestValue("length(NULL)", TYPE_INT, NULL);
|
||||
|
||||
@@ -245,6 +245,7 @@ class Expr {
|
||||
friend class StringFunctions;
|
||||
friend class TimestampFunctions;
|
||||
friend class ConditionalFunctions;
|
||||
friend class UtilityFunctions;
|
||||
friend class CaseExpr;
|
||||
friend class InPredicate;
|
||||
friend class FunctionCall;
|
||||
|
||||
19
be/src/exprs/utility-functions.cc
Normal file
19
be/src/exprs/utility-functions.cc
Normal file
@@ -0,0 +1,19 @@
|
||||
// Copyright (c) 2011 Cloudera, Inc. All rights reserved.
|
||||
|
||||
#include "exprs/utility-functions.h"
|
||||
#include "exprs/function-call.h"
|
||||
#include "exprs/expr.h"
|
||||
#include "util/debug-util.h"
|
||||
#include "runtime/tuple-row.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace impala {
|
||||
|
||||
void* UtilityFunctions::Version(Expr* e, TupleRow* row) {
|
||||
DCHECK_EQ(e->GetNumChildren(), 0);
|
||||
e->result_.SetStringVal(GetVersionString());
|
||||
return &e->result_.string_val;
|
||||
}
|
||||
|
||||
}
|
||||
20
be/src/exprs/utility-functions.h
Normal file
20
be/src/exprs/utility-functions.h
Normal file
@@ -0,0 +1,20 @@
|
||||
// Copyright (c) 2011 Cloudera, Inc. All rights reserved.
|
||||
|
||||
#ifndef IMPALA_EXPRS_UTILITY_FUNCTIONS_H
|
||||
#define IMPALA_EXPRS_UTILITY_FUNCTIONS_H
|
||||
|
||||
namespace impala {
|
||||
|
||||
class Expr;
|
||||
class OpcodeRegistry;
|
||||
class TupleRow;
|
||||
|
||||
class UtilityFunctions {
|
||||
public:
|
||||
// Implementation of the version() function. Returns the version string.
|
||||
static void* Version(Expr* e, TupleRow* row);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -67,6 +67,7 @@ cc_registry_preamble = '\
|
||||
#include "exprs/string-functions.h"\n\
|
||||
#include "exprs/timestamp-functions.h"\n\
|
||||
#include "exprs/conditional-functions.h"\n\
|
||||
#include "exprs/utility-functions.h"\n\
|
||||
#include "opcode/functions.h"\n\
|
||||
\n\
|
||||
namespace impala { \n\
|
||||
|
||||
@@ -106,6 +106,7 @@ functions = [
|
||||
'StringFunctions::ParseUrl', ['parse_url']],
|
||||
['String_Parse_Url', 'STRING', ['STRING', 'STRING', 'STRING'], \
|
||||
'StringFunctions::ParseUrlKey', ['parse_url']],
|
||||
['Utility_Version', 'STRING', [], 'UtilityFunctions::Version', ['version']],
|
||||
|
||||
# Timestamp Functions
|
||||
['Unix_Timestamp', 'INT', ['TIMESTAMP'], \
|
||||
|
||||
Reference in New Issue
Block a user