Removing tuples with the same elements in lists

Comments

4 comments

  • Official comment
    Joel Stewart

    Thanks for the additional details Tim and for confirming that you have already made considerations about the sorting to ensure consistent results.

    In this particular scenario, I'd recommend using the GROUP_PATH_CHANGES function.

    Comment actions Permalink
  • Joel Stewart

    There appears to be an implied assumption in your proposed use-case. Specifically, using the GROUPBY and GROUPCONCAT functions does not guarantee the order of the results between steps. The results may shift order as they are distributed and may complete at different times. 

    For this reason, the GROUPCONCATDISTINCT function is recommended here because it will search globally for duplicates and only return one record per instance. 

    If a use case requires the order of the rows to be maintained explicitly, be sure to use a function such as GROUP_SORT_ASC to maintain the precise ordering. 

    Does this use case require that order be maintained? 

    0
    Comment actions Permalink
  • Tim

    Thanks for the answer and for the suggestion Joel!

    In fact I have a sorting variable (date) and applied it now on the GROUPCONCAT function sorting the table beforehand by date.

    The problem remains. For further explanation: Imagine these lists as paths through a network where I want to remove the hops to the same location where the subject already is:

    [a,a,a] -> [a]

    [a,b,b,b,a] -> [a,b,a]

    0
    Comment actions Permalink
  • Tim

    Thanks a lot Joel, now I have every path for 2 successive elements. Finally I want to merge them by their owner to get a full path per owner:

    owner 1: [a,a,a] -> [a]

    owner 2: [a,b,b,b,a] -> [a,b,a]

     

    How can I achieve that? Is there a merge path function or so?

    Thanks again!

    0
    Comment actions Permalink

Please sign in to leave a comment.