oregon-gov/state-of-oregon-agency-data-inventory-yp9j-pm7w
Icon for Socrata external plugin

Query the Data Delivery Network

Query the DDN

The 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 state_of_oregon_agency_data_inventory table in this repository, by referencing it like:

"oregon-gov/state-of-oregon-agency-data-inventory-yp9j-pm7w:latest"."state_of_oregon_agency_data_inventory"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "data_value", -- What is your sense of the relative value in publishing this data?    [High] - existing and ongoing requests for this data; this data addresses pressing information needs or pain points (for either State govt or other entities); or we have heard compelling examples of how this data could be used;     [Medium] - This data may be useful for other state or govt agencies or for other constituents; we occasionally receive requests for this information; or we have heard some examples for how this data could be used;    [Low] - This data has unclear value for either the public or other state or govt entitles; we have never received requests for this data; or we have never heard a use case for this data;   [N\A or blank] - An N\A or blank are used if "Data is not Publishable."
    "geographic_granularity", -- What is the lowest level of geographic granularity in the data? For example, if the data is collected by address, it would be Street Address.
    "department_division", -- Name of the business unit of the agency who is responsible for managing this data.
    "agency_name", -- The name of the State agency who has inventoried the dataset and identified themselves as custodian of the dataset.
    "inventory_id", -- The unique ID for each inventoried dataset. This ID is used to track datasets through the publishing process. Once published, each inventoried dataset also contains a unique catalog ID (Dataset ID). Unique IDs are generated by the Chief Data Office as part of processing the inventories submitted by agencies. Unique IDs are a concatenation of the Agency acronym and a number.
    "data_classification", -- How would you classify this data? Level 1, "Published" - Information that is not protected from disclosure, that will not jeopardize the privacy or security of agency employees, clients or partners. Level 2, "Limited" - Information that may not be protected from disclosure, but may jeopardize the privacy or security of agency employees, clients, or partners if made readily available. Examples: risk assessments, internal audits. Level 3, "Restricted" - Information intended for limited business use that may be exempt from public disclosure due to risks posed to privacy and security associated with release of this information.  Examples: network diagrams, personally identifiable information, information exempted from public records disclosure. Level 4, "Critical" - Information that is considered highly sensitive and is intended for use by specified individuals only.  Disclosure or release of this information poses a series threat and could cause major damage or injury. Examples: Records of victims of domestic violence/stalking, IRS records/data
    "frequency_of_data_change", -- At what rate does the information in the dataset change? E.g., Hourly, Daily, Monthly, Annually
    "geographic_boundaries", -- If this data contains geographic information, what are the bounding boxes for this data?
    "data_readiness_for_publication", -- What is your sense of the readiness of this data to be made publicly available?   [High] - this data is of a high quality, requires little to no de-identification, intervention or transformation to make it suitable for external users;   [Medium] - This data may have a few quality issues, technological challenges/limitations, or other elements that would require work on behalf of the agency to clean, prepare, and ready it for publication;   [Low] - this data is of a low quality/usability, is technically challenging to access and export, or has other limitations that would require extensive work on behalf of the agency to clean, prepare, and ready it for publication;   [N\A or blank] - An N\A or blank is used if "Data is not Publishable."
    "type_of_existing_publication", -- If the answer to the previous question is yes, include a link to the publication or a description of the type of publication.
    "overall_priority", -- What is the overall priority for the agency in publishing this data?   [High] - This data is of high value/import to the agency and is an immediate priority for publication;   [Medium] - This data could be valuable if published, but is not an immediate priority;   [Low] - This data, due to either readiness or value considerations, is not a priority at this time;   [No priority or blank] - This data cannot be published; requires redaction; can be published "as-is" but priority decision is pending; or is already published as an open data set on data.oregon.gov, or another portal or website. 
    "data_is_is_not_publishable", -- Is this data publishable? Data can be published as is: the data can be published with no redactions or removal of fields. Data can be published with some redactions: the data may be published but would require redactions, de-identification, statistical noise, or aggregation to make it public. Data is not publishable: the data cannot be published in any format. (As-is, Redaction required, Not publishable)
    "brief_description_of_data", -- Brief description of the dataset. What is the purpose? What is it used for? Include key data fields if possible.
    "dataset_name", -- Brief descriptive name for the dataset.
    "dataset_id", -- The unique ID given to the dataset during publishing automatically by the open data platform. This is null or empty when the "Publishing Status" = Not Published.
    "data_restrictions_or", -- Are there other restrictions or regulations that would limit the release of this data or require redaction of some fields? E.g. FERPA, HIPAA, Public Records Exemptions, statutory or contractual limitations.
    "existing_publication", -- Is this data already made available for public consumption through an existing report, API endpoint, portal, etc.?
    "data_contains_pii_phi", -- Does this data contain either Personally Identifiable Information or Personal Health Information? (PII, PHI, PII/PHI, No)
    "open_data_publishing_status", -- The publishing status of this data as an open dataset.
    "dataset_link" -- The hyperklink given to the dataset during publishing. This is null or empty when the "Publishing Status" = Not Published
FROM
    "oregon-gov/state-of-oregon-agency-data-inventory-yp9j-pm7w:latest"."state_of_oregon_agency_data_inventory"
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 oregon-gov/state-of-oregon-agency-data-inventory-yp9j-pm7w with SQL in under 60 seconds.

This repository is an "external" repository. That means it's hosted elsewhere, in this case at data.oregon.gov. When you queryoregon-gov/state-of-oregon-agency-data-inventory-yp9j-pm7w: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

Install Splitgraph Locally
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; sgrcan 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 cloneand sgr checkout.

Mounting Data

This repository is an external repository. It's not hosted by Splitgraph. It is hosted by data.oregon.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 \
  "oregon-gov/state-of-oregon-agency-data-inventory-yp9j-pm7w" \
  --handler-options '{
    "domain": "data.oregon.gov",
    "tables": {
        "state_of_oregon_agency_data_inventory": "yp9j-pm7w"
    }
}'

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, oregon-gov/state-of-oregon-agency-data-inventory-yp9j-pm7w is just another Postgres schema.