private Pair<Boolean, Integer> isSupported(RexNode node) {
    int numberOfInputRefs = 0;
    boolean isSupported = true;

    if (node instanceof RexCall) {
      RexCall compositeNode = (RexCall) node;

      // Only support comparisons in a predicate, some sql functions such as:
      //  CAST, TRIM? and REVERSE? should be supported as well.
      if (!node.getKind().belongsTo(SUPPORTED_OPS)) {
        isSupported = false;
      } else {
        for (RexNode operand : compositeNode.getOperands()) {
          // All operands must be supported for a parent node to be supported.
          Pair<Boolean, Integer> childSupported = isSupported(operand);
          // BigQuery supports complex combinations of both conjunctions (AND) and disjunctions
          // (OR).
          if (!node.getKind().belongsTo(ImmutableSet.of(AND, OR))) {
            numberOfInputRefs += childSupported.getRight();
          }
          // Predicate functions, where more than one field is involved are unsupported.
          isSupported = numberOfInputRefs < 2 && childSupported.getLeft();
        }
      }
    } else if (node instanceof RexInputRef) {
      numberOfInputRefs = 1;
    } else if (node instanceof RexLiteral) {
      // RexLiterals are expected, but no action is needed.
    } else {
      throw new UnsupportedOperationException(
          "Encountered an unexpected node type: " + node.getClass().getSimpleName());
    }

    return Pair.of(isSupported, numberOfInputRefs);
  }
@Test
  public void testIsSupported() {
    ImmutableList<Pair<String, Boolean>> sqlQueries =
        ImmutableList.of(
            Pair.of("select * from TEST where unused1=100", true),
            Pair.of("select * from TEST where unused1 in (100, 200)", true),
            Pair.of("select * from TEST where unused1+10=110", true),
            Pair.of("select * from TEST where b", true),
            Pair.of(
                "select * from TEST where unused1>100 and unused1<=200 and id<>1 and (name='two' or id=2)",
                true),
            Pair.of("select * from TEST where unused2=200", true),
            Pair.of("select * from TEST where name like 'o%e'", true),
            // Functions involving more than one column are not supported yet.
            Pair.of("select * from TEST where unused1=unused2 and id=2", false),
            Pair.of("select * from TEST where unused1+unused2=10", false));

    for (Pair<String, Boolean> query : sqlQueries) {
      String sql = query.getLeft();
      Boolean isSupported = query.getRight();

      BeamRelNode beamRelNode = sqlEnv.parseQuery(sql);
      assertThat(beamRelNode, instanceOf(BeamCalcRel.class));
      BigQueryFilter filter =
          new BigQueryFilter(((BeamCalcRel) beamRelNode).getProgram().split().right);

      assertThat(
          "Query: '" + sql + "' is expected to be " + (isSupported ? "supported." : "unsupported."),
          filter.getNotSupported().isEmpty() == isSupported);
    }
  }