none
USQL- Pass Filename from Usql script to Custom Extractor in Extract statement

    Question

  • Hi,

    I wrote a custom extractor to check a static schema with input file first row. Below is the code sample for the same:

    @config= "schema";

    @data =
        EXTRACT col1 string,
                col2 string,
                col3 string,
                col4 string,
                col5 string,
                filename string
        FROM @input
        USING new USQLApplication.CustomExtractor(@config);

    I want to pass the filename to the CustomExtractor. In extractor the filename is declared but cannot be passed as parameter to CustomExtractor Constructor.

    As of now when I debug the code, the IUnstructuredReader contains only BaseStream & Length as its properties. I cannot get filename as data while debug.

    Is there any way, to how I would get the filename in CustomExtractor ,while each row is read?

    Also can I add more extra columns in Extract statement and set them from CustomExtractor?

    for e.g.

    EXTRACT col1 string,
                col2 string,
                col3 string,
                col4 string,
                col5 string,

               IsValid string, 

               ErrorMessage string, 

               filename string

         FROM @input
        USING new USQLApplication.CustomExtractor(@config);

    Is there any way to achieve this scenario?

    Thank You


    Thursday, March 16, 2017 1:47 PM