Hitachi Vantara Pentaho Community Forums
Results 1 to 6 of 6

Thread: Sort Step and NULLS

  1. #1

    Default Sort Step and NULLS

    When I sort by a given column, nulls are always placed first. Is there any way to change this behavior?

  2. #2

    Default

    Think how can you separate the stream, sort in a way you want and then merge the streams...

  3. #3

    Default

    Thanks George, but I was thinking more about some kettle config property.

  4. #4

    Default

    Hi,

    I think it's an in-built java Collections method that does the actual sorting so not something you can configure. You could just replace the nulls with an appropriately high value before sorting (and reset it afterwards if necessary.)
    Regards,

    Mark, Cloud2Land

    http://www.cloud2land.com

  5. #5

    Default

    Yep, this thing looks promising
    field ==null ? "ZZZZZZZ" : field --> sort --> "ZZZZZZZ".equalsIgnoreCase(field) ? new String() : field
    There could be a pitfall with the chosen value... but

    Thanks both

  6. #6
    Join Date
    Nov 1999
    Posts
    9,729

    Default

    To sort field A nulls first you can also create an extra field B that contains false if A is null and true otherwise. Then sort on B, A ascending and you should get what you want.

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 - 2019 Hitachi Vantara Corporation. All Rights Reserved.