Hitachi Vantara Pentaho Community Forums
Results 1 to 4 of 4

Thread: how to concatenate 100 output rows into one output row

  1. #1
    Join Date
    Jun 2016
    Posts
    6

    Default how to concatenate 100 output rows into one output row

    I have database rows from a table input step that produces one JSON document per row.
    What I want to do is to concatenate `100 rows at a time with a comma delimiter and write 1 row out, then
    process the next 100 rows, then the remainder if any.

    I've been trying UDJC but abandoned that in favor of modified javascript step but am not sure how to achieve this.

  2. #2
    Join Date
    Feb 2017
    Posts
    5

    Default

    Hi Chris,

    You can accomplish this with a sequence, integer division, and a group by:
    1. add an incremental sequence to the incoming database rows (you can do this with the "Add Sequence" step or using SQL) - make sure the sequence starts at zero!
    2. use the calculator step to
      1. define a constant value group_size variable set to 100 (integer data type)
      2. define a json_group variable as sequence / group_size (integer data type - use the A / B calculation)

    3. use Group By step:
      1. group by json_group
      2. aggregate your json rows as the "Subject" in the "Aggregates" section. Name the result whatever you like, and use the "Concatenate strings separated by ," as the "Type" selection.

  3. #3
    Join Date
    Jun 2016
    Posts
    6

    Default

    Thanks rgardner, I'll try it out - looks good

  4. #4
    Join Date
    Jun 2016
    Posts
    6

    Default

    Woks great, thanks again

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2017 Pentaho Corporation. All Rights Reserved.