cityofnewyork-us/dob-job-application-filings-ic3t-wcy2
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 dob_job_application_filings table in this repository, by referencing it like:

"cityofnewyork-us/dob-job-application-filings-ic3t-wcy2:latest"."dob_job_application_filings"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "adult_estab", -- Adult Estab
    "gis_bin", -- BIN
    "gis_nta_name", -- NTA Name
    "gis_longitude", -- Longitude
    "building_class", -- Building Class
    "special_action_date", -- Special Action Date
    "signoff_date", -- Sign-off Date
    "dobrundate", -- Date when query is run and pushed to Open Data. Could be used to differentiate report dates.
    "zip", -- Zip
    "city_", -- City 
    "owner_shouse_street_name", -- House Street Name of Property Owner
    "owner_s_business_name", -- Business Name of Property Owner
    "owner_type", -- Owner Type
    "proposed_occupancy", -- Proposed Occupancy
    "proposed_dwelling_units", -- Proposed Dwelling Units
    "street_frontage", -- Street Frontage
    "initial_cost", --  Estimated cost of job
    "fully_permitted", -- Date when job is fully permitted
    "applicant_s_first_name", -- First Name of Applicant
    "other_description", -- Other Description
    "bin__", -- Number assigned by City Planning to a specific building
    "job__", -- Number assigned by DOB to Job Filing
    "proposed_no_of_stories", -- Proposed No. of Stories
    "applicant_license__", -- Number assigned to the skilled trade person/contractor or licensed professional
    "fire_suppression", -- Fire Suppression  Work Type? (X=Yes, Blank=No)
    "job_status_descrp", -- Status code description
    "special_district_2", -- Special District 2
    "zoning_dist3", -- Zoning Distr 3
    "owner_s_house_number", -- House Number of Property Owner
    "existing_zoning_sqft", -- Existing Zoning Sqft
    "applicant_professional_title", -- Applicant's Professional Title
    "street_name", -- Street Name where Property is located
    "fully_paid", -- Date when job is paid and entered
    "applicant_s_last_name", -- Last Name of Applicant
    "little_e", -- Hazardous
    "gis_census_tract", -- Census Tract
    "approved", -- Date when job is approved
    "owner_s_first_name", -- First Name of property owner
    "job_description", -- Job Description
    "enlargement_sq_footage", -- Enlargement SQ Footage
    "city_owned", -- City Owned
    "boiler", -- Boiler  Work Type? (X=Yes, Blank=No)
    "proposed_height", -- Proposed Height
    "horizontal_enlrgmt", -- Horizontal Enlrgmt
    "zoning_dist1", -- Zoning Distr 1
    "existing_occupancy", -- Existing Occupancy
    "existingno_of_stories", -- ExistingNo. of Stories
    "gis_latitude", -- Latitude
    "job_no_good_count", -- Job No Good Count
    "total_construction_floor_area", -- Total  Construction Floor Area
    "owner_s_last_name", -- Last Name of property owner
    "site_fill", -- Site Fill
    "existing_dwelling_units", -- Existing Dwelling Units
    "total_est__fee", -- Estimated fee of job
    "paid", -- Date when job is paid
    "pre__filing_date", -- Date when job is prefiled
    "latest_action_date", -- Latest status date
    "gis_council_district", -- Council District
    "job_s1_no", -- JOB_S1_NO
    "withdrawal_flag", -- Withdrawal Indicator
    "state", -- State
    "special_district_1", -- Special Distr 1
    "proposed_zoning_sqft", -- Proposed Zoning Sqft
    "fee_status", -- Type of Fee
    "efiling_filed", -- Application Filed electronically, rather than manually
    "community___board", -- 3-digit identifier: Borough code = first position, last 2 = community board
    "job_status", -- DOB Status code of job (A-Pre Filed, I-Sign Off, P- Approved, R-Permit Entire) Complete List - http://www.nyc.gov/html/dob/downloads/pdf/bisjobstatus.pdf
    "lot", -- Tax lot assigned by Department of Finance
    "house__", -- House Number of Residence or Commercial Property
    "doc__", -- Document Number
    "zoning_dist2", -- Zoning Distr 2
    "block", -- Tax block assigned by Department of Finance
    "other", -- Other? (X=Yes, Blank=No)
    "sprinkler", -- Sprinkler  Work Type? (X=Yes, Blank=No)
    "assigned", -- Date when job is assigned to plan examiner
    "landmarked", -- L code indicates that the building has been assigned landmark status
    "job_type", -- Job Type, based on DOB Job Code (NB-New Building, A1, A2, A3- Alterations 1-3, SG-Sign, etc.)
    "professional_cert", -- Job is Professionally Certified by Licensed Professional instead of having it reviewed by Department of Building's Plan Examiners
    "mechanical", -- Mechanical  Work Type? (X=Yes, Blank=No)
    "owner_sphone__", -- Owner's  Phone #
    "existing_height", -- Existing Height
    "special_action_status", -- Special Action Status
    "non_profit", -- Non-Profit
    "fuel_storage", -- Fuel Storage  Work Type? (X=Yes, Blank=No)
    "fuel_burning", -- Fuel Burning  Work Type? (X=Yes, Blank=No)
    "cluster", -- Cluster
    "borough", -- 1= Manhattan, 2= Bronx, 3 = Brooklyn, 4 = Queens, 5 = Staten Island
    "loft_board", -- Loft Board
    "standpipe", -- Standpipe Work Type? (X=Yes, Blank=No)
    "pc_filed", -- Application Filed electronically, rather than manually
    "building_type", -- 1-2-3 Family  or Other
    "vertical_enlrgmt", -- Vertical Enlrgmt
    "curb_cut", -- Curb Cut  Work Type? (X=Yes, Blank=No)
    "fire_alarm", -- Fire Alarm  Work Type? (X=Yes, Blank=No)
    "plumbing", -- Plumbing Work Type? (X=Yes, Blank=No)
    "equipment" -- Equipment  Work Type? (X=Yes, Blank=No)
FROM
    "cityofnewyork-us/dob-job-application-filings-ic3t-wcy2:latest"."dob_job_application_filings"
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 cityofnewyork-us/dob-job-application-filings-ic3t-wcy2 with SQL in under 60 seconds.

This repository is an "external" repository. That means it's hosted elsewhere, in this case at data.cityofnewyork.us. When you querycityofnewyork-us/dob-job-application-filings-ic3t-wcy2: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.cityofnewyork.us, 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 \
  "cityofnewyork-us/dob-job-application-filings-ic3t-wcy2" \
  --handler-options '{
    "domain": "data.cityofnewyork.us",
    "tables": {
        "dob_job_application_filings": "ic3t-wcy2"
    }
}'

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, cityofnewyork-us/dob-job-application-filings-ic3t-wcy2 is just another Postgres schema.