public static boolean isLiteral(RexNode expr) {
    if (expr instanceof RexCall) {
      RexCall call = (RexCall) expr;
      if (call.getOperator() == SqlStdOperatorTable.ROW ||
          call.getOperator() == SqlStdOperatorTable.ARRAY_VALUE_CONSTRUCTOR ||
          call.getOperator() == SqlStdOperatorTable.MAP_VALUE_CONSTRUCTOR) {
        // We check all operands
        for (RexNode node : call.getOperands()) {
          if (!isLiteral(node)) {
            return false;
          }
        }
        // All literals
        return true;
      }
    }
    return expr.isA(SqlKind.LITERAL);
  }
Check if the expression is usable for query materialization, returning the first failing expression.
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/HiveCalciteUtil.java