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-wxyj-6dfq:latest"."advanced_messaging_concept_development_basic"
or in a full query, like:
SELECT
":id", -- Socrata column ID
"ambient_air_temperature", -- The temperature of the air outside the vehicle as measured by vehicle sensors and expressed as degrees Celsius.
"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.
"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.
"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.”
"elevation", -- The elevation of the vehicle in meters above mean sea level as determined by the OBU GPS when the BMM was generated.
"longitude", -- The geographic longitude position as determined by the OBU GPS unit when the BMM was generated expressed as a GPS coordinate.
"latitude", -- The geographic latitude position as determined by the OBU GPS unit when the BMM was generated, expressed as a GPS coordinate.
"width", -- The width of the vehicle expressed in centimeters.
"time_received", -- The time at which the BMM was received by the VCC Cloud server in milliseconds UTC time.
"time_sent", -- The time at which the message was sent from the OBU to the VCC Cloud server in milliseconds UTC time.
"obu_id", -- The ID of the OBU that generated and sent the message for the current communication sequence.
"message_id", -- A message ID value generated by the OBU that increases sequentially with each new BMM message created, starting with 1.
"brake_applied_status", -- A bit field representing a binary indication of whether brakes were 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 active
"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
"precipitation_sensor", -- The status of the vehicle’s on board sensors that detect the presence of precipitation expressed as: 0 = None 1 = Light Mist 2 = Heavy Mist 3 = Light Rain 4 = Rain 5 = Moderate Rain 6 = Heavy Rain 7 = Heavy Downpour
"wiper_status", -- The status of the vehicle’s front windshield wipers expressed as: 0 = Unavailable 1 = Off 2 = Intermittent 3 = Low 4 = High 126 = Washer In-Use 128 = Auto Present
"tire_air_pressure", -- The status of the vehicle’s combined tire pressure status. A measure of the relative tire pressure observed. Encoded as per the value set used in SAE J1939 0 = No data 1 = Over Pressure 2 = No Warning Pressure 3 = Under Pressure 4 = Extreme Under Pressure 5 = Undefined 6 = Error Indicator 7 = Unavailable
"container_message_id", -- BMMs are sent from the OBU packed into a container message that can contain up to four separate data snapshots. This is the ID of the container message that contained the BMM as it was transmitted to the server.
"length", -- The length of the vehicle expressed in centimeters.
"transmission_state", -- The state of the vehicle transmission known to the OBU at the time the BMM was generated. 0 = Neutral 1 = Park 2 = Forward 3 = Reverse 4 = Reserved 5 = Reserved 6 = Reserved 7 = Unavailable
"speed", -- The vehicle speed in meters per second.
"abs_active", -- The status of the vehicle’s ABS system where the system was detected to be active. 0 = Unavailable 1 = Off 2 = On 3 = Engaged
"stability_control_status", -- The status of the vehicle’s SCS. 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
"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.
"ambient_air_pressure", -- The pressure of the air outside the vehicle as measured by vehicle sensors and expressed as hPa.
"test_no", -- The AMCD field test number the data was collected from.
"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.
"light_status", -- The status of the vehicle’s external lighting system expressed as a bit field where: Bit0 = Off Bit1 = Headlight Low Beam Bit2 = Headlight High Beam Bit3 = Left Turn Bit4 = Right Turn Bit5 = Hazard Bit6 = Automatic Control Bit7 = Daytime Running
"mode_of_transmission", -- An indication of which mode of transmission was 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
"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.
FROM
"datahub-transportation-gov/advanced-messaging-concept-development-basic-wxyj-6dfq: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-wxyj-6dfq
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 datahub-transportation-gov/advanced-messaging-concept-development-basic-wxyj-6dfq: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 datahub-transportation-gov/advanced-messaging-concept-development-basic-wxyj-6dfq
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 datahub-transportation-gov/advanced-messaging-concept-development-basic-wxyj-6dfq:latest
This will download all the objects for the latest
tag of datahub-transportation-gov/advanced-messaging-concept-development-basic-wxyj-6dfq
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 datahub-transportation-gov/advanced-messaging-concept-development-basic-wxyj-6dfq: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 datahub-transportation-gov/advanced-messaging-concept-development-basic-wxyj-6dfq: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, datahub-transportation-gov/advanced-messaging-concept-development-basic-wxyj-6dfq
is just another Postgres schema.