Skip to content
This repository has been archived by the owner on Sep 27, 2019. It is now read-only.

Commit

Permalink
first try of function translator
Browse files Browse the repository at this point in the history
  • Loading branch information
Xupeng Li authored and apavlo committed Oct 12, 2017
1 parent 4483c4d commit 5d27bf9
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 1 deletion.
20 changes: 20 additions & 0 deletions src/codegen/expression/function_translator.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include "codegen/expression/function_translator.h"

#include "expression/function_expression.h"

namespace peloton {
namespace codegen {

// Constructor
FunctionTranslator::FunctionTranslator(
const expression::FunctionExpression &exp, CompilationContext &ctx)
: ExpressionTranslator(exp, ctx) {}

codegen::Value FunctionTranslator::DeriveValue(
CodeGen &codegen, RowBatch::Row &row) const {
const auto &func_expr = GetExpressionAs<expression::FunctionExpression>();
func_expr->
}

} // namespace codegen
} // namespace peloton
1 change: 0 additions & 1 deletion src/codegen/query_compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ bool QueryCompiler::IsExpressionSupported(
const expression::AbstractExpression &expr) {
switch (expr.GetExpressionType()) {
case ExpressionType::STAR:
case ExpressionType::FUNCTION:
case ExpressionType::VALUE_PARAMETER:
return false;
default:
Expand Down
6 changes: 6 additions & 0 deletions src/codegen/translator_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "codegen/operator/projection_translator.h"
#include "codegen/operator/table_scan_translator.h"
#include "codegen/expression/tuple_value_translator.h"
#include "codegen/expression/function_translator.h"
#include "expression/case_expression.h"
#include "expression/comparison_expression.h"
#include "expression/conjunction_expression.h"
Expand Down Expand Up @@ -161,6 +162,11 @@ std::unique_ptr<ExpressionTranslator> TranslatorFactory::CreateTranslator(
translator = new CaseTranslator(case_exp, context);
break;
}
case ExpressionType::FUNCTION: {
auto &func_exp = static_cast<const expression::FunctionExpression &>(exp);
translator = new FunctionTranslator(func_exp, context);
break;
}
default: {
throw Exception{"We don't have a translator for expression type: " +
ExpressionTypeToString(exp.GetExpressionType())};
Expand Down
28 changes: 28 additions & 0 deletions src/include/codegen/expression/function_translator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#pragma once

#include "codegen/expression/expression_translator.h"

namespace peloton {

namespace expression {
class FunctionExpression;
} // namespace expression

namespace codegen {

//===----------------------------------------------------------------------===//
// A translator for function expression
//===----------------------------------------------------------------------===//
class FunctionTranslator : public ExpressionTranslator {
public:
// Constructor
FunctionTranslator(const expression::FunctionExpression &func_expr,
CompilationContext &context);

// Return the result of the function call
codegen::Value DeriveValue(CodeGen &codegen,
RowBatch::Row &row) const override;
};

} // namespace codegen
} // namespace peloton

0 comments on commit 5d27bf9

Please sign in to comment.