Could be inspired from this: https://github.com/GoogleCloudDataproc/spark-bigquery-connector/pull/736/