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

feat: Add SetKey Support to Expand Processor #81

Merged
merged 1 commit into from
Mar 1, 2023
Merged

Conversation

jshlbrd
Copy link
Contributor

@jshlbrd jshlbrd commented Mar 1, 2023

Description

  • Adds SetKey support to the Expand processor

Motivation and Context

Some data sources have complex object structures with either deeply nested arrays of objects or multiple layers of arrays of objects. For example:

{
	"a": {
		"b": {
			"c": [{
				"d": "e"
			}],
			"h": {
				"i": 1
			}
		}
	},
	"j": {
		"k": 1
	}
}

The processor currently pushes { "d": "e" } to the top of the object like this:

{
	"d": "e",
	"a": {
		"b": {
			"h": {
				"i": 1
			}
		}
	},
	"j": {
		"k": 1
	}
}

This makes it nearly impossible to modify the structure of the object after the processor runs because the content of the array is dynamic. This change adds SetKey support which makes this possible (if the SetKey is "x.y"):

{
	"a": {
		"b": {
			"h": {
				"i": 1
			}
		}
	},
	"j": {
		"k": 1
	},
	"x": {
		"y": {
			"d": "e"
		}
	}
}

This has some other benefits, like making the expansion of non-object arrays possible.

How Has This Been Tested?

Refactored and added new unit tests.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@jshlbrd jshlbrd marked this pull request as ready for review March 1, 2023 15:21
@jshlbrd jshlbrd requested a review from a team as a code owner March 1, 2023 15:21
@jshlbrd jshlbrd merged commit 5419f5e into main Mar 1, 2023
@jshlbrd jshlbrd deleted the jshlbrd/expand-setkey branch March 1, 2023 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants