No person is obliged to attend as a witness before a court or magistrate out of the county where the witness resides, or is served with the subpoena, unless the distance be less than 150 miles from his or her place of residence to the place of trial, or unless the judge of the court in which the offense is triable, or a justice of the Supreme Court, or a judge of a superior court, or, in the case of a minor concerning whom a petition has been filed pursuant to Article 16 (commencing with Section 650) of Chapter 2 of Part 1 of Division 2 of the Welfare and Institutions Code, by the judge of the juvenile court hearing the petition, upon an affidavit of the district attorney or prosecutor, or of the defendant, or his or her counsel, or in the case involving a minor in whose behalf a petition has been filed in the juvenile court, of the probation officer approving the filing of the petition or of any party to the action, or his or her counsel, stating that he or she believes the evidence of the witness is material, and his or her attendance at the examination, trial, or hearing is material and necessary, shall endorse on the subpoena an order for the attendance of the witness.
When a subpoena duces tecum is duly issued according to any other provision of law and is served upon a custodian of records or other qualified witness as provided in Article 4 (commencing with Section 1560) of Chapter 2 of Division 11 of the Evidence Code, and his or her personal attendance is not required by the terms of the subpoena, the limitations of this section shall not apply.
Ca. Pen. Code § 1330