Skip to content
Advertisement

Can’t found the poroblem within this Hive Query [closed]

EDIT: Sorry, I’ve just realised I was naming equal both fee and foo columns. Now it’s corrected

I’m trying to do an inner join between 2 tables in Hive in GCP. The problem is that this join needs to be done with the mutual join of 2 variables. This is my query:

CREATE VIEW IF NOT EXISTS table_foofee AS
SELECT foo.atr1, foo.atr2, fee.atrA, fee.atrB
FROM table_foo foo
JOIN table_fee fee
ON foo.atr9 = fee.atr9 and foo.atr10 = fee.atr10;

An examploea of each tables:

# foo
atr1 atr2 ... atr9 atr10
1     0.7      1    01/01/05
0.78  0.1      1    01/02/05
1.7   0.4      1    01/03/05
0.1    0       1    01/04/05
1     0.78      2   01/01/05
0     0.44      2   01/02/05
        ....

#fee
atrA atrB ... atr9 atr10
10   0.47      1    01/01/05
0.8  0.2       1    01/02/05
3    0.41      1    01/03/05
4.1   1        1    01/04/05
2     0.7      2   01/01/05
1.78  0.34     2   01/02/05
        ....

As you can seem both atr9 and atr10 are equals. I receive no error but an empty view. What is wrong with that query?

Advertisement

Answer

As you can seem both atr9 and atr10 are equals.

No, we can’t see this.

I receive no error but an empty view. Normal your query is correct

What is wrong with that query? Nothing

To uderstand, you have to change the query with LEFT OR RIGHT JOIN and see the result, you’ll see some null result facing not null result and you have to understand why there are some differnces.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement