0

I have the following code where I am trying to create a relational algebra: final RelNode relNode = relBuilder.scan(index).build();

I am looking for a sample code where I can create a SELECE and WHERE clause in the above code.

1 Answers1

0

Have you read the documentation? There are several examples there.

final RelNode node = builder
  .scan("EMP")
  .aggregate(builder.groupKey("DEPTNO"),
      builder.count(false, "C"),
      builder.sum(false, "S", builder.field("SAL")))
  .filter(
      builder.call(SqlStdOperatorTable.GREATER_THAN,
          builder.field("C"),
          builder.literal(10)))
  .build();
System.out.println(RelOptUtil.toString(node));

is equivalent to SQL

SELECT deptno, count(*) AS c, sum(sal) AS s
FROM emp
GROUP BY deptno
HAVING count(*) > 10
Michael Mior
  • 28,107
  • 9
  • 89
  • 113