Errors when trying to use decimal type arguments in a Data Flow Library Function

Justin Modrzynski 0 Reputation points
2024-06-25T16:28:56.7966667+00:00

I am receiving errors when trying to use a decimal argument in a Data Flow Library Function and based on my troubleshooting I believe it may be an issue with ADF itself. I have gone through these troubleshooting steps:

  1. Create a new Data Flow Library with a new Data Flow Library Function
  2. Add an argument of type "decimal"
  3. In the library Body, don't even use the argument, just return "1"
    DataFlowLibraryFunction
  4. Create a new Data Flow with any source you want. I used an inline Azure SQL source and just selected a default value in my query.
    DataFlowSource
  5. Add a Dreived Column step and use your Data Flow Library Function in the column expression. I used "toDecimal" as well to confirm I was passing a decimal value into the function. You can use the default decimal precision or include it. You can also read a decimal value from your data source instead.
    TestLibraryFunction(toDecimal(123.45, 10, 2))
    DerivedColumnExpression
  6. Refresh the Data Preview tab and notice the error.
    Spark job failed: { "text/plain": "{\"runId\":\"ad3661ae-8382-4e4a-b6f3-7399b15d2aab\",\"sessionId\":\"00856b32-06e9-485c-b5ea-a7a7346ff05b\",\"status\":\"Failed\",\"payload\":{\"statusCode\":400,\"shortMessage\":\"DF-DSL-001 at : DSL stream has parsing errors\\nLine 2 Position 27: TestLibraryFunction(decimal) as integer = 1\\nmismatched input ')' expecting '('\",\"detailedMessage\":\"Failure 2024-06-25 16:02:45.052 failed DebugManager.processJob, run=ad3661ae-8382-4e4a-b6f3-7399b15d2aab, errorMessage=DF-DSL-001 at : DSL stream has parsing errors\\nLine 2 Position 27: TestLibraryFunction(decimal) as integer = 1\\nmismatched input ')' expecting '('\"}}\n" } - RunId: ad3661ae-8382-4e4a-b6f3-7399b15d2aab
    DataPreviewError1
  7. Inside of the error you will note it mentions "type mismatch" and expecting a comma or parens instead of a different character, along with a line position. This lead me to the JSON representation of the Data Flow Library Function and the fact that it looks like parser is requiring precision to always be included on the decimal argument type, such as "decimal(10, 2)", but the drop down in the ADF UI only has "decimal" and it only shows up as "decimal" in the JSON as well.
    DataFlowLibraryFunctionJson
  8. I went ahead and updated the JSON to include a precision of "decimal(10, 2)" and tried preview again, but this time I received a different error.
    DataFlowLibraryFunctionJsonUpdated

DataPreviewError2

Spark job failed: { "text/plain": "{\"runId\":\"172ad852-106d-40f7-a47a-e506756a9895\",\"sessionId\":\"00856b32-06e9-485c-b5ea-a7a7346ff05b\",\"status\":\"Failed\",\"payload\":{\"statusCode\":400,\"shortMessage\":\"DF-FN-002 at Derive 'derivedColumn2'(Line 10/Col 35): Function 'TestLibraryFunction' argument 1 should be DecimalType(10,2) but was DecimalType(10,0)\",\"detailedMessage\":\"Failure 2024-06-25 16:14:04.718 failed DebugManager.processJob, run=172ad852-106d-40f7-a47a-e506756a9895, errorMessage=DF-FN-002 at Derive 'derivedColumn2'(Line 10/Col 35): Function 'TestLibraryFunction' argument 1 should be DecimalType(10,2) but was DecimalType(10,0)\"}}\n" } - RunId: 172ad852-106d-40f7-a47a-e506756a9895

  1. The error this time mentions that argument 1 is of precision "decimal(10, 2)" which is what I saved in the JSON, but that the argument being passed in is of precision "decimal(10, 0)" which is not correct. In Step 5 you'll notice that I am passing in "decimal(10, 2)" but for some reason it doesn't recognize that precision.
  2. After much testing at this point, it looks like when calling the Data Flow Library Function it always thinks you are passing in "decimal(10, 0)", so the only way to get the error to go away is to update the JSON to the same thing.
    DataFlowLibraryFunctionJsonUpdated2
  3. However, you can pass any precision of decimal still into the Data Flow Library Function, which you've specified as only allowing "decimal(10, 0)", and it will not only still work, but it will keep the precision you set. You can test it out by updating the Data Flow Library Function to return your input parameter "i1" back and view it on the Data Preview.
    DerivedColumnExpression2

DataPreviewResults

After this testing I believe this may be a bug within ADF, and I'm looking for confirmation if that seems correct and also next steps to get this submitted and corrected if it is truly an ADF issue. As a workaround we are converting the decimal field to a "Double" field before passing it into the Data Flow Library Functions, but that is an extra step we are adding in a lot of places that we'd wish to avoid. Thanks!

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
9,977 questions
{count} votes