ny-gov/utility-company-customer-service-response-index-w3b5-8aqf
Loading...

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

"ny-gov/utility-company-customer-service-response-index-w3b5-8aqf:latest"."utility_company_customer_service_response_index"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "service_provider", -- Name of Company Complaints are Entered Against
    "csri", -- The Customer Service Response Index (CSRI) is the overall score received by the service provider. It is the sum of the four indices; CSM, CRM, ERM and PCM. 
    "crm_index", -- The Complaint Response Time (CRM) Index scores the service providers responsiveness to initial complaints closed in the reporting month. A score of 2 points is awarded when a provider's average response time for initial complaints is 14 days or less. No points are earned if the average response time for initial complaints is more than 28 days (twice the acceptable reply standard).
    "avg_age_of_cases_pending", -- This is the average age, in days, of all the cases awaiting a response from the service provider. 
    "complaint_response_time", -- This is the average number of days it took for a utility to respond to initial complaints in the reporting month.
    "year", -- Year Initial Complaint Was Filed
    "e_complaint_response_time", -- This is the average number of days it took for a utility to respond to escalated complaints in the reporting month. 
    "pcm_index", -- The Pending Case (PCM) Index scores the average age of all cases awaiting response by the service provider. A score of 1 point is awarded when a service providers' average age of all cases is 14 days or less. No points are earned if the average age of all cases exceeds 70 days (two months delinquent). A negative score is applied if the average age of all cases is over 70 days.
    "initial_complaints", -- The number of initial complaints DPS receives and forwards to the utility company for resolution directly with the customer. 
    "csm_index", -- The Consumer Satisfaction (CSM) Index scores the ratio of the number of initial complaints to the number of escalated complaints in the reporting month. A score of 5 points are awarded when a service provider receives no escalated complaints during the reporting month. There is no score awarded if a service provider satisfies less than 50% of the customers that the PSC refers to them.
    "erm_index", -- The Escalated Complaint Response Time (ERM) Index scores the service providers responsiveness to escalated complaints closed in the reporting month. A score of 2 points is awarded when a provider's average response time for escalated complaints is 10 days or less. No points are earned if the average response time for escalated complaints is more than 25 days (two weeks past due).
    "escalated_complaints", -- The number of complaints that DPS escalated for further handling and investigation because the customer informed DPS that the utility failed to satisfy their initial complaint. 
    "month" -- Month Initial Complaint Was Filed
FROM
    "ny-gov/utility-company-customer-service-response-index-w3b5-8aqf:latest"."utility_company_customer_service_response_index"
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 ny-gov/utility-company-customer-service-response-index-w3b5-8aqf with SQL in under 60 seconds.

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, 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 cloneand sgr checkout.

Cloning Data

Because ny-gov/utility-company-customer-service-response-index-w3b5-8aqf: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 ny-gov/utility-company-customer-service-response-index-w3b5-8aqf

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 ny-gov/utility-company-customer-service-response-index-w3b5-8aqf:latest

This will download all the objects for the latest tag of ny-gov/utility-company-customer-service-response-index-w3b5-8aqf 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 ny-gov/utility-company-customer-service-response-index-w3b5-8aqf: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 ny-gov/utility-company-customer-service-response-index-w3b5-8aqf: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, ny-gov/utility-company-customer-service-response-index-w3b5-8aqf is just another Postgres schema.

Related Documentation:

Loading...