Home > OS >  How to convert T-SQL NOT IN Query into KQL and limit batch size with parameter in C#
How to convert T-SQL NOT IN Query into KQL and limit batch size with parameter in C#

Time:03-24

I am currently working on ADX and need to convert following SQL query into KQL

SELECT UserId, Column2, Column3 from Table1 t
where t.UserId NOT IN (Select UserId from Table2)
and t.Type = 'Something'

I also need to limit the result set with some configurable batch size parameter that would be pass from .net core function app using following code in C# so that it's not returning billions of records to application

        using (var queryProvider = KustoClientFactory.CreateCslQueryProvider(kustoConnectionStringBuilder))
        {
            var query = "Table1  | count";

            using (var reader = queryProvider.ExecuteQuery(Database, query,null))
            {
                while (reader.Read())
                {
                   // Console.WriteLine(reader);
                    
                }
            }
        }

CodePudding user response:

To get started with SQL to KQL translation you can use the "explain" command, see more here

As for passing the size parameter, you can append to the query text in the code "| take X" (where X is the number of records), or you can use query parameters.

  • Related