TangSiyang2001 opened a new issue, #20952:
URL: https://github.com/apache/doris/issues/20952

   ### Search before asking
   
   - [X] I had searched in the 
[issues](https://github.com/apache/doris/issues?q=is%3Aissue) and found no 
similar issues.
   
   
   ### Version
   
   all
   
   ### What's Wrong?
   
   1. For `float` type columns, bug exists now #20867.
   2. For `char` type columns, if we assign default value for them, and we 
insert default value, error will be raised: "can not cast from origin type 
TINYINT to target type=CHAR(16)".
   3. For `datetime` or `datetimev2` columns, if we use CURRENT_TIMESTAMP as 
default value, error will be raised: " [INTERNAL_ERROR]Invalid value in strict 
mode for function CAST, source column String, from type String to type 
DateTimeV2".
   
   
   ### What You Expected?
   
   Fix the wrong behaviors.
   
   ### How to Reproduce?
   
   Create a table with those types and set default values, and run `insert into 
tbl values();` to insert default values for them.
   
   ### Anything Else?
   
   For `datetime` related bug, there are some clues.
   
   Seems the plan is wrong:
   
   mysql [test]>explain verbose insert into dft values();
   ```
   
+---------------------------------------------------------------------------------------+
   | Explain String                                                             
           |
   
+---------------------------------------------------------------------------------------+
   | PLAN FRAGMENT 0                                                            
           |
   |   OUTPUT EXPRS:                                                            
           |
   |      CAST('CURRENT_TIMESTAMP' AS DATETIMEV2(0))                            
           |
   |   PARTITION: UNPARTITIONED                                                 
           |
   |                                                                            
           |
   |   OLAP TABLE SINK                                                          
           |
   |     TUPLE ID: 0                                                            
           |
   |     RANDOM                                                                 
           |
   |                                                                            
           |
   |   0:VUNION                                                                 
           |
   |      constant exprs:                                                       
           |
   |          CAST('CURRENT_TIMESTAMP' AS DATETIMEV2(0))                        
           |
   |      tuple ids: 1                                                          
           |
   |                                                                            
           |
   | Tuples:                                                                    
           |
   | TupleDescriptor{id=0, tbl=null, byteSize=16}                               
           |
   |   SlotDescriptor{id=0, col=k13, colUniqueId=0, type=datetimev2(0), 
nullable=true}     |
   |                                                                            
           |
   | TupleDescriptor{id=1, tbl=null, byteSize=16}                               
           |
   |   SlotDescriptor{id=1, col=null, colUniqueId=null, type=datetimev2(0), 
nullable=true} |
   
+---------------------------------------------------------------------------------------+
   20 rows in set (0.01 sec)
   ```
   
   Related logic for default val processing in NativeInsertStmt
   
https://github.com/apache/doris/blob/bf197ee8d2d9e6ccf88184663e4614068bc3edde/fe/fe-core/src/main/java/org/apache/doris/analysis/NativeInsertStmt.java#L661-L676
   
   Maybe due to unreasonable logic here, so 
`targetColumns.get(i).getDefaultValue())` returns the string itself. 
https://github.com/apache/doris/blob/bf197ee8d2d9e6ccf88184663e4614068bc3edde/fe/fe-core/src/main/java/org/apache/doris/analysis/ColumnDef.java#L106-L109
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
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.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