datahub-austintexas-gov/plan-review-cases-n8ck-xkda
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 plan_review_cases table in this repository, by referencing it like:

"datahub-austintexas-gov/plan-review-cases-n8ck-xkda:latest"."plan_review_cases"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "number_of_units", -- Number of residential units in the structure to be built. 
    "electrical_valuation", -- Estimated expenditure on electrical costs
    "applied_date", -- the date the case was applied for
    "other_organization_name", -- name of other entitiy's organization associated with the case
    "owner_phone", -- the owner's phone 
    "project_name", -- the folder name
    "sub_type", -- the sub type of case
    "propertyrsn", -- the property record number of the AMANDA system
    "legal_description", -- Legal Description of the property associated with the permit.
    "total_job_valuation", -- Estimated expenditure on construction (will include plumbing, mechanical, electrical costs etc)
    "number_of_floors", -- Number of floors of the structure to be built. 
    "medgas_valuation_remodel", -- Estimated expenditure on patient medical gas or medical support gas components in remodelling structures. 
    "electrical_valuation_remodel", -- Estimated expenditure  on remodelling - electrical costs 
    "building_valuation_remodel", -- Estimated expenditure  on remodelling (building portion only)
    "expires_date", -- the date the case would expire
    "issued_date", -- the issued date of the case
    "other_full_name", -- name of other entitiy associated with the case
    "owner_address", -- the owner's address
    "status_date", -- the date for the current status
    "folder_section", -- the folder section
    "referencefile", -- the case number
    "update_date", -- the date the data was created
    "propx", -- State Plane X Coordinate of the case
    "total_valuation_remodel", -- Estimated expenditure on remodelling (will include plumbing, mechanical, electrical costs etc)
    "total_new_add_footage", -- total new or additional square footage 
    "remodel_repair_footage", -- square footage that will be remodelled or repaired. 
    "building_valuation", -- Estimated expenditure  on new construction (building portion only)
    "final_date", -- the date the case was finaled
    "issued_in_last_30_days", -- whether the issued date of the case was in the last 30 days
    "appraisal_id", -- the id of the appraisal record
    "owner_organization_name", -- the owner's organization name
    "owner_full_name", -- the owner's full name
    "applicant_address", -- the applicant's address
    "applicant_organization_name", -- the applicant's organization name
    "applicant_full_name", -- the applicant's full name
    "status_current", -- the current status of the record
    "plumbing_valuation", -- Estimated expenditure  on plumbing costs 
    "mechanical_valuation", -- Estimated expenditure on mechanical costs
    "calendar_year_issued", -- Calendar year of the issued date of the case was in the last 30 days
    "other_phone", -- the other's phone 
    "applicant_phone", -- the applicant's phone number
    "permit_number", -- the permit number
    "total_existing_bldg_footage", -- Total existing building square footage
    "propy", -- State Plane Y Coordinate of the case
    "folder_description", -- the folder description of the case
    "location", -- the latitude and longitude value needed to map in the Socrata data.austintexas.gov site
    "medgas_valuation", -- Estimated expenditure on patient medical gas or medical support gas components in structures. 
    "folderrsn", -- the AMANDA folderrsn tracking number
    "fiscal_year_issued", -- Fiscal year of the issued date of the case was in the last 30 days
    "other_address", -- the other's address
    "plumbing_valuation_remodel", -- Estimated expenditure  on remodelling (plumbing costs)
    "mechanical_valuation_remodel", -- Estimated expenditure  on remodelling ( mechanical costs )
    "council_district", -- Council District in which case is located
    "day_issued", -- the issued day of the case
    "condominium", -- whether the project is a condominium 
    "express_permit", -- whether permit is express or not
    "work_class", -- whether it is residential or commercial
    "folder_type", -- the type of AMANDA folder
    "permit_type", -- the type of case
    "fiscal_year_indate", -- the fiscal year case was applied for
    "web_link", -- the link to the Austin Build and Connect web site for the case
    ":@computed_region_xzeg_zdjk",
    ":@computed_region_rxpj_nzrk",
    ":@computed_region_m2th_e4b7",
    ":@computed_region_e9j2_6w3z",
    ":@computed_region_q9nd_rr82",
    ":@computed_region_jcrc_4uuy",
    ":@computed_region_8spj_utxs"
FROM
    "datahub-austintexas-gov/plan-review-cases-n8ck-xkda:latest"."plan_review_cases"
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 datahub-austintexas-gov/plan-review-cases-n8ck-xkda with SQL in under 60 seconds.

This repository is an "external" repository. That means it's hosted elsewhere, in this case at datahub.austintexas.gov. When you querydatahub-austintexas-gov/plan-review-cases-n8ck-xkda: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 datahub.austintexas.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 \
  "datahub-austintexas-gov/plan-review-cases-n8ck-xkda" \
  --handler-options '{
    "domain": "datahub.austintexas.gov",
    "tables": {
        "plan_review_cases": "n8ck-xkda"
    }
}'

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, datahub-austintexas-gov/plan-review-cases-n8ck-xkda is just another Postgres schema.