fix: create function error for json/decimal/blob/varbinary type

This commit is contained in:
slzhou 2023-03-21 00:38:13 -08:00
parent 93e50588ce
commit b9edd24d3f
2 changed files with 12 additions and 0 deletions

View File

@ -6393,6 +6393,15 @@ static int32_t translateCreateFunction(STranslateContext* pCxt, SCreateFunctionS
if (fmIsBuiltinFunc(pStmt->funcName)) {
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_FUNCTION_NAME);
}
if (TSDB_DATA_TYPE_JSON == pStmt->outputDt.type ||
TSDB_DATA_TYPE_VARBINARY == pStmt->outputDt.type ||
TSDB_DATA_TYPE_DECIMAL == pStmt->outputDt.type ||
TSDB_DATA_TYPE_BLOB == pStmt->outputDt.type ||
TSDB_DATA_TYPE_MEDIUMBLOB == pStmt->outputDt.type) {
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_SYNTAX_ERROR, "Unsupported output type for UDF");
}
SCreateFuncReq req = {0};
strcpy(req.name, pStmt->funcName);
req.igExists = pStmt->ignoreExists;

View File

@ -29,6 +29,9 @@ else
sql create function bit_and as '/tmp/udf/libbitand.so' outputtype int bufSize 8;
sql create aggregate function l2norm as '/tmp/udf/libl2norm.so' outputtype double bufSize 8;
endi
sql_error create function bit_and as '/tmp/udf/libbitand.so' oputtype json;
sql show functions;
if $rows != 2 then
return -1