microsoft / Kusto-Query-Language

Kusto Query Language is a simple and productive language for querying Big Data.
Apache License 2.0
510 stars 97 forks source link

Predictable naming when joining #135

Closed Bouke closed 1 month ago

Bouke commented 5 months ago

Say I have an Application Insights query like the following:

dependencies
| join kind=leftouter (traces | summarize take_any(customDimensions) by operation_ParentId) on $left.id == $right.operation_ParentId
| join kind=leftouter (traces | where condition | summarize take_any(customDimensions) by operation_ParentId) on $left.id == $right.operation_ParentId
| where customDimensions2['foo'] == 'bar'

My resultset will have columns customDimensions, customDimensions1 and customDimensions2.

However when I make a change to the first join so that it doesn't return a column named customDimensions, my resultset will no longer have a column customDimensions2 and what was customDimensions2 will now be in customDimensions1. As a user this is very confusing. Making a change to the first join affects other parts of the query that didn't operate on the data from this join, like customDimensions2.

This makes writing and refactoring queries very hard and error-prone. I'd like to see a way to refer to a column by some stable identifier. For example give the columns from a join a user-defined prefix: join ... as join_2 -> join2_customDimensions.

rolfgreven-tomtom commented 5 months ago

Have you considered using the project-rename operator – within the joins – to prevent duplicate column names so that the issue you experience won't happen.