|
|
@ -1427,7 +1427,10 @@ export async function validateFormulaAndExtractTreeWithType({ |
|
|
|
if (parsedTree.type === JSEPNode.CALL_EXP) { |
|
|
|
if (parsedTree.type === JSEPNode.CALL_EXP) { |
|
|
|
const calleeName = parsedTree.callee.name.toUpperCase(); |
|
|
|
const calleeName = parsedTree.callee.name.toUpperCase(); |
|
|
|
// validate function name
|
|
|
|
// validate function name
|
|
|
|
if (!formulas[calleeName] || sqlUI?.getUnsupportedFnList().includes(calleeName)) { |
|
|
|
if ( |
|
|
|
|
|
|
|
!formulas[calleeName] || |
|
|
|
|
|
|
|
sqlUI?.getUnsupportedFnList().includes(calleeName) |
|
|
|
|
|
|
|
) { |
|
|
|
throw new FormulaError( |
|
|
|
throw new FormulaError( |
|
|
|
FormulaErrorType.INVALID_FUNCTION_NAME, |
|
|
|
FormulaErrorType.INVALID_FUNCTION_NAME, |
|
|
|
{}, |
|
|
|
{}, |
|
|
@ -1504,15 +1507,20 @@ export async function validateFormulaAndExtractTreeWithType({ |
|
|
|
argPt.dataType !== FormulaDataTypes.UNKNOWN |
|
|
|
argPt.dataType !== FormulaDataTypes.UNKNOWN |
|
|
|
) { |
|
|
|
) { |
|
|
|
if (argPt.type === JSEPNode.IDENTIFIER) { |
|
|
|
if (argPt.type === JSEPNode.IDENTIFIER) { |
|
|
|
|
|
|
|
const name = |
|
|
|
|
|
|
|
columns?.find( |
|
|
|
|
|
|
|
(c) => c.id === argPt.name || c.title === argPt.name |
|
|
|
|
|
|
|
)?.title || argPt.name; |
|
|
|
|
|
|
|
|
|
|
|
throw new FormulaError( |
|
|
|
throw new FormulaError( |
|
|
|
FormulaErrorType.INVALID_ARG, |
|
|
|
FormulaErrorType.INVALID_ARG, |
|
|
|
{ |
|
|
|
{ |
|
|
|
key: 'msg.formula.columnWithTypeFoundButExpected', |
|
|
|
key: 'msg.formula.columnWithTypeFoundButExpected', |
|
|
|
columnName: parsedTree.name, |
|
|
|
columnName: name, |
|
|
|
columnType: parsedTree.dataType, |
|
|
|
columnType: argPt.dataType, |
|
|
|
expectedType: expectedArgType, |
|
|
|
expectedType: expectedArgType, |
|
|
|
}, |
|
|
|
}, |
|
|
|
`Field ${parsedTree.name} with ${parsedTree.dataType} type is found but ${expectedArgType} type is expected` |
|
|
|
`Field ${name} with ${argPt.dataType} type is found but ${expectedArgType} type is expected` |
|
|
|
); |
|
|
|
); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
let key = '', |
|
|
|
let key = '', |
|
|
|