Data Lake Analytics - U-SQL AVG function is rounding off


  • In Azure Data Lake File, I have a column with many 0s, 1s, 2s kind of of numbers.  The Average function in Data Lake Analytics / U-SQL is rounding off to 0, not showing decimal values, any help?
    Thursday, December 21, 2017 11:01 AM


  • It looks like you are passing integers and therefore the return type is integer.  Please see the Return Type chart from AVG (U-SQL).  "The resulting value will be truncated to its integral part."

    @avg = 
        SELECT * FROM 
            ( VALUES
            ) AS T(col1);
    @result =
        SELECT AVG(col1) AS truncatedResult,
            AVG((double)col1) AS convertedType
        FROM @avg;
    OUTPUT @result
    TO "/Test/avg.txt"
    USING Outputters.Tsv(outputHeader: true);

    Thursday, December 21, 2017 4:58 PM