-
Notifications
You must be signed in to change notification settings - Fork 104
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
[JSON] Support Rename Fields for JSON operator #1133
Comments
I am interested. Can I work on this issue? |
Hello @Danbaba1, sure I have assigned this ticket to you! 🙌 |
Hey @Danbaba1 I have removed you as an assignee because there is no activity for the past 2 weeks 🙏 Please raise again if you are still working on it, thanks |
I would like to give a try for this issue. Can you please assign me? |
@AkashJana18 Sounds good, I have assigned it to you! |
Hey @chuang8511 @ShihChun-H Could you please guide me on where to make the changes for implementing JSON manipulation with the JsonOperator schema? I haven’t worked with this tech stack before, so any pointers on relevant files, modules, or general structure would be very helpful. Thanks in advance! |
I would like to work on this issue. Can you please assign it to me. |
Hey @gagan-bhullar-tech I am already working on it would you like to collaborate? |
@AkashJana18 Could you take a look on this? We have built the task definition. So, what you only have to do is working on Golang implementation. |
@chuang8511 so the Golang Implementation needs to be done in pipeline-backend repo? |
@AkashJana18 |
Issue Description
Current State
Proposed Change
JSON schema pseudo code
Key Features:
conflictResolution
: Handling conflicts when renaming fields in JSON, especially when working with nested objects and dot notation, is critical to avoid data loss or unexpected behavior. Allow users to specify how they want conflicts to be resolved (e.g., via a parameter such asconflictResolution: 'overwrite'|'skip'|'error'
),Here are different strategies to manage conflicts and some considerations for each.
1. Overwrite the Existing Field (Default Behavior)
Description: If the
newField
already exists in the object, overwrite its value with the value fromcurrentField
.Pros:
Cons:
Implementation:
2. Skip the Renaming Operation
Description: If the
newField
already exists, skip the renaming operation for that particular field.Pros:
Cons:
Implementation:
3. Merge Values
Description: If both
currentField
andnewField
exist and contain objects or arrays, merge the two values. This approach is more complex but can be very powerful.Pros:
Cons:
currentField
andnewField
differ.Implementation:
4. Rename with a Suffix or Prefix
Description: If the
newField
already exists, rename the new field by appending a suffix or prefix (e.g.,_1
,_conflict
) to avoid conflicts.Pros:
Cons:
Implementation:
5. Return an Error or Warning
Description: If a conflict is detected, stop the operation and return an error or warning to the user. This forces the user to address the conflict before proceeding.
Pros:
Cons:
Implementation:
Summary:
Choose the strategy that best aligns with your application's needs and the user's expectations. Implementing a combination of these strategies, such as providing a default behavior with options for customization, can offer the best balance between usability and robustness.
Example Usage:
Scenario: Input data as JSON object
// input
{
"data": {
"name": "John Doe",
"age": 30,
"address": {
"street": "123 Main St",
"city": "Anytown",
"state": "CA"
},
"state": "conflict"
},
"fields": [
{"currentField": "address.street", "newField": "address.road"},
{"currentField": "state", "newField": "address.state"}
],
// "supportDotNotation": true,
"conflictResolution": "overwrite"
}
Conflict Resolution Scenarios:
1. Overwrite (Default):
2. Skip:
3. Error:
address.state
already exists.ValueError: Conflict detected: 'address.state' already exists.
Scenario: Input Data as an Array of Objects
If the input data is an array of objects, the logic needs to be adapted to handle each object in the array individually. The schema and the function would process each object within the array according to the specified fields and
conflictResolution
rules.Below is an example demonstrating how the "Rename Fields" operation would work with input data that is an array of objects.
Input
Explanation:
Output:
Rules for the Component Hackathon
Component Contribution Guideline | Documentation | Official Go Tutorial
The text was updated successfully, but these errors were encountered: