-
Notifications
You must be signed in to change notification settings - Fork 703
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Whenever a not equal to filter is applied on dictionary column with n…
…umeric datatype, the cast added by spark plan is removed while creating carbon filters from spark filter. Due to this plan modification incorrect results are returned by spark.
- Loading branch information
1 parent
a1b8afa
commit 7d32cf7
Showing
7 changed files
with
125 additions
and
83 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
integration/spark-common-test/src/test/resources/filter/notEqualToFilter.csv
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,3 @@ | ||
1,2015-07-23 00:00:00,china,aaa1,phone197,ASD69643,15000 | ||
7,2015-07-24 00:00:00,china,aaa2,phone756,ASD42892,15001 | ||
7,2015-07-25 00:00:00,china,aaa3,phone1904,ASD37014,15002 |
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
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
90 changes: 90 additions & 0 deletions
90
...ration/spark2/src/test/scala/org/apache/spark/carbondata/query/TestNotEqualToFilter.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,90 @@ | ||
/* | ||
* 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.spark.carbondata.query | ||
|
||
import org.apache.spark.sql.common.util.QueryTest | ||
import org.scalatest.BeforeAndAfterAll | ||
|
||
import org.apache.carbondata.core.constants.CarbonCommonConstants | ||
import org.apache.carbondata.core.util.CarbonProperties | ||
|
||
/** | ||
* Test cases for testing columns having \N or \null values for non numeric columns | ||
*/ | ||
class TestNotEqualToFilter extends QueryTest with BeforeAndAfterAll { | ||
|
||
override def beforeAll { | ||
sql("drop table if exists test_not_equal_to_carbon") | ||
sql("drop table if exists test_not_equal_to_hive") | ||
CarbonProperties.getInstance() | ||
.addProperty(CarbonCommonConstants.CARBON_TIMESTAMP_FORMAT, | ||
CarbonCommonConstants.CARBON_TIMESTAMP_DEFAULT_FORMAT | ||
) | ||
sql( | ||
""" | ||
CREATE TABLE IF NOT EXISTS test_not_equal_to_carbon | ||
(ID Int, date Timestamp, country String, | ||
name String, phonetype String, serialname String, salary Int) | ||
STORED BY 'org.apache.carbondata.format' TBLPROPERTIES('dictionary_include'='id') | ||
""") | ||
sql( | ||
""" | ||
CREATE TABLE IF NOT EXISTS test_not_equal_to_hive | ||
(ID Int, date Timestamp, country String, | ||
name String, phonetype String, serialname String, salary Int) | ||
row format delimited fields terminated by ',' | ||
""") | ||
sql( | ||
s""" | ||
LOAD DATA LOCAL INPATH '$resourcesPath/filter/notEqualToFilter.csv' into table | ||
test_not_equal_to_carbon | ||
OPTIONS('FILEHEADER'='ID,date,country,name,phonetype,serialname,salary') | ||
""") | ||
sql( | ||
s""" | ||
LOAD DATA LOCAL INPATH '$resourcesPath/filter/notEqualToFilter.csv' into table | ||
test_not_equal_to_hive | ||
""") | ||
} | ||
|
||
test("select Id from test_not_equal_to_carbon where id != '7'") { | ||
checkAnswer( | ||
sql("select Id from test_not_equal_to_carbon where id != '7'"), | ||
sql("select Id from test_not_equal_to_hive where id != '7'") | ||
) | ||
} | ||
|
||
test("select Id from test_not_equal_to_carbon where id != 7.0") { | ||
checkAnswer( | ||
sql("select Id from test_not_equal_to_carbon where id != 7.0"), | ||
sql("select Id from test_not_equal_to_hive where id != 7.0") | ||
) | ||
} | ||
|
||
test("select Id from test_not_equal_to_carbon where id != 7") { | ||
checkAnswer( | ||
sql("select Id from test_not_equal_to_carbon where id != 7"), | ||
sql("select Id from test_not_equal_to_hive where id != 7") | ||
) | ||
} | ||
|
||
override def afterAll { | ||
sql("drop table if exists test_not_equal_to_carbon") | ||
sql("drop table if exists test_not_equal_to_hive") | ||
} | ||
} |