suxiaogang223 opened a new pull request, #32438:
URL: https://github.com/apache/doris/pull/32438

   ## Proposed changes
   backport: https://github.com/apache/doris/pull/31128
   This optimization allows doris to correctly read struct type data after 
changing the schema from hive.
   
   ## Changing  struct schema  in hive:
   ```sql
   hive> create table struct_test(id int,sf struct<f1: int, f2: string>) stored 
as parquet;
   
   hive> insert into struct_test values
       >           (1, named_struct('f1', 1, 'f2', 's1')),
       >           (2, named_struct('f1', 2, 'f2', 's2')),
       >           (3, named_struct('f1', 3, 'f2', 's3'));
   
   hive> alter table struct_test change sf sf struct<f1:int, f3:string>;
   
   hive> select * from struct_test;
   OK
   1    {"f1":1,"f3":null}
   2    {"f1":2,"f3":null}
   3    {"f1":3,"f3":null}
   Time taken: 5.298 seconds, Fetched: 3 row(s)
   ```
   
   The previous result of doris was:
   ```sql
   mysql> select * from struct_test;
   +------+-----------------------+
   | id   | sf                    |
   +------+-----------------------+
   |    1 | {"f1": 1, "f3": "s1"} |
   |    2 | {"f1": 2, "f3": "s2"} |
   |    3 | {"f1": 3, "f3": "s3"} |
   +------+-----------------------+
   ```
   
   Now the result is same as hive:
   
   ```sql
   mysql> select * from struct_test;
   +------+-----------------------+
   | id   | sf                    |
   +------+-----------------------+
   |    1 | {"f1": 1, "f3": null} |
   |    2 | {"f1": 2, "f3": null} |
   |    3 | {"f1": 3, "f3": null} |
   +------+-----------------------+
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to