ny-gov/residential-existing-homes-one-to-four-units-assk-vu73
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 residential_existing_homes_one_to_four_units table in this repository, by referencing it like:

"ny-gov/residential-existing-homes-one-to-four-units-assk-vu73:latest"."residential_existing_homes_one_to_four_units"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    ":@computed_region_yamh_8v7k", -- This column was automatically created in order to record in what polygon from the dataset 'NYS Municipal Boundaries' (yamh-8v7k) the point in column 'geocoded_column' is located.  This enables the creation of region maps (choropleths) in the visualization canvas and data lens.
    ":@computed_region_kjdx_g34t", -- This column was automatically created in order to record in what polygon from the dataset 'Counties' (kjdx-g34t) the point in column 'geocoded_column' is located.  This enables the creation of region maps (choropleths) in the visualization canvas and data lens.
    "home_performance_site_id", -- Unique site identifier for location of the project
    "project_county", -- Name of county for project location
    "reporting_period", -- The time period covered by the data set
    "home_performance_project_id", -- Unique identifier for project
    "number_of_units", -- Number of units served by the Program Available only for projects completed after January 1, 2018 
    "estimated_annual_kwh_savings", -- Annual post-retrofit modeled electric savings estimate in kWh. Negative numbers represent projects with post-retrofit increase in electric consumption, typically from fuel conversions or ancillary savings
    "estimated_annual_mmbtu_savings", -- Annual post-retrofit modeled MMBtu savings based on primary fuel type. Negative numbers represent projects with post-retrofit increase in MMBtu consumption, typically from fuel conversions or ancillary savings
    "first_year_energy_savings_estimate", -- Estimated modeled post-retrofit first year dollar savings (USD). Negative numbers represent projects with estimated post-retrofit first year dollar expenses, typically occurring when non-energy work was completed such as health and safety improvements, or when work was done in conjunction with another, net positive energy savings project
    "geocoded_column",
    "homeowner_received_green_jobs_green_ny_free_reduced_cost_audit_", -- Indicator if the homeowner received a Free/Reduced Cost Green Jobs Green-NY audit prior to retrofit work
    "total_incentives", -- Total Incentives	Numeric	Amount of homeowner incentive (USD). Zero dollars represent either projects receiving only financing, or Market Rate projects that did not receive an incentive, but still participated in the program to take advantage of working with participating contractors and Quality Assurance benefits
    "total_project_cost", -- Cost of project in US dollars (USD)
    "low_rise_or_home_performance_indicator", -- Indicates whether project was part of a low-rise community initiative or a single-family home performance project. Low-rise projects are not eligible for residential loan products, or free or reduced cost audits. Each unit served on a low-rise project is treated as an individual project
    "project_completion_date", -- Date final project completion paperwork was reviewed and approved by Program.
    "electric_utility", -- Name of electric utility for project location
    "gas_utility", -- Name of gas utility for project location. If blank, then utility was not reported, or project location is not served by a gas utility
    "project_zip", -- Name of zip code for project location
    "project_city", -- Name of city for project location
    ":@computed_region_wbg7_3whc", -- This column was automatically created in order to record in what polygon from the dataset 'New York Zip Codes' (wbg7-3whc) the point in column 'geocoded_column' is located.  This enables the creation of region maps (choropleths) in the visualization canvas and data lens.
    "customer_type", -- Indicates if the homeowner received market rate incentives or the assisted subsidy for households with income up to 80% of the State or median county income, whichever is higher
    "type_of_program_financing", -- Indicates type of Program financing a project received, including current financing options of GJGNY On-Bill Recovery Loan, GJGNY Smart Energy Loan, and legacy financing options (Energy Smart Loan Fund (ESMART) and Home Performance with ENERGY STAR Financing (ESTAR)). If blank, then project was not financed through the GJGNY Smart Energy Loan Program, GJGNY On-Bill Recovery Loan or other legacy Program financing option.
    "amount_financed_through_program", -- Project loan amount (USD). If blank, then project was not financed through the GJGNY Smart Energy Loan Program, GJGNY On-Bill Recovery Loan or other legacy Program financing option.
    "pre_retrofit_home_heating_fuel_type", -- Indicates the pre-retrofit primary heating fuel type 
    "year_home_built", -- Home construction date.  Available only for projects completed after January 1, 2018
    "size_of_home", -- Square footage of home.  Available only for projects completed after January 1, 2018
    "volume_of_home", -- Approximate volume of conditioned space of the home.  Available only for projects completed after January 1, 2018
    "measure_type" -- Measure classification describing primary project improvement.  Available only for projects completed after January 1, 2018
FROM
    "ny-gov/residential-existing-homes-one-to-four-units-assk-vu73:latest"."residential_existing_homes_one_to_four_units"
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/residential-existing-homes-one-to-four-units-assk-vu73 with SQL in under 60 seconds.

This repository is an "external" repository. That means it's hosted elsewhere, in this case at data.ny.gov. When you queryny-gov/residential-existing-homes-one-to-four-units-assk-vu73: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.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 \
  "ny-gov/residential-existing-homes-one-to-four-units-assk-vu73" \
  --handler-options '{
    "domain": "data.ny.gov",
    "tables": {
        "residential_existing_homes_one_to_four_units": "assk-vu73"
    }
}'

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, ny-gov/residential-existing-homes-one-to-four-units-assk-vu73 is just another Postgres schema.