Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discern merged properties for multiple joins #16

Closed
iRon7 opened this issue Mar 10, 2021 · 2 comments
Closed

Discern merged properties for multiple joins #16

iRon7 opened this issue Mar 10, 2021 · 2 comments
Assignees

Comments

@iRon7
Copy link
Owner

iRon7 commented Mar 10, 2021

In case multiple joins are chained, I would like to be able to separate/discern/rename the merged properties in once in the last cmdlet in the chain.

Example:

$AAA = ConvertFrom-Csv @'
Number,Name,Domain
Z001,ABC,Domain1
Z002,DEF,Domain2
Z003,GHI,Domain3
'@

$BBB = ConvertFrom-Csv @'
Number,Name,Domain
Z001,ABC,Domain1
Z002,JKL,Domain2
Z004,MNO,Domain4
'@

$CCC = ConvertFrom-Csv @'
Number,Name,Domain
Z005,PQR,Domain2
Z001,ABC,Domain1
Z001,STU,Domain2
'@

$DDD = ConvertFrom-Csv @'
Number,Name,Domain
Z005,VWX,Domain4
Z006,XYZ,Domain1
Z001,ABC,Domain3
'@

$AAA |FullJoin $BBB -On Number |FullJoin $CCC -On Number |FullJoin $DDD -On Number -Discern *1,*2,*3,*4 | ft

Number Name1 Name2 Name3 Name4 Domain1 Domain2 Domain3 Domain4
------ ----- ----- ----- ----- ------- ------- ------- -------
Z001   ABC   ABC   ABC   ABC   Domain1 Domain1 Domain1 Domain3
Z001   ABC   ABC   STU   ABC   Domain1 Domain1 Domain2 Domain3
Z002   DEF   JKL               Domain2 Domain2
Z003   GHI                     Domain3
Z004         MNO                       Domain4
Z005               PQR   VWX                   Domain2 Domain4
Z006                     XYZ                           Domain1
@iRon7 iRon7 self-assigned this Mar 10, 2021
@iRon7
Copy link
Owner Author

iRon7 commented Mar 10, 2021

The implementation of this feature implies that the -Discern parameter is longer mutually exclusive with the -Property parameter as the -Discern feature comes on top of the -Property feature. Meaning that a -Discern argument could potentially alter a defined -Property argument again (assuming that it has some merged properties).
Anyways, I have removed the mutually exclusive parametersets between the two parameters meaning that is now possible to use both at at the same time although I would recommend against doing so without a founded reason.

Note that the argument list of the -Discern parameter is right aligned, meaning that the last string in the -Discern list will be used on the last object property added to the |Join ... chain. The secondlast String to the secondlast object property and so on. The rest (in case there are less -Discern strings then object properties / chained Join cmdlets) of the object properties will put in an array and added to the original name of the concerned property.

iRon7 added a commit that referenced this issue Mar 11, 2021
iRon7 added a commit that referenced this issue Mar 11, 2021
@iRon7
Copy link
Owner Author

iRon7 commented Mar 11, 2021

Implemented in version 3.4.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant