Query the Data Delivery Network
Query the DDNThe 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 federal_projects
table in this repository, by referencing it like:
"highways-hidot-hawaii-gov/federal-projects-quc5-s8s8:latest"."federal_projects"
or in a full query, like:
SELECT
":id", -- Socrata column ID
"inactivedays", -- Days of inactivity. The calculation is: Today's Date - Latest Payment Date
"projectstatus", -- Project Status. For Construction: 1 is active, 2 is closeout, 3 is archived. For Design, Planning, and ROW, 1 is programmed, 2 is active, 3 is archived, and 4 is cancelled. For County projects, 1 is programmed, 2 is design, 3 is active construction, 4 is construction closeout, 5 is archived, and 6 is cancelled
"iscountyproject", -- Is the project a county project? True or False
"fv_request", -- The state has requested that the Federal division office grant final voucher
"pe10reqmet", -- The date the PE10 requirement set by FHWA division office was met. The date the project was removed from the PE10 list.
"popcurrentdatevariance", -- Period of performance current variance date
"pe10repayby", -- Deadline to repay funds
"pe1_enddate", -- Preliminary Engineering 1 (Planning) period of performance end date. Date by which the planning phase must be done to continue to receive Federal participation.
"pe2_enddate", -- Preliminary Engineering 2 (Design) period of performance end date. Date by which the design phase must be done (ROW or construction has been obligated) to continue to receive Federal participation.
"row_enddate", -- Right of Way period of performance end date. Date by which the ROW phase must be done to continue to receive Federal participation.
"con_enddate", -- Construction period of performance end date. Date by which the project must be closed to continue to receive Federal participation.
"fin_no", -- Financial Ineligibility Number. These are numbers assigned to projects that are non-participating due to Period of Peformance end dates expiring
"sm_status", -- A field created to sort projects for particular reports (inactive, closeout, billing, etc). Currently not being utilized.
"start_ineligible", -- The date when the ineligible period (federal non-participating period) starts for the project
"pe10repaydate", -- Date that funds were repaid
"fv_request_date", -- The date the state requested that the Federal division office grant final voucher
"contactperson", -- Name of contact person. This field is only filled in if there is not a corresponding record in PSS
"contactoffice", -- Name of contact office. This field is only filled in if there is not a corresponding record in PSS
"pe2_enddate_orig", -- Original period of performance end date for PE2. If a renewal to the PE2 end date is made, this field is filled in with the date that was originally granted for PE2.
"row_enddate_orig", -- Original period of performance end date for ROW. If a renewal to the ROW end date is made, this field is filled in with the date that was originally granted for ROW.
"con_enddate_orig", -- Original period of performance end date for Construction. If a renewal to the Construction end date is made, this field is filled in with the date that was originally granted for Construction.
"project_title", -- Federal project title. This is the project Title as recorded in FMIS
"demoid", -- The Federal Demonstration project ID.
"notpursuepopext", -- True or False field for whether we are pursuing a period of performance extension for a project
"est_con_date", -- A date filled in by FHWA
"pe_date", -- The date Preliminary Engineering funds were first obligated. This could refer to Planning, Design, or both.
"popstatus", -- Period of performance status: Needs attention, Critical, Good
"right_of_way_date", -- The date ROW funds were initially obligated, and could be ROW or pre-ROW funds.
"construction_date", -- The date construction funds were first obligated.
"spr_date", -- The date SPR funds were first obligated.
"earliest_auth_date", -- The first date any funds were obligated for this Federal ID
"final_voucher_paid_date", -- Date final voucher was granted for the project by FHWA
"expenditure_amount", -- The total amount of money expended for this Federal ID
"remarksstate", -- State remarks in FMIS
"project_end_date", -- Period of performance end date as recorded in FMIS. Should match 1240. Only recorded for projects which were given an end date as of 2017 or later.
"sumoffedmoneyremaining", -- Sum of federal money remaining
"materialcertstatus", -- Material certification status. Words describing where the letter of material certs is in the closeout status. Based on information entered in the lab module of the database
"uastatus", -- Utility agreement status. Words describing where the utility agreement is in the closeout process. Based on dates entered in the disposition log by construction
"rowinfo", -- Right of Way info
"final_con_acceptance_date", -- Date final construction acceptance was issued for state and county projects
"as_built_date_filled_district", -- As built date filed to distrit
"percentcomplete", -- Percentage of work complete
"project_status_description", -- Federal project status description. Active, Closed, or Withdrawn'
"projectnumber", -- Calculated project number
"projectid", -- Unique ID assigned to each project. Assigned by HWY-SM based on JAs processed by HWY-SM. All projects beginning with charge codes 1, 2 or 6 are included. Others are included by request.
"branch", -- Branch that completed work
"substantialcomplete", -- Calculated Substantial completion date. If Substantial Completion date is entered in PSS, it uses that one. Otherwise, it checks other fields to predict whether a project is complete even if a substantial completion date is not entered.
"popdate", -- Period of performance date (latest of all the period of performance dates set)
"podi", -- Project has been chosen by FHWA Division office as a PODI (project of division initerest) project
"pe10", -- Is this a PE10 project? True or False
"currentphase", -- Current Phase of Project (Planning, Design, Construction, ROW or County)
"county", -- County project? True or False. This field is only filled in if there is not a corresponding project in PSS
"currentstatus", -- Current project status
"matchfed", -- This field is used for determining which PSS project is used for Federal listings if there is more than 1 PSS project with the same Federal ID. If it is true, this PSS project will be used for the Federal Listing. If it is false, it will not.
"popestimatedcompletiondate", -- Period of performance estimated completion date
"popvariance", -- Period of performance variance. The difference (in days) between the POPEstimatedCompletionDate and the POPDate.
"popvariancerank", -- Period of performance variance rank
"email", -- Email for users within Highways
"uuid",
"design_project_status", -- 1 = Programmed, 2 = Active, 3 = Archived (went to construction) , 4 = Cancelled or indefinately deferred
"latest_payment_date", -- Date the project was most recently reimbursed for
"extendedphase", -- Extended Phase
"sm_rep", -- Person in HWY-SM responsible for project (obligations, final closeout, etc)
"row_project_status", -- Project status for Right of Way project. 1 is programmed, 2 is active, 3 is archived (ROW complete), and 4 is cancelled or indefinitely deferred
"adv_con", -- Amount of money set aside for advance construction
"finaldispositionlogdate", -- The date the final disposition log was completed
"projecttitle", -- Calculated title of project
"construction_project_status", -- Construction project status: 1: Active, 2: Closeout, 3: Archived (Done at district, fiscal closeout may still be pending)
"responsibleperson", -- Responsible person associated with project
"originalpopthisphase", -- Original POP date for project in current phase
"stip_ref", -- Filled in by FHWA. I supposed to reference STIP number, but not always clear which STIP the reference is to
"fyexpenditure_amount", -- The amount of money expended for this Federal ID this fiscal year
"project_status", -- A number corresponding to the status of the project: 10=active, 11=closed, 13=withdrawn
"fedid", -- Federal ID assigned to each project
"obligations_amount", -- The amount of money obligated for this Federal ID
"remarksfhwa", -- FHWA remarks in FMIS
"ntpdate", -- Notice to proceed date for both State and County Projects. For contracts bid on prior to October 1, 2018 the NTP date and Start Date were synonomous and indicate the start of the contract time. After October 1, 2018 the NTP date does not indicate
"recipient_project_number", -- Recipient project number. This is the "Project Number" as recorded in FMIS.
"pe1_enddate_orig", -- Original period of performance end date for PE1. If a renewal to the PE1 end date is made, this field is filled in with the date that was originally granted for PE1.
"prioritydate", -- Priority date for SHPD list. This date order is used for ordering shpd projects and is based on they type of projects and dates entered into the anticipated NEPA and the anticipated RTA in PSS.
"fiscalcloseoutpending", -- If this is true, the project is still in fiscal closeout. If this is false and the project is archived, this project is completely closed out.
"office", -- Office associated with project
"other_date", -- The date of obligation for any fund types not already accounted for under PE, ROW, Construction, or SPR.
"end_ineligible", -- The date when the ineligible period (federal non-participating period) starts for the project
"islandfed", -- The Island the project is on. This field is ONLY filled in if there is not a corresponding project in PSS
"popphase" -- Period of performance phase.
FROM
"highways-hidot-hawaii-gov/federal-projects-quc5-s8s8:latest"."federal_projects"
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 highways-hidot-hawaii-gov/federal-projects-quc5-s8s8
with SQL in under 60 seconds.
Query Your Local Engine
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; sgr
can 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 clone
and sgr checkout
.
Cloning Data
Because highways-hidot-hawaii-gov/federal-projects-quc5-s8s8: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 highways-hidot-hawaii-gov/federal-projects-quc5-s8s8
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 highways-hidot-hawaii-gov/federal-projects-quc5-s8s8:latest
This will download all the objects for the latest
tag of highways-hidot-hawaii-gov/federal-projects-quc5-s8s8
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 highways-hidot-hawaii-gov/federal-projects-quc5-s8s8: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 highways-hidot-hawaii-gov/federal-projects-quc5-s8s8: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, highways-hidot-hawaii-gov/federal-projects-quc5-s8s8
is just another Postgres schema.