Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Azure-Samples/usql-named-lambda-functions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

services platforms author
data-lake-analytics
dotnet
saveenr

U-SQL named lambda functions

Simple one-line lambda

DECLARE @myToUpper Func<string, string> = (s) => s.ToUpper();

@searchlog = 
    EXTRACT UserId          int, 
            Start           DateTime, 
            Region          string, 
            Query           string, 
            Duration        int, 
            Urls            string, 
            ClickedUrls     string
    FROM @"/Samples/Data/SearchLog.tsv"
    USING Extractors.Tsv();

@searchlog = 
    SELECT Query, 
    @myToUpper(Query) AS QueryUpper
    FROM @searchlog;
    
OUTPUT @searchlog 
    TO @"/Samples/Output/SearchLog_output.tsv"
    USING Outputters.Tsv();

Multi-line lambda

DECLARE @myToUpper2 Func<string, string> = (s) => 
    {
        if (s.Length == 0 ) { throw new System.ArgumentException(); }
        s = s.Trim();
        s = s.ToUpper();
        return s;
    };

//Define schema of file, must map all columns
@searchlog = 
    EXTRACT UserId          int, 
            Start           DateTime, 
            Region          string, 
            Query           string, 
            Duration        int, 
            Urls            string, 
            ClickedUrls     string
    FROM @"/Samples/Data/SearchLog.tsv"
    USING Extractors.Tsv();

@searchlog = 
    SELECT Query, 
    @myToUpper2(Query) AS QueryUpper
    FROM @searchlog;
    
OUTPUT @searchlog 
    TO @"/Samples/Output/SearchLog_output.tsv"
    USING Outputters.Tsv();

About

How to use named lambda functions with U-SQL

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published