Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
package com.facebook.presto.execution;

import com.facebook.presto.sql.tree.DefaultTraversalVisitor;
import com.facebook.presto.sql.tree.LambdaArgumentDeclaration;
import com.facebook.presto.sql.tree.LambdaExpression;
import com.facebook.presto.sql.tree.Parameter;
import com.facebook.presto.sql.tree.Statement;

Expand Down Expand Up @@ -54,5 +56,15 @@ public Void visitParameter(Parameter node, Void context)
parameters.add(node);
return null;
}

@Override
protected Void visitLambdaExpression(LambdaExpression node, Void context)
Comment on lines 60 to 61
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is a legit change; but really would love to have @rschlussel to double check. If prepared statement is going to collect ? in sequence, this visitor shouldn't mess the sequence up or make any damage to the scope (which I assume parameters don't care about scopes).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, this looks good.

{
process(node.getBody(), context);
for (LambdaArgumentDeclaration argument : node.getArguments()) {
process(argument, context);
}
return null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,12 @@ public void testPreparedStatementWithSubqueries()
// prepared statement is not supported by Presto on Spark
}

@Override
public void testExecuteWithParametersInLambda()
{
// prepared statement is not supported by Presto on Spark
}

@Override
public void testExplainDdl()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4870,6 +4870,17 @@ public void testExecuteUsingWithSubquery()
"SELECT 10 in (SELECT orderkey FROM orders)");
}

@Test
public void testExecuteWithParametersInLambda()
{
String query = "SELECT filter(array[1, 2, 3], x -> x > ?)";
Session session = Session.builder(getSession())
.addPreparedStatement("my_query", query)
.build();

assertQuery(session, "EXECUTE my_query USING 2", "SELECT array[3]");
}

@Test
public void testExecuteWithParametersInGroupBy()
{
Expand Down Expand Up @@ -5725,9 +5736,9 @@ public void testMapUnionSumOverflow()
{
assertQueryFails(
"select y, map_union_sum(x) from (select 1 y, map(array['x', 'z', 'y'], cast(array[null,30,100] as array<tinyint>)) x " +
"union all select 1 y, map(array['x', 'y'], cast(array[1,100] as array<tinyint>))x) group by y", ".*Value 200 exceeds MAX_BYTE.*");
"union all select 1 y, map(array['x', 'y'], cast(array[1,100] as array<tinyint>))x) group by y", ".*Value 200 exceeds MAX_BYTE.*");
assertQueryFails(
"select y, map_union_sum(x) from (select 1 y, map(array['x', 'z', 'y'], cast(array[null,30, 32760] as array<smallint>)) x " +
"union all select 1 y, map(array['x', 'y'], cast(array[1,100] as array<smallint>))x) group by y", ".*Value 32860 exceeds MAX_SHORT.*");
"union all select 1 y, map(array['x', 'y'], cast(array[1,100] as array<smallint>))x) group by y", ".*Value 32860 exceeds MAX_SHORT.*");
Comment on lines 5728 to 5742
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accidental change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is changed by the formatter automatically. The previous format seems incorrect because there is a + in the previous line.

}
}