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

   ### 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
   
   2.0.4
   2.0.3
   
   ### What's Wrong?
   
   Exception occurs when executing the 'INSERT SELECT' statement while 'SELECT' 
does not.
   
   I have a business SQL with the 'INSERT SELECT' syntax. When I execute the 
'SELECT' statement alone, everything works perfectly. However, when I execute 
the 'INSERT SELECT,' it always triggers an exception like below:
   
![image](https://github.com/apache/doris/assets/19585991/b1daf40b-8b4d-4b40-9b19-a0e69e4837d4)
   
   Due to the sensitivity of the business SQL, I have compiled a simplified 
version of the SQL. While both the simplified SQL and the original business SQL 
trigger the same exception, the severity differs. The simplified SQL can be 
successfully submitted after modifying the following variables, but the same 
modification does not work for the original business SQL.
   
![image](https://github.com/apache/doris/assets/19585991/f63bd458-1e4a-4d63-97ba-9466a2e7f8b3)
   
   After disabling the 'enable_fallback_to_original_planner', business SQL 
query shows clear errors. The first error is as follows:
   
![f88124d9bbc88193b7842f9adb365dd](https://github.com/apache/doris/assets/19585991/65ec8cd4-a866-4d3b-9f2f-fd6ab01a09f0)
   
   So, I tried removing all occurrences of 'current_timestamp' from both the 
source and destination tables. At this point, I encountered the second error:
   
![401ca6cbe7c0d12514e770cb22fa6de](https://github.com/apache/doris/assets/19585991/009eef94-9392-4546-8836-18b8e22308af)
   
   
   
   ### What You Expected?
   
   INSERT SELECT can be executed normally, just like SELECT statement.
   
   ### How to Reproduce?
   
   I will provide a simplified version of the SQL for now. If necessary, I will 
attempt to manually desensitize some of the logic in the business SQL later 
while ensuring that its behavior remains consistent with the original state 
before desensitization.
   
   Here, simplified SQL:
   `CREATE TABLE `dws_a` ( 
       `createdate` int(11) NOT NULL, 
       `price2` DECIMAL(19, 4) NULL, 
       `price1` DECIMAL(19, 4) NULL 
   ) 
   ENGINE=OLAP UNIQUE KEY(`createdate`) 
   DISTRIBUTED BY HASH(`createdate`) BUCKETS 10 PROPERTIES ( 
"replication_allocation" = "tag.location.default: 3", "is_being_synced" = 
"false", "storage_format" = "V2", "light_schema_change" = "true", 
"disable_auto_compaction" = "false", "enable_single_replica_compaction" = 
"false" );
   
   CREATE TABLE `dwm_a` ( 
       `id` varchar(255) NOT NULL COMMENT 'ID',
       `ptime` datetime NULL,
       `price1` DECIMALV3 NULL,
       `price2` DECIMALV3 NULL,
       `number` DECIMALV3 NULL,
       `is_a` varchar(32) NULL,
   ) 
   ENGINE=OLAP DUPLICATE KEY(`id`) 
   DISTRIBUTED BY HASH(`id`) BUCKETS 10 PROPERTIES ( "replication_allocation" = 
"tag.location.default: 3", "is_being_synced" = "false", "storage_format" = 
"V2", "light_schema_change" = "true", "disable_auto_compaction" = "false", 
"enable_single_replica_compaction" = "false" );
   
   INSERT INTO dws_a (createdate ,price1)
   SELECT
   createdate,
   price1
   FROM (
       SELECT
       createdate,
       SUM(price2) AS price2,
       SUM(price3) AS price3,
       SUM(price1) AS price1
       FROM (   
           SELECT
           DATE_FORMAT(ptime, '20%y%m01') AS createdate,
           CASE
               WHEN is_a = '是' THEN 'a'
               ELSE 'b' 
           END AS type,
           number * 1000 AS price3,
           price2 ,
           price1
           FROM dwm_a                        
       ) a
   GROUP BY createdate) b;
   `
   
   ### Anything Else?
   
   _No response_
   
   ### 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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to