question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add a `Join-Object` cmdlet to the standard PowerShell equipment

See original GitHub issue

As the verb-noun convention suggests, I think that there are a lot of developers looking for a common way to join objects (lists). See StackOverflow: In Powershell, what’s the best way to join two tables into one? Personally, I am convinced that a Join-Object cmdlet will generally result in a better syntax were an object (list) join is required (in comparison with alternative cmdlets along with Group-Object) and better performance (then using obvious iterators like ForEach-Object together with Where-Object or similar cmdlets and methods). For that reason I am maintaining a Join-Object script/module for more than 3 years now. I don’t think that my Join-Object version should be added to the standard PowerShell package (for one thing, it is written in PowerShell and not C# 🤔), but it might serve as an example for what I would expect from a syntax that comes together with a Join-Object cmdlet.

What do I expect from a “internal” Join-Object cmdlet?

  • An intuitive idiomatic PowerShell syntax The syntax should be PowerShell like and include features similar to the SQL Join clause where it basically joins (a list of) objects or items based on related properties (-On parameter) or a simple side-by-side list join (by omitting the -On parameter) as a specific PowerShell cmdlet feature (see: #14732) .
  • Ability to do similar Join types as SQL, along with InnerJoin, LeftJoin, RightJoin, FullJoin
  • Ability to join based on multiple property relations, e.g.: -On Column1, Column2
  • Smart property merging (e.g. if a properly is defined as related, it should only appear ones in the result)
  • Respect the PowerShell pipeline (for the left object supplied through pipeline)
  • A reasonable performance by using a binary search (HashTable) on the right object (knowing that it needs to be iterated multiple times). Also note the Linq Join-Object solution by @ili101
  • Calculated properties

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:28
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
mklement0commented, Mar 11, 2021

An aside re:

And it could even prevent to invest too much in traditional operators as shown here.

As I’ve argued in detail in https://github.com/PowerShell/PowerShell/issues/14724#issuecomment-777801399, there is no reason to pit cmdlet-based solutions against expression / statement-based solutions: both are necessary, and in certain cases use of one over the other is the only option. Instead, we should strive for feature parity, to the extent that is feasible.

2reactions
chenxizhangcommented, Apr 11, 2023

vote for this feature

Read more comments on GitHub >

github_iconTop Results From Across the Web

Join-Object - PowerShell Team
There is no built-in cmdlet for joining in Windows PowerShell, so the remainder of this post will be about building a cmdlet called...
Read more >
Connect data with PowerShell's Join-Object module
Looking to join different data sets in PowerShell? Use the community module Join-Object to connect separate, unrelated objects.
Read more >
How to perform "INNER JOIN" of powershell objects?
Join data from two sets of objects based on a common value. ... to Add a Join-Object cmdlet to the standard PowerShell equipment...
Read more >
In PowerShell, what's the best way to join two tables into ...
Join -Object ... Combines two object lists based on a related property between them. ... Combines properties from one or more objects. It...
Read more >
Join-Object - Power$nippets
Join -Object. Combines two object lists based on a related property between them. Combines properties from one or more objects. It creates a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found