kangkaisen opened a new issue #1356: Wrong query result with constant 
URL: https://github.com/apache/incubator-doris/issues/1356
 
 
   **Describe the bug**
   1 create a view with constant
   ```
   CREATE VIEW `app_brand_ka_analysis_flow_entry_m_kks4` AS
   SELECT `t`.`brand_id` AS `bigchain_brand_id`,
          `t`.`city_id` AS `poi_second_city_id`,
          `t`.`mo` AS `mo`
   FROM `default_cluster:mart_waimai`.`app_ka_brand_list_m` t
   UNION ALL
   SELECT `t`.`brand_id` AS `bigchain_brand_id`,
          -1 AS `poi_second_city_id`,
          `t`.`mo` AS `mo`
   FROM `default_cluster:mart_waimai`.`app_ka_brand_list_m` t;
   ```
   2 query
   
   SQL1 :
   
   ```
   SELECT
   poi_second_city_id
   FROM
   app_brand_ka_analysis_flow_entry_m_kks4
   WHERE
   mo = 24233
   AND poi_second_city_id = -1
   AND bigchain_brand_id = 437;
   ```
   the result is:
   
   ```
   |                 -1 |
   |                 -1 |
   |                 -1 |
   |                 -1 |
   |                 -1 |
   |                 -1 |
   |                 -1 |
   |                 -1 |
   +--------------------+
   5714 rows in set (27.65 sec)
   ```
   SQL 2:
   ```
   SELECT
   poi_second_city_id
   FROM
   app_brand_ka_analysis_flow_entry_m_kks4
   WHERE
   mo = 24233
   AND poi_second_city_id IN (-1)
   AND bigchain_brand_id = 437;
   ```
   the result is empty.
   
   the SQL 2 result is wrong. because in `RangePartitionPruner.prune`, the code 
will run into
   ```
           Set<Long> resultSet = Sets.newHashSet();
           int childrenNum = inPredicate.getChildren().size();
           int newComplex = inPredicate.getChildren().size() * complex;
           for (int i = 1; i < childrenNum; ++i) {
               LiteralExpr expr = (LiteralExpr) inPredicate.getChild(i);
               minKey.pushColumn(expr, keyColumn.getDataType());
               maxKey.pushColumn(expr, keyColumn.getDataType());
               Collection<Long> subList = prune(rangeMap, columnIdx + 1, 
minKey, maxKey, newComplex);
               for (long partId : subList) {
                   resultSet.add(partId);
               }
               minKey.popColumn();
               maxKey.popColumn();
           }
   ```
   **and get the wrong partition id.**
   
   
   we could fix the bug by computing `-1 in (-1)`  to `BoolLiteral(true)`.
   

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

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

Reply via email to