You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@carbondata.apache.org by manishgupta88 <gi...@git.apache.org> on 2018/01/04 06:22:55 UTC

[GitHub] carbondata pull request #1082: [CARBONDATA-1218] [GLOBAL SORT] In case of da...

Github user manishgupta88 commented on a diff in the pull request:

    https://github.com/apache/carbondata/pull/1082#discussion_r159584326
  
    --- Diff: integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/badrecordloger/BadRecordLoggerTest.scala ---
    @@ -247,6 +248,33 @@ class BadRecordLoggerTest extends QueryTest with BeforeAndAfterAll {
         }
       }
     
    +  test(
    +    "test if first load failed due to bad record then second load should not failed if there is " +
    +    "no bad record") {
    +    sql("drop table IF EXISTS loadIssue")
    +    sql("""CREATE TABLE IF NOT EXISTS loadIssue(ID BigInt, item String) STORED BY 'carbondata'""")
    +    CarbonProperties.getInstance().addProperty(CarbonCommonConstants.CARBON_BAD_RECORDS_ACTION,
    +      "FAIL").addProperty(CarbonCommonConstants.LOAD_SORT_SCOPE, "GLOBAL_SORT")
    +    try {
    +      sql("insert into loadIssue select 'x','Book'");
    +    } catch {
    +      case ex: Exception =>
    +        assert(true)
    +    }
    +    try {
    +      sql("insert into loadIssue select 1,'Book'");
    +    } catch {
    +      case ex: Exception =>
    +        assert(false)
    +    } finally {
    +      CarbonProperties.getInstance()
    +        .addProperty(CarbonCommonConstants.CARBON_BAD_RECORDS_ACTION, "FORCE")
    +        .addProperty(CarbonCommonConstants.LOAD_SORT_SCOPE, "LOCAL_SORT")
    +    }
    +    assert(true)
    +    sql("drop table IF EXISTS loadIssue")
    +  }
    +
    --- End diff --
    
    1. Use only one try and finally block inside test code..try should start from first line and end at last and finally should only reset the carbon property
    2. Instead of try catch use intercept[Exception] only for the 1st case where exception is expected. For 2nd case try catch is not required...if exception comes anyways test case will fail


---