Topic: How to use project operator to select required columns in Kusto Query Language
In this article, we are going to learn about project Operator so it is very important for us to select the required data from a table sometimes we need to select a couple of columns sometimes we need to select all the columns except a few of them so with the projector it give us all those different options that we can use to select the required data from the table and especially this is a happening as you have hundreds of columns sometimes in a table or even you know let's say you even have your 50 columns but still get to very messy when you need to select a few of them and then exclude some of them, Kusto Query Language is a powerful tool to explore your data and discover patterns, identify anomalies and outliers, create statistical modeling, and more. The query uses schema entities that are organized in a hierarchy similar to SQL's: databases, tables, and columns.
//project -- Select the columns to include, rename or drop, and insert new computed columns.
//
//Let's create a table Customer
//.drop table Customer
.create table Customer (CustomerId: long, FName: string,LName:string, Salary:int,hiredate:datetime)
.ingest inline into table Customer <|
1,Aamir,Shahzad,2000,2021-11-28T04:52:43.8745893Z
2,Raza,ALI,4000,2018-11-28T04:52:43.8745893Z
3,Lisa,Rivers,50000,2021-12-28T04:52:43.8745893Z
4,steve,Ladson,1000,2010-09-28T04:52:43.8745893Z
5,Robert,Jr,500,2015-01-20T04:52:43.8745893Z
6,aamir,ali,1000,2005-03-01T04:52:43.8745893Z
// project
Customer
//Add some new derived Columns
Customer
| project CustomerId,FirstName=FName,FullName=strcat(FName,' ',LName)
//Exclude the columns by using project-away
Customer
| project-away hiredate,Salary
// Provide the list of Columns you want to keep, it is different from project as derived columns does not work
Customer
| project-keep *Name,CustomerId
// Get all the columns and Rename the once you want
Customer
| project-rename FirstNAme=FName,LastName=LName
//project-reorder, it reorder the columns which you want and leave the rest as is.
Customer
| project-reorder hiredate,Salary
We'll provide you with a custom-written How To Cook Steak In Cast Iron Skillet
ReplyDeletelow-cost, well-researched, plagiarism-free paper that will impress both you and your professors.
This comment has been removed by the author.
ReplyDelete