@@ -664,15 +664,14 @@ class TestInsertTable extends HoodieSparkSqlTestBase {
664664 }
665665 }
666666
667- test(" Test nested field as preCombineField" ) {
667+ test(" Test nested field as primaryKey and preCombineField" ) {
668668 withTempDir { tmp =>
669669 Seq (" cow" , " mor" ).foreach { tableType =>
670670 val tableName = generateTableName
671671 // create table
672672 spark.sql(
673673 s """
674674 |create table $tableName (
675- | id int,
676675 | name string,
677676 | price double,
678677 | ts long,
@@ -681,18 +680,18 @@ class TestInsertTable extends HoodieSparkSqlTestBase {
681680 | location ' ${tmp.getCanonicalPath}/ $tableName'
682681 | options (
683682 | type = ' $tableType',
684- | primaryKey = 'id ',
683+ | primaryKey = 'nestedcol.a1 ',
685684 | preCombineField = 'nestedcol.a2.b2.c2'
686685 | )
687686 """ .stripMargin)
688687 // insert data to table
689688 spark.sql(
690689 s """ insert into $tableName values
691- |(0, 'name_1', 10, 1000, struct('a', struct('b', struct('c', 999)))),
692- |(0, 'name_2', 20, 2000, struct('a', struct('b', struct('c', 333))))
690+ |('name_1', 10, 1000, struct('a', struct('b', struct('c', 999)))),
691+ |('name_2', 20, 2000, struct('a', struct('b', struct('c', 333))))
693692 | """ .stripMargin)
694- checkAnswer(s " select id, name, price, ts, nestedcol, nestedcol.a2.b2.c2 from $tableName" )(
695- Seq (0 , " name_1" , 10.0 , 1000 , " { \" a1 \" : \" a \" , \" a2 \" :{ \" b1 \" : \" b \" , \" b2 \" :{ \" c1 \" : \" c \" , \" c2 \" :999}}}, 999" )
693+ checkAnswer(s " select name, price, ts, nestedcol.a1 , nestedcol.a2.b2.c2 from $tableName" )(
694+ Seq (" name_1" , 10.0 , 1000 , " a " , 999 )
696695 )
697696 }
698697 }
0 commit comments