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 advanced_messaging_concept_development_basic
table in this repository, by referencing it like:
"datahub-transportation-gov/advanced-messaging-concept-development-basic-eezi-v4pm:latest"."advanced_messaging_concept_development_basic"
or in a full query, like:
SELECT
":id", -- Socrata column ID
"location", -- Column to generate visualization
"longitude", -- The geographic longitude position as determined by the OBU GPS unit when the BSM was generated expressed as a GPS coordinate.
"latitude", -- The geographic latitude position as determined by the OBU GPS unit when the BSM was generated, expressed as a GPS coordinate.
"width", -- The width of the vehicle expressed in centimeters.
"mode_of_transmission", -- This field contains an indication of the mode of transmission used to transmit the message (DSRC or Cellular) from the OBU to the VCC Cloud server. If received via DSRC: 1 through 114 = The ID of the RSU used to forward the message to the server If received via cellular: 999999 = Cellular
"time_received", -- This field contains the time the BSM was received by the VCC Cloud server in milliseconds UTC time.
"obu_id", -- This field contains the ID of the OBU that generated and sent the message for the current communication sequence.
"location_zip",
"location_city",
"location_address",
"location_state",
":@computed_region_28hd_vqqn",
"time_sent", -- This field contains the time the message was sent from the OBU to the VCC Cloud server in milliseconds UTC time.
"length", -- The length of the vehicle expressed in centimeters.
"stability_control_status", -- The status of the vehicle’s stability control system. If the vehicle is equipped with an SCS, the element reports whether the system was in an Off or On state. 0 = Unavailable 1 = Off 2 = On
"abs_active", -- The status of the vehicle’s ABS, where the ABS was detected to be active. 0 = Unavailable 1 = Off 2 = On 3 = Engaged
"test_no", -- The AMCD test number the data was collected during.
"yaw_rate", -- A signed value representing degrees rotation per second of the vehicle around its vertical axis. Positive values indicate clockwise rotation of the vehicle around its vertical axis.
"steering_wheel_angle", -- The angle of the driver’s steering wheel, expressed in degrees of rotation from center where positive values represent rotation in the clockwise direction and negative values represent rotation in the counterclockwise direction.
"traction_control_state", -- The status of the vehicle’s traction system. If the vehicle is equipped with a TCS, the element reports whether the system was in an Off, On, or Engaged state. 0 = Unavailable 1 = Off 2 = On 3 = Engaged
"brake_applied_status", -- A bit field representing a binary indication of whether brakes are being applied at each wheel. A component of the brake system status data frame. 0000 = All off 0001 = Left front active 0010 = Left rear active 0100 = Right front active 1000 = Right rear active 1111 = Brake is active
"vertical_acceleration", -- The signed vertical acceleration of the vehicle along the vertical axis in meters per second squared where positive values indicate upward (opposite of gravity) acceleration.
"lateral_acceleration", -- The acceleration along the Y axis or perpendicular to the vehicle's general direction of travel in parallel with a left-to-right centerline. Expressed in meters per second squared where negative values indicate the vehicle is accelerating to left.
"longitudinal_acceleration", -- The acceleration along the X axis or the vehicle's direction of travel, which is generally in parallel with a front to rear centerline. Expressed in meters per second squared where negative values indicate deceleration, and possible braking action.
"transmission_state", -- The state of the vehicle transmission known to the OBU at the time the BSM was generated. 0 = Neutral 1 = Park 2 = Forward 3 = Reverse 4 = Reserved 5 = Reserved 6 = Reserved 7 = Unavailable
"heading", -- The heading of the vehicle expressed in degrees (0-360) where zero represents “North” and positive values express a heading values in a clockwise direction from “North.”
"speed", -- The vehicle speed in meters per second.
"elevation" -- The elevation of the vehicle in meters above mean sea level as determined by the OBU GPS when the BSM was generated.
FROM
"datahub-transportation-gov/advanced-messaging-concept-development-basic-eezi-v4pm:latest"."advanced_messaging_concept_development_basic"
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-transportation-gov/advanced-messaging-concept-development-basic-eezi-v4pm
with SQL in under 60 seconds.
This repository is an "external" repository. That means it's hosted elsewhere, in this case at datahub.transportation.gov. When you querydatahub-transportation-gov/advanced-messaging-concept-development-basic-eezi-v4pm: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
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 (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 clone
and sgr checkout
.
Mounting Data
This repository is an external repository. It's not hosted by Splitgraph. It is hosted by datahub.transportation.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-transportation-gov/advanced-messaging-concept-development-basic-eezi-v4pm" \
--handler-options '{
"domain": "datahub.transportation.gov",
"tables": {
"advanced_messaging_concept_development_basic": "eezi-v4pm"
}
}'
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-transportation-gov/advanced-messaging-concept-development-basic-eezi-v4pm
is just another Postgres schema.