U-SQL’s tight integration with C#’s expression language normally makes calls to C# expression seamless. On rare occasions it may be useful to be able to guard a C# expression from getting interpreted by U-SQL, such as when a new version of C# may introduce a syntax that conflicts with an established U-SQL syntax or when the C# expression needs to turn off U-SQL name binding or U-SQL reserved keywords in the expression.


CSHARP_Expression :=                                                                                     
    'CSHARP' '(' expression ')'.


  • expression
    The C# expression to be guarded as pure C# expression without U-SQL name resolutions or syntax interpretations.

Return Type

Polymorphic based on the expression’s type.


  • The examples can be executed in Visual Studio with the Azure Data Lake Tools plug-in.
  • The scripts can be executed locally. An Azure subscription and Azure Data Lake Analytics account is not needed when executed locally.
  • The examples below are based on the dataset defined below. Ensure your execution includes the rowset variable.


@aCircle = 
        ( VALUES
        ) AS T(radius);

The following query fails because PI is an uppercase name and thus a reserved keyword:

@result =
    SELECT Math.PI * radius * radius AS Area
    FROM @aCircle; 

The CSHARP function turns off the keyword reservation and allows to use PI:

@result =
    SELECT CSHARP(Math.PI) * radius * radius AS Area
    FROM @aCircle;

OUTPUT @result
TO "/Output/ReferenceGuide/Operators/Other/csharp1.txt"
USING Outputters.Csv();

See Also