Skip to content
Open
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 @@ -18,6 +18,7 @@

import org.apache.calcite.adapter.java.JavaTypeFactory;
import org.apache.calcite.linq4j.EnumerableDefaults;
import org.apache.calcite.linq4j.function.Function1;
import org.apache.calcite.linq4j.tree.BlockBuilder;
import org.apache.calcite.linq4j.tree.Expression;
import org.apache.calcite.linq4j.tree.Expressions;
Expand Down Expand Up @@ -530,9 +531,12 @@ public static EnumerableMergeJoin create(RelNode left, RelNode right,
Expressions.list(
leftExpression,
rightExpression,
Expressions.lambda(
// Force Function1: a single BOOLEAN key would otherwise
// deduce Predicate1, which does not match the signature of
// EnumerableDefaults.mergeJoin
Expressions.lambda(Function1.class,
leftKeyPhysType.record(leftExpressions), left_),
Expressions.lambda(
Expressions.lambda(Function1.class,
rightKeyPhysType.record(rightExpressions), right_),
predicate,
EnumUtils.joinSelector(joinType,
Expand Down
35 changes: 35 additions & 0 deletions core/src/test/resources/sql/sub-query.iq
Original file line number Diff line number Diff line change
Expand Up @@ -10150,5 +10150,40 @@ ORDER BY emp.ename;
+--------+------------+
(8 rows)

!ok

!use scott

# Test case for [CALCITE-7334] Compiling the generated Java code throws an exception when
# a scalar sub-query is used in the SELECT list.
# Result validated against PostgreSQL 14.
select
(SELECT
COUNT(*)
FROM
"scott".emp
WHERE
v.empno >= 2), 3
from "scott".emp as v;
+--------+--------+
| EXPR$0 | EXPR$1 |
+--------+--------+
| 14 | 3 |
| 14 | 3 |
| 14 | 3 |
| 14 | 3 |
| 14 | 3 |
| 14 | 3 |
| 14 | 3 |
| 14 | 3 |
| 14 | 3 |
| 14 | 3 |
| 14 | 3 |
| 14 | 3 |
| 14 | 3 |
| 14 | 3 |
+--------+--------+
(14 rows)

!ok
# End sub-query.iq
Loading