diff --git a/presto-tests/src/main/java/com/facebook/presto/tests/TestExcludeColumnsFunction.java b/presto-tests/src/main/java/com/facebook/presto/tests/TestExcludeColumnsFunction.java index f55c66626cefe..13cda70359823 100644 --- a/presto-tests/src/main/java/com/facebook/presto/tests/TestExcludeColumnsFunction.java +++ b/presto-tests/src/main/java/com/facebook/presto/tests/TestExcludeColumnsFunction.java @@ -197,4 +197,28 @@ public void testBigInput() " columns => DESCRIPTOR(orderstatus, orderdate, orderpriority, clerk, shippriority, comment)))\n", "SELECT orderkey, custkey, totalprice FROM tpch.tiny.orders"); } + + @Test + public void testExcludeColumnsLateralJoin() + { + // Test LATERAL join with exclude_columns function + // This tests using exclude_columns in a lateral join context with filtering + assertQuery("SELECT n.nationkey, filtered.* " + + "FROM tpch.tiny.nation n " + + "CROSS JOIN LATERAL (" + + " SELECT * " + + " FROM TABLE(" + + " system.builtin.exclude_columns(" + + " input => table(tpch.tiny.region)," + + " columns => descriptor(comment)" + + " )" + + " ) r " + + " WHERE r.regionkey = n.regionkey" + + ") filtered " + + "WHERE n.nationkey < 5", + "SELECT n.nationkey, r.regionkey, r.name " + + "FROM tpch.tiny.nation n " + + "JOIN tpch.tiny.region r ON r.regionkey = n.regionkey " + + "WHERE n.nationkey < 5"); + } } diff --git a/presto-tests/src/main/java/com/facebook/presto/tests/TestSequenceFunction.java b/presto-tests/src/main/java/com/facebook/presto/tests/TestSequenceFunction.java index dd6bc1b8946aa..ad283337ea60a 100644 --- a/presto-tests/src/main/java/com/facebook/presto/tests/TestSequenceFunction.java +++ b/presto-tests/src/main/java/com/facebook/presto/tests/TestSequenceFunction.java @@ -288,4 +288,22 @@ public void testEdgeValues() " step => %s)) t(x)", start, stop, step), format("SELECT %s, %s", start, Long.MAX_VALUE - 1)); } + + @Test + public void testSequenceLateralJoin() + { + // Test LATERAL join with sequence function + // This tests using sequence in a lateral join context with filtering + assertQuery("SELECT t.nationkey, s.seq " + + "FROM tpch.tiny.nation t " + + "CROSS JOIN LATERAL (" + + " SELECT * " + + " FROM TABLE(system.builtin.sequence(start => 1, stop => 5))" + + ") AS s(seq) " + + "WHERE t.nationkey < 3 AND s.seq <= t.regionkey", + "SELECT t.nationkey, s.seq " + + "FROM tpch.tiny.nation t " + + "CROSS JOIN UNNEST(sequence(1, 5)) AS s(seq) " + + "WHERE t.nationkey < 3 AND s.seq <= t.regionkey"); + } }