Details

    • Type: New Feature
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 0.8.0
    • Fix Version/s: 0.8.0
    • Component/s: None
    • Labels:
      None

      Description

      I'd like to lmplement this function.
      Plz assign to me

      1. TAJO-359_1.patch
        5 kB
        Seungun Choe
      2. TAJO-359_2.patch
        5 kB
        Seungun Choe
      3. TAJO-359_3.patch
        5 kB
        Seungun Choe
      4. TAJO-359_4.patch
        6 kB
        Seungun Choe
      5. TAJO-359_5.patch
        5 kB
        Seungun Choe
      6. TAJO-359.patch
        5 kB
        Seungun Choe

        Activity

        Hide
        seungunchoe Seungun Choe added a comment -

        Here is my patch for lpad.
        I confirmed with mvn, and there is no problem.

        Show
        seungunchoe Seungun Choe added a comment - Here is my patch for lpad. I confirmed with mvn, and there is no problem.
        Hide
        blrunner Jaehwa Jung added a comment -

        'mvn clean install' failed.
        I found error messages as follows:

        Failed tests:   testlpad(org.apache.tajo.engine.function.TestStringOperatorsAndFunctions): select lpad('hi', 5, 'xy')  expected:<[hixyx]> but was:<[xyxhi]>
        
        Tests run: 417, Failures: 1, Errors: 0, Skipped: 0
        
        Show
        blrunner Jaehwa Jung added a comment - 'mvn clean install' failed. I found error messages as follows: Failed tests: testlpad(org.apache.tajo.engine.function.TestStringOperatorsAndFunctions): select lpad('hi', 5, 'xy') expected: <[hixyx]> but was: <[xyxhi]> Tests run: 417, Failures: 1, Errors: 0, Skipped: 0
        Hide
        seungunchoe Seungun Choe added a comment -

        I sorry, I have some mistake.
        re-attach new patch file.

        Show
        seungunchoe Seungun Choe added a comment - I sorry, I have some mistake. re-attach new patch file.
        Hide
        seungunchoe Seungun Choe added a comment -

        TAJO-359_1 test case function name is lpad
        So, Changed testLpad();

        Show
        seungunchoe Seungun Choe added a comment - TAJO-359 _1 test case function name is lpad So, Changed testLpad();
        Hide
        seungunchoe Seungun Choe added a comment -

        same issue, TAJO-361(rpad)
        I fixed issue, and repatched.

        Show
        seungunchoe Seungun Choe added a comment - same issue, TAJO-361 (rpad) I fixed issue, and repatched.
        Hide
        blrunner Jaehwa Jung added a comment -

        Thank you for your contribution.
        Your patch operates successfully.

        Well, How about use byte array?
        If it is used on lots of data, byte array will make good performance compare to string type.

        Show
        blrunner Jaehwa Jung added a comment - Thank you for your contribution. Your patch operates successfully. Well, How about use byte array? If it is used on lots of data, byte array will make good performance compare to string type.
        Hide
        hyunsik Hyunsik Choi added a comment -

        I would like to suggest org.apache.commons-lang.StringUtils::leftPad().

        Show
        hyunsik Hyunsik Choi added a comment - I would like to suggest org.apache.commons-lang.StringUtils::leftPad().
        Hide
        sirpkt Keuntae Park added a comment - - edited

        However, it looks that org.apache.commons-lang.StringUtils::leftPad() works differently from lpad() specified in http://www.postgresql.org/docs/9.1/static/functions-string.html
        When the string is longer than the given length, lpad() truncates the string but org.apache.commons-lang.StringUtils::leftPad() just returns the string (http://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/StringUtils.html#leftPad(java.lang.String,%20int,%20java.lang.String).

        Show
        sirpkt Keuntae Park added a comment - - edited However, it looks that org.apache.commons-lang.StringUtils::leftPad() works differently from lpad() specified in http://www.postgresql.org/docs/9.1/static/functions-string.html When the string is longer than the given length, lpad() truncates the string but org.apache.commons-lang.StringUtils::leftPad() just returns the string ( http://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/StringUtils.html#leftPad(java.lang.String,%20int,%20java.lang.String ).
        Hide
        hyunsik Hyunsik Choi added a comment -

        truncate was already implemented in this patch by 'if then' condition. We could just replace string concatenations with StringUtils::leftpad.

        Show
        hyunsik Hyunsik Choi added a comment - truncate was already implemented in this patch by 'if then' condition. We could just replace string concatenations with StringUtils::leftpad.
        Hide
        seungunchoe Seungun Choe added a comment -

        In PostgreSQL, select lpad('test', 3, '1'); result is tes;
        but using StringUtils.leftPad() case, there is different result.

        • testSimpleEval("select LPAD('hello', 3, 'xy') ", new String[] {"hel"}

          );
          --> org.junit.ComparisonFailure: select LPAD('hello', 3, 'xy')
          --> Expected :hel
          --> Actual :hello

        plz, check this issue.

        Show
        seungunchoe Seungun Choe added a comment - In PostgreSQL, select lpad('test', 3, '1'); result is tes; but using StringUtils.leftPad() case, there is different result. testSimpleEval("select LPAD('hello', 3, 'xy') ", new String[] {"hel"} ); --> org.junit.ComparisonFailure: select LPAD('hello', 3, 'xy') --> Expected :hel --> Actual :hello plz, check this issue.
        Hide
        seungunchoe Seungun Choe added a comment -

        Attached patch file.
        I think byte array has some problem about uni-code.
        So, I used StringUtils and if with substring.
        plz confirm my patch.

        Show
        seungunchoe Seungun Choe added a comment - Attached patch file. I think byte array has some problem about uni-code. So, I used StringUtils and if with substring. plz confirm my patch.
        Hide
        seungunchoe Seungun Choe added a comment -

        fixed some git using issue(ref-TAJO-361)
        fixed some value name.

        Show
        seungunchoe Seungun Choe added a comment - fixed some git using issue(ref- TAJO-361 ) fixed some value name.
        Hide
        sirpkt Keuntae Park added a comment -

        In testLpad() method of TestStringOperatorsAndFunctions.java,
        there is a code line that

         testSimpleEval("select lPAD('가나다라', 3) ", new String[]{"가나다"});
        

        As I know, Oracle uses byte length in lpad(), so above test will not pass in Oracle.
        I'm not sure whether we should follow Oracle or make another function ipadb() for byte length like strposb() case.

        Show
        sirpkt Keuntae Park added a comment - In testLpad() method of TestStringOperatorsAndFunctions.java, there is a code line that testSimpleEval("select lPAD('가나다라', 3) ", new String[]{"가나다"}); As I know, Oracle uses byte length in lpad(), so above test will not pass in Oracle. I'm not sure whether we should follow Oracle or make another function ipadb() for byte length like strposb() case.
        Hide
        blrunner Jaehwa Jung added a comment -

        In MySQL, the result was that we expected as follows:

        • statement: select lpad('abcdef', '3', 'xy') from dual;
        • result: abc

        And I have a question. What is unicode problem about byte array?

        Show
        blrunner Jaehwa Jung added a comment - In MySQL, the result was that we expected as follows: statement: select lpad('abcdef', '3', 'xy') from dual; result: abc And I have a question. What is unicode problem about byte array?
        Hide
        blrunner Jaehwa Jung added a comment - - edited

        +1.

        You don't need to answer my question.
        I understood unicode problem now.
        So, I've just committed now.
        Thank you for your contribution.

        Show
        blrunner Jaehwa Jung added a comment - - edited +1. You don't need to answer my question. I understood unicode problem now. So, I've just committed now. Thank you for your contribution.
        Hide
        hudson Hudson added a comment -

        SUCCESS: Integrated in Tajo-trunk-postcommit #588 (See https://builds.apache.org/job/Tajo-trunk-postcommit/588/)
        TAJO-359: Implement lpad function. (Seungun Choe via jaehwa) (jhjung: https://git-wip-us.apache.org/repos/asf?p=incubator-tajo.git&a=commit&h=d9e458fa011120d914b50212b094f0c5f9401fb0)

        • tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/function/TestStringOperatorsAndFunctions.java
        • tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/master/TajoMaster.java
        • CHANGES.txt
        • tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/function/string/Lpad.java
        Show
        hudson Hudson added a comment - SUCCESS: Integrated in Tajo-trunk-postcommit #588 (See https://builds.apache.org/job/Tajo-trunk-postcommit/588/ ) TAJO-359 : Implement lpad function. (Seungun Choe via jaehwa) (jhjung: https://git-wip-us.apache.org/repos/asf?p=incubator-tajo.git&a=commit&h=d9e458fa011120d914b50212b094f0c5f9401fb0 ) tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/function/TestStringOperatorsAndFunctions.java tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/master/TajoMaster.java CHANGES.txt tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/function/string/Lpad.java

          People

          • Assignee:
            seungunchoe Seungun Choe
            Reporter:
            seungunchoe Seungun Choe
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development