For example, if I want to call the createPartitionedTable
(createPartitionedTable — DolphinDB 2.0 documentation ), what script should I write?
Asked
Active
Viewed 29 times
1 Answers
0
The built-in functions are classified into operator functions and system functions, which are called with different prototypes.
Operator functions: call(Heap, const ConstantSP&, const ConstantSP&).
System functions: call(Heap, vector&).
There are two functions that can identify whether a function is a system function or the other kind.
inline bool isSystemFunction() const {return defType_ == SYSFUNC;}
inline FUNCTIONDEF_TYPE getFunctionDefType() const {return defType_;}
For how these two different functions can be called, you can refer to the following scripts:
createPartitionedTable
is called as a system function:
vector<ConstantSP> args{dbHandle, load(MySQLTableName_or_query, schema, 0, 1), new String(tableName), partitionColumns};
ret = heap->currentSession()->getFunctionDef("createPartitionedTable")->call(heap, args);
cumsum
is called as an operator function:
ConstantSP v = Util::createIndexVector(1, 100);
v->setTemporary(false); //The value of v may be modified when calling a built-in function. If you do not expect that, call setTemporary(false) firstly.
FunctionDefSP cumsum = heap->currentSession()->getFunctionDef("cumsum");
ConstantSP result = cumsum->call(heap, v, new Void());
// That is equivalent to cumsum(v), where new Void() is a placeholder with no practical use.

lulunolemon
- 219
- 3
-
As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 28 '23 at 08:42