konstantinb commented on code in PR #6014:
URL: https://github.com/apache/hive/pull/6014#discussion_r2273730730


##########
ql/src/test/queries/clientpositive/lateral_view_cartesian_test.q:
##########
@@ -0,0 +1,172 @@
+-- HIVE-29084: LATERAL VIEW cartesian product schema construction
+DROP TABLE IF EXISTS src_lv_cart;
+CREATE TABLE src_lv_cart (val_array array<string>);
+INSERT INTO src_lv_cart VALUES (array('a', 'b'));
+
+SELECT first_val, second_val
+FROM src_lv_cart
+LATERAL VIEW explode(val_array) lv1 AS first_val
+LATERAL VIEW explode(val_array) lv2 AS second_val
+WHERE first_val != second_val
+ORDER BY first_val, second_val;
+
+SELECT first_val, second_val
+FROM (SELECT array('a', 'b') AS val_array) src
+LATERAL VIEW explode(val_array) lv1 AS first_val
+LATERAL VIEW explode(val_array) lv2 AS second_val
+WHERE first_val != second_val
+ORDER BY first_val, second_val;
+
+SELECT lv1.val1, lv2.val2, lv3.val3
+FROM (SELECT array('x', 'y') AS arr) src
+LATERAL VIEW explode(arr) lv1 AS val1
+LATERAL VIEW explode(arr) lv2 AS val2
+LATERAL VIEW explode(arr) lv3 AS val3
+WHERE lv1.val1 != lv2.val2 AND lv2.val2 != lv3.val3
+ORDER BY lv1.val1, lv2.val2, lv3.val3;
+
+SELECT first_val, second_val
+FROM (SELECT array('p', 'q', 'r') AS val_array) src
+LATERAL VIEW explode(val_array) lv1 AS first_val
+LATERAL VIEW explode(val_array) lv2 AS second_val
+WHERE first_val = 'p' OR second_val = 'r'
+ORDER BY first_val, second_val;
+
+SET hive.cbo.enable=false;
+SELECT first_val, second_val
+FROM (SELECT array('m', 'n') AS val_array) src
+LATERAL VIEW explode(val_array) lv1 AS first_val
+LATERAL VIEW explode(val_array) lv2 AS second_val
+WHERE first_val != second_val
+ORDER BY first_val, second_val;
+
+SET hive.cbo.enable=true;

Review Comment:
   @zabetak
   
   The original bug originated from different results, accurate with 
hive.cbo.enable=false and inaccurate with hive.cbo.enable=true
   
   This was the main reason for including these tests, but, technically, after 
my fix, there should be no difference with either true or false. If there is no 
need of ensuring the matching results regardless on whether CBO is enabled or 
disabled, I will be happy to drop these redundancies



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to