Code of Civil Procedure § 1989
CHAPTER 2. Means of Production
A witness, including a witness specified in subdivision (b) of Section 1987, is not obliged to attend as a witness before any court, judge, justice or any other officer, unless the witness is a resident within the state at the time of service.