union duplicate key

Open
#2,873 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

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.

Description

to-be-verified

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

Dominant language
Java
Stars
2k
Forks
989
Avg merge
1d 8h
Merged PRs (30d)
5

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/drill

All issues in apache/drill

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.