Skip to content

[Bug] lateral view + subquery leads to the error predicate #7823

@EmmyMiao87

Description

@EmmyMiao87

Search before asking

  • I had searched in the issues and found no similar issues.

Version

#6746

What's Wrong?

The lateral view + subquery leads to the error join predicate equal join conjunct: `k3` = `k3`

What You Expected?

Only one join predicate equal join conjunct: `k1` = `k3`

How to Reproduce?

Steps:

  1. create table
CREATE TABLE `test_explode` (
  `k1` int(11) NULL COMMENT "",
  `k2` varchar(1) NULL COMMENT ""
) ENGINE=OLAP
DUPLICATE KEY(`k1`)
COMMENT "OLAP"
DISTRIBUTED BY HASH(`k1`) BUCKETS 5
PROPERTIES (
"replication_allocation" = "tag.location.default: 1",
"in_memory" = "false",
"storage_format" = "V2"
) 
  1. query
MySQL [test]> explain select k1 from test_explode lateral view explode_split(k2, ",") tmp as e1  where k1 in (select k3 from tbl1);
+--------------------------------------------------------------------------------------+
| Explain String                                                                       |
+--------------------------------------------------------------------------------------+
| PLAN FRAGMENT 0                                                                      |
|  OUTPUT EXPRS:`k1`                                                                   |
|   PARTITION: UNPARTITIONED                                                           |
|                                                                                      |
|   RESULT SINK                                                                        |
|                                                                                      |
|   6:EXCHANGE                                                                         |
|                                                                                      |
| PLAN FRAGMENT 1                                                                      |
|  OUTPUT EXPRS:                                                                       |
|   PARTITION: HASH_PARTITIONED: `k3`, `k1`                                            |
|                                                                                      |
|   STREAM DATA SINK                                                                   |
|     EXCHANGE ID: 06                                                                  |
|     UNPARTITIONED                                                                    |
|                                                                                      |
|   3:HASH JOIN                                                                        |
|   |  join op: LEFT SEMI JOIN (PARTITIONED)                                           |
|   |  hash predicates:                                                                |
|   |  colocate: false, reason: The src data has been redistributed                    |
|   |  equal join conjunct: `k3` = `k3`                                                |
|   |  equal join conjunct: `k1` = `k3`                                                |
|   |  runtime filters: RF000[in] <- `k3`                                              |
|   |  cardinality=-1                                                                  |
|   |                                                                                  |
|   |----5:EXCHANGE                                                                    |
|   |                                                                                  |
|   4:EXCHANGE                                                                         |
|                                                                                      |
| PLAN FRAGMENT 2                                                                      |
|  OUTPUT EXPRS:                                                                       |
|   PARTITION: HASH_PARTITIONED: `default_cluster:test`.`tbl1`.`k1`                    |
|                                                                                      |
|   STREAM DATA SINK                                                                   |
|     EXCHANGE ID: 05                                                                  |
|     HASH_PARTITIONED: `k3`, `k3`                                                     |
|                                                                                      |
|   2:OlapScanNode                                                                     |
|      TABLE: tbl1                                                                     |
|      PREAGGREGATION: OFF. Reason: No AggregateInfo                                   |
|      partitions=1/1                                                                  |
|      rollup: tbl1                                                                    |
|      tabletRatio=3/3                                                                 |
|      tabletList=14007,14009,14011                                                    |
|      cardinality=1                                                                   |
|      avgRowSize=983.0                                                                |
|      numNodes=2                                                                      |
|                                                                                      |
| PLAN FRAGMENT 3                                                                      |
|  OUTPUT EXPRS:                                                                       |
|   PARTITION: HASH_PARTITIONED: `default_cluster:test`.`test_explode`.`k1`            |
|                                                                                      |
|   STREAM DATA SINK                                                                   |
|     EXCHANGE ID: 04                                                                  |
|     HASH_PARTITIONED: `k3`, `k1`                                                     |
|                                                                                      |
|   1:TABLE FUNCTION NODE                                                              |
|   |  table function: explode_split(`default_cluster:test`.`test_explode`.`k2`, ',')  |
|   |  lateral view tuple id: 1                                                        |
|   |  output slot id: 2                                                               |
|   |  cardinality=-1                                                                  |
|   |                                                                                  |
|   0:OlapScanNode                                                                     |
|      TABLE: test_explode                                                             |
|      PREAGGREGATION: ON                                                              |
|      runtime filters: RF000[in] -> `k1`                                              |
|      partitions=1/1                                                                  |
|      rollup: test_explode                                                            |
|      tabletRatio=5/5                                                                 |
|      tabletList=17010,17012,17014,17016,17018                                        |
|      cardinality=1                                                                   |
|      avgRowSize=842.0                                                                |
|      numNodes=2                                                                      |
+--------------------------------------------------------------------------------------+
73 rows in set (2 min 19.321 sec)

Anything Else?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions