Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CARBONDATA-3115] Fix CodeGen error in preaggregate table and codegen display issue in oldstores #2939

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,29 @@ class TestPreAggCreateCommand extends QueryTest with BeforeAndAfterAll {
}
}

test("test codegen issue with preaggregate") {
sql("DROP TABLE IF EXISTS PreAggMain")
sql("CREATE TABLE PreAggMain (id Int, date date, country string, phonetype string, " +
"serialname String,salary int ) STORED BY 'org.apache.carbondata.format' " +
"tblproperties('dictionary_include'='country')")
sql("create datamap PreAggSum on table PreAggMain using 'preaggregate' as " +
"select country,sum(salary) as sum from PreAggMain group by country")
sql("create datamap PreAggAvg on table PreAggMain using 'preaggregate' as " +
"select country,avg(salary) as avg from PreAggMain group by country")
sql("create datamap PreAggCount on table PreAggMain using 'preaggregate' as " +
"select country,count(salary) as count from PreAggMain group by country")
sql("create datamap PreAggMin on table PreAggMain using 'preaggregate' as " +
"select country,min(salary) as min from PreAggMain group by country")
sql("create datamap PreAggMax on table PreAggMain using 'preaggregate' as " +
"select country,max(salary) as max from PreAggMain group by country")
sql(s"LOAD DATA INPATH '$integrationPath/spark-common-test/src/test/resources/source.csv' " +
s"into table PreAggMain")
checkExistence(sql("select t1.country,sum(id) from PreAggMain t1 join (select " +
"country as newcountry,sum(salary) as sum from PreAggMain group by country)" +
"t2 on t1.country=t2.newcountry group by country"), true, "france")
sql("DROP TABLE IF EXISTS PreAggMain")
}

// TODO: Need to Fix
ignore("test creation of multiple preaggregate of same name concurrently") {
sql("DROP TABLE IF EXISTS tbl_concurr")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,34 +248,34 @@ case class CarbonDictionaryDecoder(
|org.apache.spark.sql.DictTuple $value = $decodeDecimal($dictRef, ${ev.value});
""".stripMargin
ExprCode(code, s"$value.getIsNull()",
s"(org.apache.spark.sql.types.Decimal)$value.getValue()")
s"((org.apache.spark.sql.types.Decimal)$value.getValue())")
} else {
getDictionaryColumnIds(index)._3.getDataType match {
case CarbonDataTypes.INT => code +=
s"""
|org.apache.spark.sql.DictTuple $value = $decodeInt($dictRef, ${ ev.value });
""".stripMargin
ExprCode(code, s"$value.getIsNull()", s"(Integer)$value.getValue()")
ExprCode(code, s"$value.getIsNull()", s"((Integer)$value.getValue())")
case CarbonDataTypes.SHORT => code +=
s"""
|org.apache.spark.sql.DictTuple $value = $decodeShort($dictRef, ${ ev.value });
""".stripMargin
ExprCode(code, s"$value.getIsNull()", s"(Short)$value.getValue()")
ExprCode(code, s"$value.getIsNull()", s"((Short)$value.getValue())")
case CarbonDataTypes.DOUBLE => code +=
s"""
|org.apache.spark.sql.DictTuple $value = $decodeDouble($dictRef, ${ ev.value });
""".stripMargin
ExprCode(code, s"$value.getIsNull()", s"(Double)$value.getValue()")
ExprCode(code, s"$value.getIsNull()", s"((Double)$value.getValue())")
case CarbonDataTypes.LONG => code +=
s"""
|org.apache.spark.sql.DictTuple $value = $decodeLong($dictRef, ${ ev.value });
""".stripMargin
ExprCode(code, s"$value.getIsNull()", s"(Long)$value.getValue()")
ExprCode(code, s"$value.getIsNull()", s"((Long)$value.getValue())")
case _ => code +=
s"""
|org.apache.spark.sql.DictTuple $value = $decodeStr($dictRef, ${ev.value});
""".stripMargin
ExprCode(code, s"$value.getIsNull()", s"(UTF8String)$value.getValue()")
ExprCode(code, s"$value.getIsNull()", s"((UTF8String)$value.getValue())")

}
}
Expand Down