implement pg data source function