diff --git a/src/Interpreters/ExpressionJIT.cpp b/src/Interpreters/ExpressionJIT.cpp index 9564437f72e..4169d95bfa4 100644 --- a/src/Interpreters/ExpressionJIT.cpp +++ b/src/Interpreters/ExpressionJIT.cpp @@ -45,8 +45,6 @@ static Poco::Logger * getLogger() class LLVMExecutableFunction : public IExecutableFunctionImpl { - std::string name; - JITCompiledFunction function = nullptr; public: explicit LLVMExecutableFunction(const std::string & name_, JITCompiledFunction function_) @@ -73,13 +71,13 @@ public: result_column = result_column->cloneResized(input_rows_count); std::vector columns(arguments.size() + 1); + std::vector columns_backup; + for (size_t i = 0; i < arguments.size(); ++i) { - const auto * column = arguments[i].column.get(); - if (!column) - throw Exception(ErrorCodes::LOGICAL_ERROR, "Column {} is missing", arguments[i].name); - - columns[i] = getColumnData(column); + auto column = arguments[i].column->convertToFullColumnIfConst(); + columns_backup.emplace_back(column); + columns[i] = getColumnData(column.get()); } columns[arguments.size()] = getColumnData(result_column.get()); @@ -111,6 +109,9 @@ public: return result_column; } +private: + std::string name; + JITCompiledFunction function = nullptr; }; class LLVMFunction : public IFunctionBaseImpl diff --git a/src/Interpreters/JIT/CompileDAG.h b/src/Interpreters/JIT/CompileDAG.h index 2485e4e4303..3872a896e38 100644 --- a/src/Interpreters/JIT/CompileDAG.h +++ b/src/Interpreters/JIT/CompileDAG.h @@ -30,7 +30,7 @@ namespace DB * Node a, Constant 1, Function add(a + 1), Input b, Constant 1, Function add(b, 1), Function add(add(a + 1), add(a + 1)). * * Compile function must be called with input_nodes_values equal to input nodes count. - * During compile funciton call CompileDAG is compiled in order of added nodes. + * When compile method is called added nodes are compiled in order. */ class CompileDAG { diff --git a/src/Interpreters/JIT/compileFunction.cpp b/src/Interpreters/JIT/compileFunction.cpp index 92a7b189645..a17591bc96f 100644 --- a/src/Interpreters/JIT/compileFunction.cpp +++ b/src/Interpreters/JIT/compileFunction.cpp @@ -15,10 +15,10 @@ namespace { struct ColumnDataPlaceholder { - llvm::Value * data_init; /// first row - llvm::Value * null_init; - llvm::PHINode * data; /// current row - llvm::PHINode * null; + llvm::Value * data_init = nullptr; /// first row + llvm::Value * null_init = nullptr; + llvm::PHINode * data = nullptr; /// current row + llvm::PHINode * null = nullptr; }; } @@ -78,11 +78,11 @@ static void compileFunction(llvm::Module & module, const IFunctionBaseImpl & fun llvm::Value * counter_arg = &*args++; llvm::Value * columns_arg = &*args++; - /// Initialize ColumnDataPlaceholder llvm represenation of ColumnData - /// Last columns ColumnDataPlaceholder is result column + /// Initialize ColumnDataPlaceholder llvm representation of ColumnData auto * entry = llvm::BasicBlock::Create(b.getContext(), "entry", func); b.SetInsertPoint(entry); + std::vector columns(arg_types.size() + 1); for (size_t i = 0; i <= arg_types.size(); ++i) { diff --git a/src/Interpreters/JIT/compileFunction.h b/src/Interpreters/JIT/compileFunction.h index f571f18d6a4..ae8a5f0ad13 100644 --- a/src/Interpreters/JIT/compileFunction.h +++ b/src/Interpreters/JIT/compileFunction.h @@ -23,7 +23,7 @@ struct ColumnData }; /** Returns ColumnData for column. - * If constant column is passed, LOGICAL_ERROR will be throwed. + * If constant column is passed, LOGICAL_ERROR will be thrown. */ ColumnData getColumnData(const IColumn * column);