none
How to pass a parameter to reducer UDO?

    Question

  • Hi all,

    We have a parameter declared in U-SQL script, for example:

    DECLARE @START_TIME DateTime = DateTime.ParseExact("2016-Sep-02 09:30:06","yyyy-MMM-dd HH:mm:ss", CultureInfo.InvariantCulture);

    And there is a reducer UDO used In this U-SQL script, is there an approach to pass the parameter to the reducer to use it in the public override IEnumerable<IRow> Reduce(IRowset input, IUpdatableRow output) function?

     

    Thanks,

    Roger Rong

    Friday, October 28, 2016 6:37 PM

Answers

  • Hi Roger

    As in the case of Extractors and other UDOs, you put the parameterization into the class constructor.

    Here is a link that shows it for an Extractor, but a Reducer would work the same way.


    Michael Rys

    • Marked as answer by Roger Rong NZ Friday, October 28, 2016 7:38 PM
    Friday, October 28, 2016 6:54 PM
    Moderator

All replies

  • Hi Roger

    As in the case of Extractors and other UDOs, you put the parameterization into the class constructor.

    Here is a link that shows it for an Extractor, but a Reducer would work the same way.


    Michael Rys

    • Marked as answer by Roger Rong NZ Friday, October 28, 2016 7:38 PM
    Friday, October 28, 2016 6:54 PM
    Moderator
  • Thanks Micheal.

    That is exactly what I want to do. In our example we should pass that parameter to the using clause like:

    USING new MyNameSpace.MyReducer(@START_TIME);

    And put the parameter in the reducer constructor:

    public class MyReducer: IReducer
        {

        public MyReducer(DateTime startTime)

       {

    ...

    ...

        }

    ...

    }

    Friday, October 28, 2016 7:38 PM