0
DrillインスタンスにリンクされたPostgreSQLデータベースがあります。Apache Drillが異なるテーブルの同じ名前を持つ列を選択する理由
カラムが両方ともname
の2つのテーブルを結合しようとするときはいつでも、これを選択するときはいつでもname
ドリルが間違ったname
カラムを選択します。私は間違って何をしていますか?
select employee.name, employee.salary
from employee
inner join department on employee.dept = department.id
where department.name = 'A'
戻り
| name | salary |
|------|--------|
| A | 100 |
| A | 75 |
| A | 120 |
のRuを実行
Department
| id | name |
|----|------|
| 1 | A |
| 2 | B |
Employee
| id | name | dept | salary |
|----|------|------|--------|
| 1 | U | 1 | 100 |
| 2 | V | 1 | 75 |
| 3 | W | 1 | 120 |
| 4 | X | 2 | 95 |
| 5 | Y | 2 | 140 |
| 6 | Z | 2 | 55 |
:以下の2つのテーブルを考えると
nning
select dept.name, employee.salary
from employee
inner join department on employee.dept = department.id
where department.name = 'A'
戻り
作業を行いますが、私には非常に愚かなようで何| name | salary |
|------|--------|
| null | 100 |
| null | 75 |
| null | 120 |
は、次のとおりです。あなたが
を使用しているため
select dept.name, employee.salary
from employee
inner join (select id, name as deptname from department) as department on employee.dept = department.id
where department.deptname = 'A'
ご返信ありがとうございます。言い換えれば、私は別名「部署」としました。明らかにこれを引き起こすDrillのバグがあります:https://issues.apache.org/jira/browse/DRILL-5713 –
私は 'name'カラムに* null *を返す最初のクエリを意味しました。しかし、バグに頭をアップしてくれてありがとう。 – tobi6