Skip to content

Commit

Permalink
[CARBONDATA-3187] Supported Global Dictionary For Map
Browse files Browse the repository at this point in the history
Problem: Global Dictionary was not working for Map datatype and giving Null values.

Solution:Added the case for Global Dictionary to be created in case the datatype is Complex Map.

This closes #3006
  • Loading branch information
manishnalla1994 authored and kumarvishal09 committed Dec 20, 2018
1 parent 96ce007 commit 5f0549a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Expand Up @@ -226,22 +226,22 @@ class TestCreateDDLForComplexMapType extends QueryTest with BeforeAndAfterAll {
Row(Map(1 -> "Nalla", 2 -> "", 3 -> "Gupta", 4 -> "Kumar"))))
}

// Support this for Map type
// Global Dictionary for Map type
test("Test Load data in map with dictionary include") {
sql("DROP TABLE IF EXISTS carbon")
sql(
s"""
| CREATE TABLE carbon(
| mapField map<int,STRING>
| mapField map<STRING,STRING>
| )
| STORED BY 'carbondata'
| TBLPROPERTIES('DICTIONARY_INCLUDE'='mapField')
| """
.stripMargin)
sql("insert into carbon values('1\002Nalla\0012\002Singh\0013\002Gupta')")
sql("insert into carbon values('vi\002Nalla\001sh\002Singh\001al\002Gupta')")
sql("select * from carbon").show(false)
//checkAnswer(sql("select * from carbon"), Seq(
//Row(Map(1 -> "Nalla", 2 -> "Singh", 3 -> "Gupta", 4 -> "Kumar"))))
checkAnswer(sql("select * from carbon"), Seq(
Row(Map("vi" -> "Nalla", "sh" -> "Singh", "al" -> "Gupta"))))
}

test("Test Load data in map with partition columns") {
Expand Down
Expand Up @@ -182,7 +182,7 @@ object GlobalDictionaryUtil {
case None =>
None
case Some(dim) =>
if (DataTypes.isArrayType(dim.getDataType)) {
if (DataTypes.isArrayType(dim.getDataType) || DataTypes.isMapType(dim.getDataType)) {
val arrDim = ArrayParser(dim, format)
generateParserForChildrenDimension(dim, format, mapColumnValuesWithId, arrDim)
Some(arrDim)
Expand Down

0 comments on commit 5f0549a

Please sign in to comment.