Query the Data Delivery Network
Query the DDNThe easiest way to query any data on Splitgraph is via the "Data Delivery Network" (DDN). The DDN is a single endpoint that speaks the PostgreSQL wire protocol. Any Splitgraph user can connect to it at data.splitgraph.com:5432
and query any version of over 40,000 datasets that are hosted or proxied by Splitgraph.
For example, you can query the individual_provider_network_data_2017
table in this repository, by referencing it like:
"health-data-ny-gov/individual-provider-network-data-2017-eshx-ep38:latest"."individual_provider_network_data_2017"
or in a full query, like:
SELECT
":id", -- Socrata column ID
"pace_indicator", -- 0=No 1=Yes
"nysoh_indiv_st_silver", -- 0=No 1=Yes
"nysoh_shop_non_st_platinum_1", -- 0=No 1=Yes
"nysoh_shop_non_st_bronze_1", -- 0=No 1=Yes
"longitude",
"wheel_chair_accessibility", -- 0=No 1=Yes
"primary_designation", -- 1=PCP 2=Specialist 3=PCP and Specialist
"national_provider_identifier", -- NPI, 10 digits only
"first_name", -- First name of provider
"pndsid", -- ID associated with plan submitter
"nysoh_shop_non_st_bronze_3", -- 0=No 1=Yes
"nysoh_shop_non_st_bronze_2", -- 0=No 1=Yes
"nysoh_indiv_st_bronze", -- 0=No 1=Yes
"nysoh_indiv_non_st_silver_1", -- 0=No 1=Yes
"nysoh_indiv_adult_dental", -- 0=No 1=Yes
"nysoh_indiv_pediatric_dental_low", -- 0=No 1=Yes
"nysoh_indiv_catastrophic", -- 0=No 1=Yes
"nysoh_indiv_child_only_platinum", -- 0=No 1=Yes
"nysoh_indiv_child_only_gold", -- 0=No 1=Yes
"language_7", -- See Appendix VI of PNDS Data Dictionary at https://www.health.ny.gov/health_care/managed_care/docs/dictionary.pdf
"provider_location_permanent_facility_identifier_pfi", -- For PCPs only See Operating Facility Codes
"prov_operating_number",
"ha_permanent_facility_identifier_pfi_1", -- Corresponds to HA OPCERT #1
"hospital_affiliation_ha_operating_certificate_opcert_1", -- See Operating Facility codes 99999999=Not Applicable (for non-PCP, non-OB/GYN)
"nysoh_indiv_st_platinum", -- 0=No 1=Yes
"partial_caps_indicator", -- 0=No 1=Yes
"nysoh_indiv_family_dental", -- 0=No 1=Yes
"nysoh_indiv_non_st_bronze_2", -- 0=No 1=Yes
"board_status_primary_specialty", -- 1=Not Board Cert; Residency Incomplete 2=Not Board Certified; Residency Complete. 3=Board Certified 4=No Board Cert Avail 9=Not Applicable
"nysoh_indiv_non_st_silver_2", -- 0=No 1=Yes
"borough_county_code", -- FIPS code
"nysoh_indiv_non_st_platinum_2", -- 0=No 1=Yes
"nysoh_indiv_non_st_bronze_3", -- 0=No 1=Yes
"state_std", -- Standardized state name
"plan_name", -- Name of plan submitter
"street_address", -- Address 1
"nysoh_shop_non_st_silver_3", -- 0=No 1=Yes
"nysoh_shop_non_st_silver_1", -- 0=No 1=Yes
"nysoh_shop_st_platinum", -- 0=No 1=Yes
"nysoh_shop_st_gold", -- 0=No 1=Yes
"board_status_secondary_specialty", -- 1=Not Board Cert; Residency Incomplete 2=Not Board Certified; Residency Complete. 3=Board Certified 4=No Board Cert Avail
"nysoh_shop_non_st_gold_1", -- 0=No 1=Yes
"nysoh_shop_pediatric_dental_high", -- 0=No 1=Yes
"map_indicator", -- 0=No 1=Yes
"nysoh_shop_st_silver", -- 0=No 1=Yes
"commercial_non_mco_dental_indicator", -- 0=No 1=Yes
"nysoh_shop_non_st_gold_2", -- 0=No 1=Yes
"nysoh_shop_family_dental", -- 0=No 1=Yes
"nysoh_shop_non_st_platinum_2", -- 0=No 1=Yes
"latitude",
"nysoh_shop_adult_dental", -- 0=No 1=Yes
"nysoh_shop_st_bronze", -- 0=No 1=Yes
"medicaid_provider_indicator", -- 0=No 1=Yes
"language_5", -- See Appendix VI of PNDS Data Dictionary at https://www.health.ny.gov/health_care/managed_care/docs/dictionary.pdf
"nysoh_shop_non_st_gold_3", -- 0=No 1=Yes
"nysoh_shop_non_st_silver_2", -- 0=No 1=Yes
"nysoh_indiv_non_st_bronze_1", -- 0=No 1=Yes
"nysoh_indiv_non_st_gold_2", -- 0=No 1=Yes
"nysoh_indiv_non_st_gold_1", -- 0=No 1=Yes
"nysoh_indiv_child_only_bronze", -- 0=No 1=Yes
"nysoh_shop_pediatric_dental_low", -- 0=No 1=Yes
"language_3", -- See Appendix VI of PNDS Data Dictionary at https://www.health.ny.gov/health_care/managed_care/docs/dictionary.pdf
"fida_indicator", -- 0=No 1=Yes
"last_name", -- Last name of provider
"child_health_plus_chp_provider_indicator", -- 0=No 1=Yes
"nysoh_indiv_st_gold", -- 0=No 1=Yes
"nysoh_indiv_child_only_silver", -- 0=No 1=Yes
"commercial_non_mco_medical_indicator", -- 0=No 1=Yes
"nysoh_indiv_pediatric_dental_high", -- 0=No 1=Yes
"harp_indicator", -- 0=No 1=Yes
"language_4", -- See Appendix VI of PNDS Data Dictionary at https://www.health.ny.gov/health_care/managed_care/docs/dictionary.pdf
"nysoh_indiv_non_st_silver_3", -- 0=No 1=Yes
"nysoh_shop_non_st_platinum_3", -- 0=No 1=Yes
"commercial_non_mco_vision_indicator", -- 0=No 1=Yes
"quarter",
"nysoh_indiv_non_st_platinum_1", -- 0=No 1=Yes
"medicaid_advantage_indicator", -- 0=No 1=Yes
"gender", -- 1=Male 2=Female
"commercial_provider_indicator", -- 0=No 1=Yes
"nysoh_indiv_non_st_platinum_3", -- 0=No 1=Yes
"nysoh_standard_essential_plan_ep_indicator", -- 0=No 1=Yes
"nysoh_ep_plus_adult_vision_dental_indicator", -- 0=No 1=Yes
"hospital_affiliation_ha_operating_certificate_opcert_2", -- See Operating Facility codes 99999999=Not Applicable (for non-PCP, non-OB/GYN)
"nysoh_indiv_non_st_gold_3", -- 0=No 1=Yes
"ha_permanent_facility_identifier_pfi_2", -- Corresponds to HA OPCERT #2
"hospital_affiliation_ha_operating_certificate_opcert_3", -- See Operating Facility codes 99999999=Not Applicable (for non-PCP)
"ha_permanent_facility_identifier_pfi_3", -- Corresponds to HA OPCERT #3
"language_1", -- See Appendix VI of PNDS Data Dictionary at https://www.health.ny.gov/health_care/managed_care/docs/dictionary.pdf
"secondary_specialty", -- See Appendix
"language_2", -- See Appendix VI of PNDS Data Dictionary at https://www.health.ny.gov/health_care/managed_care/docs/dictionary.pdf
"primary_specialty", -- See Appendix
"provider_type", -- 01=MD 02=CNP Nurse Practitioner 03=CNM 04=CSW 05=Clinical Psych 06=OD Optometrist 08=DDS 09=DPM Podiatrist 10=Chiropractor 11=Other 12=DO 14=Psychologist 15=Counselor 16=Social Work 18=DMD 19=OMS 20=Acupuncturist 22=RN 23=Physician Assistant (PA) 30=Audiologist 40=CDN Dietician/Nutritionist 50=CM (not a nurse) 60=PT 61=OT 62=SLP 63=CFY 64=RT
"zip_code", -- Standardized zip code
"true_county", -- County Name
"town_city", -- Standardized city name
"language_6", -- See Appendix VI of PNDS Data Dictionary at https://www.health.ny.gov/health_care/managed_care/docs/dictionary.pdf
"room_or_suite", -- If Not Applicable “NA”
"site_name" -- Office or Professional Building
FROM
"health-data-ny-gov/individual-provider-network-data-2017-eshx-ep38:latest"."individual_provider_network_data_2017"
LIMIT 100;
Connecting to the DDN is easy. All you need is an existing SQL client that can connect to Postgres. As long as you have a SQL client ready, you'll be able to query health-data-ny-gov/individual-provider-network-data-2017-eshx-ep38
with SQL in under 60 seconds.
This repository is an "external" repository. That means it's hosted elsewhere, in this case at health.data.ny.gov. When you queryhealth-data-ny-gov/individual-provider-network-data-2017-eshx-ep38:latest
on the DDN, we "mount" the repository using the socrata
mount handler. The mount handler proxies your SQL query to the upstream data source, translating it from SQL to the relevant language (in this case SoQL).
We also cache query responses on the DDN, but we run the DDN on multiple nodes so a CACHE_HIT
is only guaranteed for subsequent queries that land on the same node.
Query Your Local Engine
bash -c "$(curl -sL https://github.com/splitgraph/splitgraph/releases/latest/download/install.sh)"
Read the installation docs.
Splitgraph Cloud is built around Splitgraph Core (GitHub), which includes a local Splitgraph Engine packaged as a Docker image. Splitgraph Cloud is basically a scaled-up version of that local Engine. When you query the Data Delivery Network or the REST API, we mount the relevant datasets in an Engine on our servers and execute your query on it.
It's possible to run this engine locally. You'll need a Mac, Windows or Linux system to install sgr
, and a Docker installation to run the engine. You don't need to know how to actually use Docker; sgr
can manage the image, container and volume for you.
There are a few ways to ingest data into the local engine.
For external repositories (like this repository), the Splitgraph Engine can "mount" upstream data sources by using sgr mount
. This feature is built around Postgres Foreign Data Wrappers (FDW). You can write custom "mount handlers" for any upstream data source. For an example, we blogged about making a custom mount handler for HackerNews stories.
For hosted datasets, where the author has pushed Splitgraph Images to the repository, you can "clone" and/or "checkout" the data using sgr clone
and sgr checkout
.
Mounting Data
This repository is an external repository. It's not hosted by Splitgraph. It is hosted by health.data.ny.gov, and Splitgraph indexes it. This means it is not an actual Splitgraph image, so you cannot use sgr clone
to get the data. Instead, you can use the socrata
adapter with the sgr mount
command. Then, if you want, you can import the data and turn it into a Splitgraph image that others can clone.
First, install Splitgraph if you haven't already.
Mount the table with sgr mount
sgr mount socrata \
"health-data-ny-gov/individual-provider-network-data-2017-eshx-ep38" \
--handler-options '{
"domain": "health.data.ny.gov",
"tables": {
"individual_provider_network_data_2017": "eshx-ep38"
}
}'
That's it! Now you can query the data in the mounted table like any other Postgres table.
Query the data with your existing tools
Once you've loaded the data into your local Splitgraph engine, you can query it with any of your existing tools. As far as they're concerned, health-data-ny-gov/individual-provider-network-data-2017-eshx-ep38
is just another Postgres schema.