Skip to content

Commit

Permalink
[CARBONDATA-4248] Fixed upper case column name in explain command
Browse files Browse the repository at this point in the history
Why is this PR needed?
Explain command with upper case column name fails with key not found exception.

What changes were proposed in this PR?
Changed column name to lower case before conversion of spark data type to carbon data type.

Does this PR introduce any user interface change?
No

Is any new testcase added?
Yes

This closes #4175
  • Loading branch information
nihal0107 authored and Indhumathi27 committed Jul 29, 2021
1 parent 9aaeba5 commit f2698fe
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ object CarbonFilters {
}

def translateDataType(name: String, columnTypes: Map[String, SparkDataType]): DataType = {
CarbonSparkDataSourceUtil.convertSparkToCarbonDataType(columnTypes(name))
CarbonSparkDataSourceUtil.convertSparkToCarbonDataType(columnTypes(name.toLowerCase()))
}

def translateColumn(name: String, dataType: SparkDataType): ColumnExpression = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,23 @@ class TestLoadDataGeneral extends QueryTest with BeforeAndAfterEach {
segment != null
}

test("test explain with case sensitive") {
sql("drop table if exists carbon_table")
sql("drop table if exists parquet_table")
sql("create table IF NOT EXISTS carbon_table(`BEGIN_TIME` BIGINT," +
" `SAI_CGI_ECGI` STRING) stored as carbondata")
sql("create table IF NOT EXISTS parquet_table(CELL_NAME string, CGISAI string)" +
" stored as parquet")
val df = sql("explain extended with grpMainDatathroughput as (select" +
" from_unixtime(begin_time, 'yyyyMMdd') as data_time, SAI_CGI_ECGI from carbon_table)," +
" grpMainData as (select * from grpMainDatathroughput a JOIN(select CELL_NAME, CGISAI from" +
" parquet_table) b ON b.CGISAI=a.SAI_CGI_ECGI) " +
"select * from grpMainData a left join grpMainData b on a.cell_name=b.cell_name").collect()
assert(df(0).getString(0).contains("carbon_table"))
sql("drop table if exists carbon_table")
sql("drop table if exists parquet_table")
}

test("test data loading CSV file") {
val testData = s"$resourcesPath/sample.csv"
checkAnswer(
Expand Down

0 comments on commit f2698fe

Please sign in to comment.