Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.8.0
    • Component/s: Function/UDF
    • Labels:
      None

      Description

      find_in_set(str,str_array) - Returns the first occurrence of str in str_array where str_array is a comma-delimited string.
      Returns null if either argument is null. Returns 0 if the first argument has any commas.

      Example:
      "select find_in_set('cr','crt,c,cr,c,def') as col1 "
      -> result: 3

      1. TAJO-381.2.patch
        6 kB
        Jae Young Lee
      2. TAJO-381.patch
        6 kB
        Jae Young Lee

        Activity

        Hide
        hudson Hudson added a comment -

        SUCCESS: Integrated in Tajo-trunk-postcommit #647 (See https://builds.apache.org/job/Tajo-trunk-postcommit/647/)
        TAJO-381: Implement find_in_set function. (Jae Young Lee via hyunsik) (hyunsik: https://git-wip-us.apache.org/repos/asf?p=incubator-tajo.git&a=commit&h=4c7579009c137570ecc412d1365ace77fbbd4b87)

        • tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/master/TajoMaster.java
        • tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/function/TestStringOperatorsAndFunctions.java
        • tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/eval/ExprTestBase.java
        • tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/function/string/FindInSet.java
        • CHANGES.txt
        Show
        hudson Hudson added a comment - SUCCESS: Integrated in Tajo-trunk-postcommit #647 (See https://builds.apache.org/job/Tajo-trunk-postcommit/647/ ) TAJO-381 : Implement find_in_set function. (Jae Young Lee via hyunsik) (hyunsik: https://git-wip-us.apache.org/repos/asf?p=incubator-tajo.git&a=commit&h=4c7579009c137570ecc412d1365ace77fbbd4b87 ) tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/master/TajoMaster.java tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/function/TestStringOperatorsAndFunctions.java tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/eval/ExprTestBase.java tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/function/string/FindInSet.java CHANGES.txt
        Hide
        hyunsik Hyunsik Choi added a comment -

        committed it to master branch. Thanks!

        Show
        hyunsik Hyunsik Choi added a comment - committed it to master branch. Thanks!
        Hide
        hyunsik Hyunsik Choi added a comment -

        +1
        That's nice work. I've changed the issue title for more explanation. In addition, I added more unit tests for find_in_set function. Thank you guys for your contribution and the reviews.

        Show
        hyunsik Hyunsik Choi added a comment - +1 That's nice work. I've changed the issue title for more explanation. In addition, I added more unit tests for find_in_set function. Thank you guys for your contribution and the reviews.
        Hide
        goodljy Jae Young Lee added a comment -

        Thanks Henry and DaeMyung Kang.
        I've changed the variable names by using use camel case.
        Please review it.

        Show
        goodljy Jae Young Lee added a comment - Thanks Henry and DaeMyung Kang. I've changed the variable names by using use camel case. Please review it.
        Hide
        hsaputra Henry Saputra added a comment -

        Small nit on style, could you use camel case for variable names so instead of pos_in_textarray but do positionInTextArray ?

        Show
        hsaputra Henry Saputra added a comment - Small nit on style, could you use camel case for variable names so instead of pos_in_textarray but do positionInTextArray ?
        Hide
        charsyam DaeMyung Kang added a comment -

        "mvn clean install" is OK.
        and I tested with mysql

        testSimpleEval("select find_in_set('c',',c,,,') as col1 ", new String[]

        {"2"}

        ;

        and

        MariaDB [test]> select find_in_set('c',',c,,,,,');
        ----------------------------

        find_in_set('c',',c,,,,,')

        ----------------------------

        2

        ----------------------------

        it is also ok.
        This patch looks good to me.

        Hyunsik ChoiJae Young Lee
        Does tajo just handle string as UTF-8?

        I just worried one thing. when some strings are in different encodings. event though, they are different but
        byte arrays are same.(It is just my guessing.)

        Show
        charsyam DaeMyung Kang added a comment - "mvn clean install" is OK. and I tested with mysql testSimpleEval("select find_in_set('c',',c,,,') as col1 ", new String[] {"2"} ; and MariaDB [test] > select find_in_set('c',',c,,,,,'); ---------------------------- find_in_set('c',',c,,,,,') ---------------------------- 2 ---------------------------- it is also ok. This patch looks good to me. Hyunsik Choi Jae Young Lee Does tajo just handle string as UTF-8? I just worried one thing. when some strings are in different encodings. event though, they are different but byte arrays are same.(It is just my guessing.)
        Hide
        goodljy Jae Young Lee added a comment -

        I've attached a patch file for this issue.
        Please review it.

        Show
        goodljy Jae Young Lee added a comment - I've attached a patch file for this issue. Please review it.

          People

          • Assignee:
            goodljy Jae Young Lee
            Reporter:
            goodljy Jae Young Lee
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development