Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]

Support Questions

Find answers, ask questions, and share your expertise
Announcements
Share your experience with Cloudera on G2 and get a $25 Amazon Gift card.
Hi, I'm CLEO! Something exciting is coming to the Community. Stay Tuned!

Jolt transform

avatar
Explorer

Hello everyone! I need a help in Jolt transform.

I have array, that consist from many json objects. (https://jolt-demo.appspot.com/ )
1.png

 

[

  {
     "table_name": "table_vd",
     "scratch_name": "l1_sample_1_1",
     "scratch_order": 1
  },
  {
     "table_name": "table_vd",
     "scratch_name": "l1_sample_1_1",
     "scratch_order": 34
  },
  {
     "table_name": "table_vd",
     "scratch_name": "l1_sample_2",
     "scratch_order": 3
  }
]

 

 

What transformation of Jolt needs to be done to get the following result?

4.png

 

Now i have next Jolt construction.

2.png

 

[
  {
     "operation": "shift",
     "spec": {
        "*": {
           "table_name": "table_name",
           "*": { "@0": "data[0].&1" }
        }
     }
  }
]

 

 

But the result is not correct.

3.png

 

1 ACCEPTED SOLUTION

avatar
Explorer

This task has been successfully solved! The required Jolt construction is shown below.

solution.png

 

[
  {

     "operation": "shift",
     "spec": {
       "*": {
         "table_name": "&",
         "*": "data[&1].&"
       }
     }
  },
  { 
     "operation": "cardinality",
     "spec": {
       "table_name": "ONE"
     }
  }
]

View solution in original post

1 REPLY 1

avatar
Explorer

This task has been successfully solved! The required Jolt construction is shown below.

solution.png

 

[
  {

     "operation": "shift",
     "spec": {
       "*": {
         "table_name": "&",
         "*": "data[&1].&"
       }
     }
  },
  { 
     "operation": "cardinality",
     "spec": {
       "table_name": "ONE"
     }
  }
]