You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2020/07/04 15:00:07 UTC

[GitHub] [incubator-doris] francisoliverlee opened a new issue #4018: Bug: Cast error in partition, using partition key in where cause

francisoliverlee opened a new issue #4018:
URL: https://github.com/apache/incubator-doris/issues/4018


   **Describe the bug**
   go to **Reproduce
   
   **To Reproduce**
   Steps to reproduce the behavior:
   1. create table
   `CREATE TABLE `vk_tbl_01` (
     `pt` date NULL COMMENT "hive分区",
     `day` date NULL COMMENT "日期",
   ) ENGINE=OLAP
   DUPLICATE KEY(`pt`, `day`)
   COMMENT "OLAP"
   PARTITION BY RANGE(`day`)
   (PARTITION p20200601 VALUES [('2020-06-01'), ('2020-06-02')),
   PARTITION p20200703 VALUES [('2020-07-03'), ('2020-07-04')))
   DISTRIBUTED BY HASH(`pt`, `day`, `dpt`, `mgr`, `tl`) BUCKETS 3
   PROPERTIES (
     "replication_num" = "1",
     "dynamic_partition.enable" = "false",
     "dynamic_partition.time_unit" = "DAY",
     "dynamic_partition.start" = "-2147483648",
     "dynamic_partition.end" = "3",
     "dynamic_partition.prefix" = "p",
     "dynamic_partition.buckets" = "5",
     "in_memory" = "false",
     "storage_format" = "DEFAULT"
   );`
   2. reproduce case sql, notice the where-in ccause
   `
   SELECT
     pt,
     DAYOFWEEK(`day`) `week`,
     dpt AS `大部`
   FROM
     vk_tbl_01 
   WHERE
     DAYOFWEEK(`day`) in ('2') limit 10;`
   
   3. right case, notice the where= cause
   `SELECT
     pt,
     DAYOFWEEK(`day`) `week`,
     dpt AS `大部`
   FROM
     vk_tbl_01
   WHERE
     DAYOFWEEK(`day`) = '2' limit 10;`
   
   **Expected behavior**
   return right resullt 
   
   **Screenshots**
   ![image](https://user-images.githubusercontent.com/5908412/86515058-fd9bf280-be48-11ea-81ba-b0fa465c1ddd.png)
   
   
   **code may cause the bug**
   `org.apache.doris.planner.RangePartitionPruner.java
   the children's type can not be used directly, because the children may be a function result, the function result's type does not eq with the original paitition key‘s type
   ![image](https://user-images.githubusercontent.com/5908412/86515099-510e4080-be49-11ea-9332-9d743c507adf.png)
   
   `
   ** possible solution **
   let's take the can-not-work-sql for example
   `
   SELECT
     pt,
     DAYOFWEEK(`day`) `week`,
     dpt AS `大部`
   FROM
     vk_tbl_01 
   WHERE
     DAYOFWEEK(`day`) in ('2') limit 10;`
   1. day is the partition key, so calc all PARTITION key result using DAYOFWEEK, we can confirm what partitions 2 in
   2. query those partitionns for the result
   
   


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

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



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