-
Notifications
You must be signed in to change notification settings - Fork 702
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CARBONDATA-1304] Support IUD with single pass
- Loading branch information
1 parent
5ea7c5b
commit 7c0c452
Showing
5 changed files
with
127 additions
and
44 deletions.
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
...a/org/apache/carbondata/spark/testsuite/iud/UpdateCarbonTableTestCaseWithSinglePass.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.carbondata.spark.testsuite.iud | ||
|
||
import org.apache.spark.sql.Row | ||
import org.apache.spark.sql.common.util.QueryTest | ||
import org.scalatest.BeforeAndAfterAll | ||
|
||
import org.apache.carbondata.common.constants.LoggerAction | ||
import org.apache.carbondata.core.constants.{CarbonCommonConstants, CarbonLoadOptionConstants} | ||
import org.apache.carbondata.core.util.CarbonProperties | ||
|
||
class UpdateCarbonTableTestCaseWithSinglePass extends QueryTest with BeforeAndAfterAll { | ||
override def beforeAll { | ||
CarbonProperties.getInstance() | ||
.addProperty(CarbonCommonConstants.CARBON_BAD_RECORDS_ACTION, LoggerAction.FORCE.name()) | ||
sql(s"""set ${ CarbonLoadOptionConstants.CARBON_OPTIONS_SINGLE_PASS }=true""").show | ||
} | ||
|
||
|
||
test("test update operation with Badrecords action as force with single_pass.") { | ||
sql("""drop table if exists badtable""").show | ||
sql("""create table badtable (c1 string,c2 int,c3 string,c5 string) STORED BY 'org.apache.carbondata.format'""") | ||
sql(s"""LOAD DATA LOCAL INPATH '$resourcesPath/IUD/badrecord.csv' INTO table badtable""") | ||
sql("""update badtable d set (d.c2) = (d.c2 / 1)""").show() | ||
checkAnswer( | ||
sql("""select c1,c2,c3,c5 from badtable"""), | ||
Seq(Row("ravi",null,"kiran","huawei"),Row("manohar",null,"vanam","huawei")) | ||
) | ||
sql("""drop table badtable""").show | ||
|
||
|
||
} | ||
test("test update operation with Badrecords action as FAIL with single_pass.") { | ||
CarbonProperties.getInstance() | ||
.addProperty(CarbonCommonConstants.CARBON_BAD_RECORDS_ACTION , LoggerAction.FAIL.name()) | ||
sql("""drop table if exists badtable""").show | ||
sql("""create table badtable (c1 string,c2 int,c3 string,c5 string) STORED BY 'org.apache.carbondata.format'""") | ||
sql(s"""LOAD DATA LOCAL INPATH '$resourcesPath/IUD/badrecord.csv' INTO table badtable""") | ||
val exec = intercept[Exception] { | ||
sql("""update badtable d set (d.c2) = (d.c2 / 1)""").show() | ||
} | ||
checkAnswer( | ||
sql("""select c1,c2,c3,c5 from badtable"""), | ||
Seq(Row("ravi",2,"kiran","huawei"),Row("manohar",4,"vanam","huawei")) | ||
) | ||
sql("""drop table badtable""").show | ||
|
||
|
||
} | ||
|
||
override def afterAll { | ||
sql(s"""set ${ CarbonLoadOptionConstants.CARBON_OPTIONS_SINGLE_PASS }=false""").show | ||
CarbonProperties.getInstance() | ||
.addProperty(CarbonCommonConstants.CARBON_BAD_RECORDS_ACTION , CarbonCommonConstants.CARBON_BAD_RECORDS_ACTION_DEFAULT) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters