apache / apache/drill

union duplicate key

Open
#2,873 5 comments 0 reactions 0 assignees View on GitHub
to-be-verified
Dominant language
Java
Stars
2k
Forks
990
Avg merge
1d 8h
Merged PRs (30d)
5

Description

mysql table baseall and table test has the same tale struct and recored

show create table baseall;
+---------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+---------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| baseall | CREATE TABLE `baseall` (
`k0` tinyint(1) DEFAULT NULL,
`k1` tinyint DEFAULT NULL,
`k2` smallint DEFAULT NULL,
`k3` int DEFAULT NULL,
`k4` bigint DEFAULT NULL,
`k5` decimal(9,3) DEFAULT NULL,
`k6` char(5) DEFAULT NULL,
`k10` date DEFAULT NULL,
`k11` datetime DEFAULT NULL,
`k7` varchar(20) DEFAULT NULL,
`k8` double DEFAULT NULL,
`k9` float DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci |
+---------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

show create table test;
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| test | CREATE TABLE `test` (
`k0` tinyint(1) DEFAULT NULL,
`k1` tinyint DEFAULT NULL,
`k2` smallint DEFAULT NULL,
`k3` int DEFAULT NULL,
`k4` bigint DEFAULT NULL,
`k5` decimal(9,3) DEFAULT NULL,
`k6` char(5) DEFAULT NULL,
`k10` date DEFAULT NULL,
`k11` datetime DEFAULT NULL,
`k7` varchar(20) DEFAULT NULL,
`k8` double DEFAULT NULL,
`k9` float DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci |
+-------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

execute sql as follow:
SELECT *
FROM
(SELECT *
FROM
(SELECT `k1`, `k2`, `k3`, `k4`, `k5`, `k6`, `k10`, `k11`, `k7`, `k8`, `k9`
FROM `test`.`baseall`) AS `t`
LEFT JOIN
(SELECT `k1`, `k2`, `k3`, `k4`, `k5`, `k6`, `k10`, `k11`, `k7`, `k8`, `k9`
FROM `test`.`test`) AS `t0`
ON
`t`.`k1` = `t0`.`k1`
UNION
SELECT *
FROM
(SELECT `k1`, `k2`, `k3`, `k4`, `k5`, `k6`, `k10`, `k11`, `k7`, `k8`, `k9`
FROM `test`.`baseall`) AS `t1`
RIGHT JOIN
(SELECT `k1`, `k2`, `k3`, `k4`, `k5`, `k6`, `k10`, `k11`, `k7`, `k8`, `k9`
FROM `test`.`test`) AS `t2`
ON
`t1`.`k1` = `t2`.`k1`) AS `t`
LIMIT 1000

report error Duplicated inline view column alias k1 in inline view t

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by running the reproduced UNION, JOIN, and inline-view SQL against the two matching MySQL tables and confirm the duplicated inline-view column alias k1 error. Trace the query-processing entry point that reports this error; done means the query executes without the reported duplicate-alias failure and existing behavior remains covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, sql
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.