You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@carbondata.apache.org by jatin9896 <gi...@git.apache.org> on 2018/03/25 08:35:18 UTC

[GitHub] carbondata pull request #2102: [CARBONDATA-2277] fix for filter on default v...

GitHub user jatin9896 opened a pull request:

    https://github.com/apache/carbondata/pull/2102

    [CARBONDATA-2277] fix for filter on default values on all datatypes

    1. Added solution to handle filter keys for the direct dictionary on default values.
    2. For no dictionary columns changes code to get correct bytes value of default values.
    Be sure to do all of the following checklist to help us incorporate 
    your contribution quickly and easily:
    
     - [ ] Any interfaces changed? No 
     
     - [ ] Any backward compatibility impacted? No
     
     - [ ] Document update required? No
    
     - [ ] Testing done
            Please provide details on 
            - Whether new unit test cases have been added or why no new tests are required? Yes
            - How it is tested? Please attach test report.
            - Is it a performance related change? Please attach the performance test report.
            - Any additional information to help reviewers in testing this change.
           
     - [ ] For large changes, please consider breaking it into sub-tasks under an umbrella JIRA. 
    


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/jatin9896/incubator-carbondata CARBONDATA-2277

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/carbondata/pull/2102.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #2102
    
----

----


---

[GitHub] carbondata issue #2102: [CARBONDATA-2277] fix for filter of default values o...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/2102
  
    Build Success with Spark 2.1.0, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder1/4575/



---

[GitHub] carbondata issue #2102: [CARBONDATA-2277] fix for filter of default values o...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/2102
  
    Build Success with Spark 2.2.1, Please check CI http://88.99.58.216:8080/job/ApacheCarbonPRBuilder/3349/



---

[GitHub] carbondata pull request #2102: [CARBONDATA-2277] fix for filter of default v...

Posted by manishgupta88 <gi...@git.apache.org>.
Github user manishgupta88 commented on a diff in the pull request:

    https://github.com/apache/carbondata/pull/2102#discussion_r177395959
  
    --- Diff: integration/spark2/src/test/scala/org/apache/spark/carbondata/restructure/AlterTableValidationTestCase.scala ---
    @@ -584,6 +589,98 @@ test("test alter command for boolean data type with correct default measure valu
           "alter table testalterwithbooleanwithoutdefaultvalue add columns(booleanfield boolean)")
         checkAnswer(sql("select * from testalterwithbooleanwithoutdefaultvalue"),Seq(Row(1,"anubhav",null)))
       }
    +  test("test alter command for filter on default values on date datatype") {
    +    sql("drop table if exists test")
    +    sql(
    +      "create table test(id int,vin string,phonenumber long,area string,salary int,country " +
    +      "string,longdate date) stored by 'carbondata'")
    +    sql("insert into test select 1,'String1',12345,'area',20,'country','2017-02-12'")
    +    sql("alter table test add columns (c3 date) TBLPROPERTIES('DEFAULT.VALUE.c3' = '1993-01-01')")
    +    sql("insert into test select 2,'String1',12345,'area',20,'country','2017-02-12','1994-01-01'")
    +    sql("insert into test select 3,'String1',12345,'area',20,'country','2017-02-12','1995-01-01'")
    +    sql("insert into test select 4,'String1',12345,'area',20,'country','2017-02-12','1996-01-01'")
    +    checkAnswer(sql("select id from test where c3='1993-01-01'"), Seq(Row(1)))
    +    checkAnswer(sql("select id from test where c3<'1995-01-01'"), Seq(Row(1), Row(2)))
    +    checkAnswer(sql("select id from test where c3>'1994-01-01'"), Seq(Row(3), Row(4)))
    +    checkAnswer(sql("select id from test where c3>='1995-01-01'"), Seq(Row(3), Row(4)))
    +    checkAnswer(sql("select id from test where c3<='1994-01-01'"), Seq(Row(1), Row(2)))
    +  }
    +
    +  test("test alter command for filter on default values on timestamp datatype") {
    +    def testFilterWithDefaultValue(flag: Boolean) = {
    +      CarbonProperties.getInstance()
    +        .addProperty(CarbonCommonConstants.CARBON_TIMESTAMP_FORMAT,
    +          "yyyy/MM/dd HH:mm:ss")
    +      sql("drop table if exists test")
    +      sql(
    +        "create table test(id int,vin string,phonenumber long,area string,salary int,country " +
    +        "string,longdate date) stored by 'carbondata'")
    +      sql("insert into test select 1,'String1',12345,'area',20,'country','2017-02-12'")
    +      if (flag) {
    +        sql(
    +          "alter table test add columns (c3 timestamp) TBLPROPERTIES('DEFAULT.VALUE.c3' = " +
    +          "'1996/01/01 11:11:11', 'DICTIONARY_INCLUDE' = 'c3')")
    +      } else {
    +        sql(
    +          "alter table test add columns (c3 timestamp) TBLPROPERTIES('DEFAULT.VALUE.c3' = " +
    +          "'1996/01/01 11:11:11')")
    +      }
    +      println("Timestamp Format: " + CarbonProperties.getInstance().getProperty(CarbonCommonConstants.CARBON_TIMESTAMP_FORMAT))
    +      println("flag : "+ flag)
    +      sql("select * from test").show(false)
    +      sql(
    +        "insert into test select 2,'String1',12345,'area',20,'country','2017-02-12','1994/01/01 " +
    +        "10:10:10'")
    +      sql(
    +        "insert into test select 3,'String1',12345,'area',20,'country','2017-02-12','1995/01/01 " +
    +        "11:11:11'")
    +      sql(
    +        "insert into test select 4,'String1',12345,'area',20,'country','2017-02-12','1996/01/01 " +
    +        "10:10:10'")
    +      checkAnswer(sql("select id from test where c3='1996-01-01 11:11:11'"), Seq(Row(1)))
    +      checkAnswer(sql("select id from test where c3<'1995-01-01 11:11:11'"), Seq(Row(2)))
    +      checkAnswer(sql("select id from test where c3>'1994-01-02 11:11:11'"),
    +        Seq(Row(3), Row(4), Row(1)))
    +      checkAnswer(sql("select id from test where c3>='1995-01-01 11:11:11'"),
    +        Seq(Row(3), Row(4), Row(1)))
    +      checkAnswer(sql("select id from test where c3<='1995-01-02 11:11:11'"), Seq(Row(2),Row(3)))
    +      CarbonProperties.getInstance()
    +        .addProperty(CarbonCommonConstants.CARBON_TIMESTAMP_FORMAT,
    +          CarbonCommonConstants.CARBON_TIMESTAMP_DEFAULT_FORMAT)
    +    }
    +
    +    testFilterWithDefaultValue(false)
    +    testFilterWithDefaultValue(true)
    +
    +  }
    +
    +  test("test alter command for filter on default values on int") {
    +    def testFilterWithDefaultValue(flag: Boolean) = {
    +      sql("drop table if exists test")
    +      sql(
    +        "create table test(id int,vin string,phonenumber long,area string,salary int,country " +
    +        "string,longdate date) stored by 'carbondata'")
    +      sql("insert into test select 1,'String1',12345,'area',5000,'country','2017/02/12'")
    +      if (flag) {
    +        sql(s"alter table test add columns (c3 int) TBLPROPERTIES('DEFAULT.VALUE.c3' = '23', " +
    +            s"'DICTIONARY_INCLUDE'='c3')")
    +      } else {
    +        sql(s"alter table test add columns (c3 int) TBLPROPERTIES('DEFAULT.VALUE.c3' = '23')")
    +      }
    +      sql("insert into test select 2,'String1',12345,'area',5000,'country','2017/02/12',25")
    +      sql("insert into test select 3,'String1',12345,'area',5000,'country','2017/02/12',35")
    +      sql("insert into test select 4,'String1',12345,'area',5000,'country','2017/02/12',45")
    +      checkAnswer(sql("select id from test where c3=23"), Seq(Row(1)))
    +      checkAnswer(sql("select id from test where c3<34"), Seq(Row(1), Row(2)))
    +      checkAnswer(sql("select id from test where c3>24"), Seq(Row(2), Row(3), Row(4)))
    +      checkAnswer(sql("select id from test where c3>=35"), Seq(Row(3), Row(4)))
    +      checkAnswer(sql("select id from test where c3<=35"), Seq(Row(1), Row(2), Row(3)))
    --- End diff --
    
    Add a query for !=, null and not null cases also


---

[GitHub] carbondata issue #2102: [CARBONDATA-2277] fix for filter of default values o...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/2102
  
    Build Success with Spark 2.1.0, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder1/4641/



---

[GitHub] carbondata issue #2102: [CARBONDATA-2277] fix for filter of default values o...

Posted by manishgupta88 <gi...@git.apache.org>.
Github user manishgupta88 commented on the issue:

    https://github.com/apache/carbondata/pull/2102
  
    LGTM


---

[GitHub] carbondata pull request #2102: [CARBONDATA-2277] fix for filter of default v...

Posted by manishgupta88 <gi...@git.apache.org>.
Github user manishgupta88 commented on a diff in the pull request:

    https://github.com/apache/carbondata/pull/2102#discussion_r177395322
  
    --- Diff: integration/spark2/src/test/scala/org/apache/spark/carbondata/restructure/AlterTableValidationTestCase.scala ---
    @@ -584,6 +589,98 @@ test("test alter command for boolean data type with correct default measure valu
           "alter table testalterwithbooleanwithoutdefaultvalue add columns(booleanfield boolean)")
         checkAnswer(sql("select * from testalterwithbooleanwithoutdefaultvalue"),Seq(Row(1,"anubhav",null)))
       }
    +  test("test alter command for filter on default values on date datatype") {
    +    sql("drop table if exists test")
    +    sql(
    +      "create table test(id int,vin string,phonenumber long,area string,salary int,country " +
    +      "string,longdate date) stored by 'carbondata'")
    +    sql("insert into test select 1,'String1',12345,'area',20,'country','2017-02-12'")
    +    sql("alter table test add columns (c3 date) TBLPROPERTIES('DEFAULT.VALUE.c3' = '1993-01-01')")
    +    sql("insert into test select 2,'String1',12345,'area',20,'country','2017-02-12','1994-01-01'")
    +    sql("insert into test select 3,'String1',12345,'area',20,'country','2017-02-12','1995-01-01'")
    +    sql("insert into test select 4,'String1',12345,'area',20,'country','2017-02-12','1996-01-01'")
    +    checkAnswer(sql("select id from test where c3='1993-01-01'"), Seq(Row(1)))
    +    checkAnswer(sql("select id from test where c3<'1995-01-01'"), Seq(Row(1), Row(2)))
    +    checkAnswer(sql("select id from test where c3>'1994-01-01'"), Seq(Row(3), Row(4)))
    +    checkAnswer(sql("select id from test where c3>='1995-01-01'"), Seq(Row(3), Row(4)))
    +    checkAnswer(sql("select id from test where c3<='1994-01-01'"), Seq(Row(1), Row(2)))
    +  }
    +
    +  test("test alter command for filter on default values on timestamp datatype") {
    +    def testFilterWithDefaultValue(flag: Boolean) = {
    +      CarbonProperties.getInstance()
    +        .addProperty(CarbonCommonConstants.CARBON_TIMESTAMP_FORMAT,
    +          "yyyy/MM/dd HH:mm:ss")
    +      sql("drop table if exists test")
    +      sql(
    +        "create table test(id int,vin string,phonenumber long,area string,salary int,country " +
    +        "string,longdate date) stored by 'carbondata'")
    +      sql("insert into test select 1,'String1',12345,'area',20,'country','2017-02-12'")
    +      if (flag) {
    +        sql(
    +          "alter table test add columns (c3 timestamp) TBLPROPERTIES('DEFAULT.VALUE.c3' = " +
    +          "'1996/01/01 11:11:11', 'DICTIONARY_INCLUDE' = 'c3')")
    +      } else {
    +        sql(
    +          "alter table test add columns (c3 timestamp) TBLPROPERTIES('DEFAULT.VALUE.c3' = " +
    +          "'1996/01/01 11:11:11')")
    +      }
    +      println("Timestamp Format: " + CarbonProperties.getInstance().getProperty(CarbonCommonConstants.CARBON_TIMESTAMP_FORMAT))
    +      println("flag : "+ flag)
    +      sql("select * from test").show(false)
    +      sql(
    +        "insert into test select 2,'String1',12345,'area',20,'country','2017-02-12','1994/01/01 " +
    +        "10:10:10'")
    +      sql(
    +        "insert into test select 3,'String1',12345,'area',20,'country','2017-02-12','1995/01/01 " +
    +        "11:11:11'")
    +      sql(
    +        "insert into test select 4,'String1',12345,'area',20,'country','2017-02-12','1996/01/01 " +
    +        "10:10:10'")
    +      checkAnswer(sql("select id from test where c3='1996-01-01 11:11:11'"), Seq(Row(1)))
    +      checkAnswer(sql("select id from test where c3<'1995-01-01 11:11:11'"), Seq(Row(2)))
    +      checkAnswer(sql("select id from test where c3>'1994-01-02 11:11:11'"),
    +        Seq(Row(3), Row(4), Row(1)))
    +      checkAnswer(sql("select id from test where c3>='1995-01-01 11:11:11'"),
    +        Seq(Row(3), Row(4), Row(1)))
    +      checkAnswer(sql("select id from test where c3<='1995-01-02 11:11:11'"), Seq(Row(2),Row(3)))
    +      CarbonProperties.getInstance()
    --- End diff --
    
    enclose the test case in try and finally to ensure that the property getting set in try block gets unset in finally block


---

[GitHub] carbondata pull request #2102: [CARBONDATA-2277] fix for filter of default v...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/carbondata/pull/2102


---

[GitHub] carbondata issue #2102: [CARBONDATA-2277] fix for filter of default values o...

Posted by ravipesala <gi...@git.apache.org>.
Github user ravipesala commented on the issue:

    https://github.com/apache/carbondata/pull/2102
  
    SDV Build Success , Please check CI http://144.76.159.231:8080/job/ApacheSDVTests/4151/



---

[GitHub] carbondata pull request #2102: [CARBONDATA-2277] fix for filter of default v...

Posted by manishgupta88 <gi...@git.apache.org>.
Github user manishgupta88 commented on a diff in the pull request:

    https://github.com/apache/carbondata/pull/2102#discussion_r177395075
  
    --- Diff: integration/spark2/src/test/scala/org/apache/spark/carbondata/restructure/AlterTableValidationTestCase.scala ---
    @@ -584,6 +589,98 @@ test("test alter command for boolean data type with correct default measure valu
           "alter table testalterwithbooleanwithoutdefaultvalue add columns(booleanfield boolean)")
         checkAnswer(sql("select * from testalterwithbooleanwithoutdefaultvalue"),Seq(Row(1,"anubhav",null)))
       }
    +  test("test alter command for filter on default values on date datatype") {
    +    sql("drop table if exists test")
    +    sql(
    +      "create table test(id int,vin string,phonenumber long,area string,salary int,country " +
    +      "string,longdate date) stored by 'carbondata'")
    +    sql("insert into test select 1,'String1',12345,'area',20,'country','2017-02-12'")
    +    sql("alter table test add columns (c3 date) TBLPROPERTIES('DEFAULT.VALUE.c3' = '1993-01-01')")
    +    sql("insert into test select 2,'String1',12345,'area',20,'country','2017-02-12','1994-01-01'")
    +    sql("insert into test select 3,'String1',12345,'area',20,'country','2017-02-12','1995-01-01'")
    +    sql("insert into test select 4,'String1',12345,'area',20,'country','2017-02-12','1996-01-01'")
    +    checkAnswer(sql("select id from test where c3='1993-01-01'"), Seq(Row(1)))
    +    checkAnswer(sql("select id from test where c3<'1995-01-01'"), Seq(Row(1), Row(2)))
    +    checkAnswer(sql("select id from test where c3>'1994-01-01'"), Seq(Row(3), Row(4)))
    +    checkAnswer(sql("select id from test where c3>='1995-01-01'"), Seq(Row(3), Row(4)))
    +    checkAnswer(sql("select id from test where c3<='1994-01-01'"), Seq(Row(1), Row(2)))
    +  }
    +
    +  test("test alter command for filter on default values on timestamp datatype") {
    +    def testFilterWithDefaultValue(flag: Boolean) = {
    +      CarbonProperties.getInstance()
    +        .addProperty(CarbonCommonConstants.CARBON_TIMESTAMP_FORMAT,
    +          "yyyy/MM/dd HH:mm:ss")
    +      sql("drop table if exists test")
    +      sql(
    +        "create table test(id int,vin string,phonenumber long,area string,salary int,country " +
    +        "string,longdate date) stored by 'carbondata'")
    +      sql("insert into test select 1,'String1',12345,'area',20,'country','2017-02-12'")
    +      if (flag) {
    +        sql(
    +          "alter table test add columns (c3 timestamp) TBLPROPERTIES('DEFAULT.VALUE.c3' = " +
    +          "'1996/01/01 11:11:11', 'DICTIONARY_INCLUDE' = 'c3')")
    +      } else {
    +        sql(
    +          "alter table test add columns (c3 timestamp) TBLPROPERTIES('DEFAULT.VALUE.c3' = " +
    +          "'1996/01/01 11:11:11')")
    +      }
    +      println("Timestamp Format: " + CarbonProperties.getInstance().getProperty(CarbonCommonConstants.CARBON_TIMESTAMP_FORMAT))
    +      println("flag : "+ flag)
    --- End diff --
    
    Remove all println statements


---

[GitHub] carbondata issue #2102: [CARBONDATA-2277] fix for filter of default values o...

Posted by ravipesala <gi...@git.apache.org>.
Github user ravipesala commented on the issue:

    https://github.com/apache/carbondata/pull/2102
  
    SDV Build Success , Please check CI http://144.76.159.231:8080/job/ApacheSDVTests/4073/



---

[GitHub] carbondata issue #2102: [CARBONDATA-2277] fix for filter of default values o...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/2102
  
    Build Success with Spark 2.2.1, Please check CI http://88.99.58.216:8080/job/ApacheCarbonPRBuilder/3416/



---