1
votes

I want to add a auto generated column in my U-SQL select stamen. how can we do.

same like identity column in SQL server

Regards, Manish

1

1 Answers

1
votes

The closest would be ROW_NUMBER. Here is a simple example:

@output =
    SELECT 
        ROW_NUMBER() OVER () AS rn,
        *
    FROM @input;

You cannot use ROW_NUMBER directly with EXTRACT at this time. Simply extract the data first then add the row number in a subsequent section, like this:

// Get raw input
@input =
    EXTRACT rawData string
    FROM "/input/yourFile.txt"
    USING Extractors.Tsv();


// Add a row number
@working =
    SELECT ROW_NUMBER() OVER() AS rn,
           *
    FROM @input;