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 common_medical_procedure_prices_in_utah_in_2021
table in this repository, by referencing it like:
"opendata-utah-gov/common-medical-procedure-prices-in-utah-in-2021-hy48-n2gd:latest"."common_medical_procedure_prices_in_utah_in_2021"
or in a full query, like:
SELECT
":id", -- Socrata column ID
"icd_10_pcs_procedure_code", -- This element applies only to acute inpatient claims. The primary ICD-10 Procedure code as reported on the claim
"calculated_allowedamount_4", -- The 75th percentile allowed amount for an entire claim containing the given procedure.
"calculated_chargedamount_9", -- The 75th percentile charged amount for a claim line with the given procedure.
"calculated_chargedamount_8", -- The 50th percentile charged amount for a claim line with the given procedure.
"calculated_allowedamount_3", -- The 50th percentile allowed amount for an entire claim containing the given procedure.
"calculated_chargedamount_7", -- The 25th percentile charged amount for a claim line with the given procedure.
"calculated_chargedamount_6", -- The standard deviation of the charged amount for a claim line with the given procedure.
"calculated_chargedamount_5", -- The average charged amount for a claim line with the given procedure.
"calculated_allowedamount_7", -- The 25th percentile allowed amount for a claim line with the given procedure.
"calculated_chargedamount_4", -- The 75th percentile charged amount for an entire claim containing the given procedure.
"calculated_chargedamount_3", -- The 50th percentile charged amount for an entire claim containing the given procedure.
"calculated_chargedamount_2", -- The 25th percentile charged amount for an entire claim containing the given procedure.
"procedure_count", -- Total count of claim lines with the given set of values.
"calculated_chargedamount_1", -- The standard deviation of the charged amount for an entire claim containing the given procedure.
"calculated_chargedamount", -- The average charged amount for an entire claim containing the given procedure.
"technical_component_flag", -- This element applies only to professional claim lines. With 0 meaning listed HCPCS procedure did not have a technical component modifier and 1 meaning listed HCPCS procedure did have a technical component modifier
"professional_component_flag", -- This element applies only to professional claim lines. With 0 meaning listed HCPCS procedure did not have a professional component modifier and 1 meaning listed HCPCS procedure did have a professional component modifier
"professional_pos_category", -- This element applies only to professional claims. The professional place of service (POS) following the Medicare differentiation between "facility" and "nonfacility" place of service codes as reported on the claim
"calculated_allowedamount_5", -- The average allowed amount for a claim line with the given procedure.
"calculated_allowedamount_9", -- The 75th percentile allowed amount for a claim line with the given procedure.
"calculated_allowedamount_1", -- The standard deviation of the allowed amount for an entire claim containing the given procedure.
"hcci_subdetailed_professional", -- This element applies only to professional claims. Classification of professional claim line based on methodology created by the Health Care Cost Institute (HCCI)
"hcci_detailed_outpatient", -- This element applies only to outpatient claims. Classification of outpatient claim line based on methodology created by the Health Care Cost Institute (HCCI)
"calculated_allowedamount_8", -- The 50th percentile allowed amount for a claim line with the given procedure.
"hcpcs_cpt_procedure_code_1", -- This element applies only to acute outpatient and professional claims. The description of the Healthcare Common Procedural Coding System (HCPCS) code as reported on the claim
"icd_10_pcs_procedure_code_1", -- This element applies only to acute inpatient claims. The description of the primary ICD-10 Procedure code as reported on the claim
"calculated_allowedamount", -- The average allowed amount for an entire claim containing the given procedure.
"calculated_allowedamount_6", -- The standard deviation of the allowed amount for a claim line with the given procedure.
"assistant_surgeon_flag_line", -- This element applies only to professional claim lines. With 0 meaning listed HCPCS procedure did not have a assistant surgeon modifier and 1 meaning listed HCPCS procedure did have a assistant surgeon modifier
"hcpcs_cpt_procedure_code", -- This element applies only to acute outpatient and professional claims. The Healthcare Common Procedural Coding System (HCPCS) code as reported on the claim
"outpatient_service_category", -- This element applies only to outpatient claims. Classification of outpatient claims based on methodology created by the Health Care Cost Institute (HCCI)
"calculated_allowedamount_2", -- The 25th percentile allowed amount for an entire claim containing the given procedure.
"year", -- Year of the statement through date as reported on the claim
"billing_provider_npi", -- The billing provider organization's National Provider Identifier (NPI) as reported on the claim
"provider_organization_name", -- Billing provider organization's legal business data as reported to National Plan and Provider Enumeration System (NPPES) as of April 11th 2022
"service_provider_taxonomy", -- Derived from the National Plan and Provider Enumeration System (NPPES) using the service provider NPI listed on the original claim. Taxonomy defintions are available on the National Uniform Claim Committee (NUCC) website.
"service_provider_taxonomy_1", -- Classification of the service provider's taxonomy code. Derived from the National Plan and Provider Enumeration System (NPPES) using the service provider NPI listed on the original claim.
"claim_category_header", -- Classification of the claim at a high level based on methodology created by the Health Care Cost Institute (HCCI)
"cms_drg", -- This element applies only to acute inpatient claims. The Centers for Medicare & Medicaid Services (CMS) Diagnosis Related Group (DRG) as reported on the claim
"cms_drg_description" -- This element applies only to acute inpatient claims. The description of the Centers for Medicare & Medicaid Services (CMS) Diagnosis Related Group (DRG) as reported on the claim
FROM
"opendata-utah-gov/common-medical-procedure-prices-in-utah-in-2021-hy48-n2gd:latest"."common_medical_procedure_prices_in_utah_in_2021"
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 opendata-utah-gov/common-medical-procedure-prices-in-utah-in-2021-hy48-n2gd
with SQL in under 60 seconds.
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, 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 (like this repository), where the author has pushed Splitgraph Images to the repository, you can "clone" and/or "checkout" the data using sgr clone
and sgr checkout
.
Cloning Data
Because opendata-utah-gov/common-medical-procedure-prices-in-utah-in-2021-hy48-n2gd:latest
is a Splitgraph Image, you can clone the data from Spltgraph Cloud to your local engine, where you can query it like any other Postgres database, using any of your existing tools.
First, install Splitgraph if you haven't already.
Clone the metadata with sgr clone
This will be quick, and does not download the actual data.
sgr clone opendata-utah-gov/common-medical-procedure-prices-in-utah-in-2021-hy48-n2gd
Checkout the data
Once you've cloned the data, you need to "checkout" the tag that you want. For example, to checkout the latest
tag:
sgr checkout opendata-utah-gov/common-medical-procedure-prices-in-utah-in-2021-hy48-n2gd:latest
This will download all the objects for the latest
tag of opendata-utah-gov/common-medical-procedure-prices-in-utah-in-2021-hy48-n2gd
and load them into the Splitgraph Engine. Depending on your connection speed and the size of the data, you will need to wait for the checkout to complete. Once it's complete, you will be able to query the data like you would any other Postgres database.
Alternatively, use "layered checkout" to avoid downloading all the data
The data in opendata-utah-gov/common-medical-procedure-prices-in-utah-in-2021-hy48-n2gd:latest
is 0 bytes. If this is too big to download all at once, or perhaps you only need to query a subset of it, you can use a layered checkout.:
sgr checkout --layered opendata-utah-gov/common-medical-procedure-prices-in-utah-in-2021-hy48-n2gd:latest
This will not download all the data, but it will create a schema comprised of foreign tables, that you can query as you would any other data. Splitgraph will lazily download the required objects as you query the data. In some cases, this might be faster or more efficient than a regular checkout.
Read the layered querying documentation to learn about when and why you might want to use layered queries.
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, opendata-utah-gov/common-medical-procedure-prices-in-utah-in-2021-hy48-n2gd
is just another Postgres schema.