Use string text from file in u-sql query where clause ( U-SQL )

631 views Asked by At

I need load some text from one file and choose specific records from another where one of second file columns is equalt to text loaded from first file.

I'm trying with something like that but actually it doesn't work.

@countryName =
    EXTRACT City string
    FROM "/TestCatalog/test.txt"
    USING Extractors.Text();

@result =
    SELECT CityName,
           Temperature,
           MeasurmentDate
    FROM @readEmployee
    WHERE CityName IN(@countryName);

What is the best way to pass some parameters to where expression ( readed from another file in azure data lake ) ?

2

There are 2 answers

5
wBob On BEST ANSWER

Variables in U-SQL which are assigned to with EXTRACT or SEELCT are rowsets, rather than scalar variables. Therefore use SEMIJOIN to do this, for example:

@output =
    SELECT re.CityName,
           re.Temperature,
           re.MeasurmentDate
    FROM @readEmployee AS re
            SEMIJOIN @countryName AS c ON re.CityName == c.City;
0
Alexandre Gattiker On

EXTRACT this other file into another rowset, and JOIN both rowsets together.