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 wyoming_cv_pilot_traveler_information_message
table in this repository, by referencing it like:
"datahub-transportation-gov/wyoming-cv-pilot-traveler-information-message-6nxx-nmxk:latest"."wyoming_cv_pilot_traveler_information_message"
or in a full query, like:
SELECT
":id", -- Socrata column ID
"travelerdataframe_content_genericsign_sequence", -- payload/data/MessageFrame/value/TravelerInformation/dataFrames/TravelerDataFrame/content/genericSign/SEQUENCE
"travelerdataframe_startyear", -- payload/data/MessageFrame/value/TravelerInformation/dataFrames/TravelerDataFrame/startYear
"travelerdataframe_starttime", -- payload/data/MessageFrame/value/TravelerInformation/dataFrames/TravelerDataFrame/startTime
"travelerdataframe_1", -- payload/data/MessageFrame/value/TravelerInformation/dataFrames/TravelerDataFrame/sspLocationRights
"travelerdataframe_name", -- payload/data/MessageFrame/value/TravelerInformation/dataFrames/TravelerDataFrame/regions/GeographicalPath/name
"travelerdataframe_msgid_lat", -- payload/data/MessageFrame/value/TravelerInformation/dataFrames/TravelerDataFrame/msgId/position/lat
"travelerdataframe_lanewidth", -- payload/data/MessageFrame/value/TravelerInformation/dataFrames/TravelerDataFrame/regions/GeographicalPath/laneWidth
"travelerdataframe_id", -- payload/data/MessageFrame/value/TravelerInformation/dataFrames/TravelerDataFrame/regions/GeographicalPath/id
"travelerdataframe_direction", -- payload/data/MessageFrame/value/TravelerInformation/dataFrames/TravelerDataFrame/regions/GeographicalPath/direction
"travelerdataframe_desc_nodes", -- payload/data/MessageFrame/value/TravelerInformation/dataFrames/TravelerDataFrame/regions/GeographicalPath/description/path/offset/xy/nodes/NodeXY
"travelerdataframe_content", -- payload/data/MessageFrame/value/TravelerInformation/dataFrames/TravelerDataFrame/content/advisory/SEQUENCE
"metadata_request_snmp_1", -- ISO string for message delivery stop time. Provided by the requester and used by the ODE to access the RSUs via the SNMP interface.
"metadata_rmd_heading", -- Heading of vehicle when receiving the message
"metadata_rmd_elevation", -- Elevation of vehicle when receiving the message
"metadata_receivedat", -- Time ODE received the data in UTC format
"metadata_serialid_serialnumber", -- Combined identifier within open stream
"metadata_payloadtype", -- ODE specific Java class identifying the type of payload included with the message
"messageid", -- payload/data/MessageFrame/messageId
"metadata_recordgeneratedby", -- Source of the record, whether [OBU, RSU, TMC].
"metadata_serialid_recordid", -- Record identier within the bundle
"metadata_serialid_streamid", -- Stream that process the original log file
"travelerdataframe_3", -- payload/data/MessageFrame/value/TravelerInformation/dataFrames/TravelerDataFrame/sspMsgRights2
"travelerdataframe_content_exitservice_sequence", -- payload/data/MessageFrame/value/TravelerInformation/dataFrames/TravelerDataFrame/content/exitService/SEQUENCE
"travelerdataframe_msgid", -- payload/data/MessageFrame/value/TravelerInformation/dataFrames/TravelerDataFrame/msgId/position/elevation
"metadata_request_snmp_enable", -- Enable RSU: 1 = true, 0 = false. Provided by the requester and used by the ODE to access the RSUs via the SNMP interface.
"metadata_request_snmp_interval", -- Interval. Provided by the requester and used by the ODE to access the RSUs via the SNMP interface.
"metadata_request_snmp_rsuid", -- OID of the RSU. Provided by the requester and used by the ODE to access the RSUs via the SNMP interface.
"travelerinformation_msgcnt", -- payload/data/MessageFrame/value/TravelerInformation/msgCnt
"metadata_request_snmp_msgid", -- Message ID. Provided by the requester and used by the ODE to access the RSUs via the SNMP interface.
"travelerdataframe_content_workzone_sequence", -- payload/data/MessageFrame/value/TravelerInformation/dataFrames/TravelerDataFrame/content/workZone/SEQUENCE
"travelerdataframe_msgid_2", -- payload/data/MessageFrame/value/TravelerInformation/dataFrames/TravelerDataFrame/msgId/roadSignID/viewAngle
"travelerdataframe_frametype", -- payload/data/MessageFrame/value/TravelerInformation/dataFrames/TravelerDataFrame/frameType
"metadata_request_rsus", -- Parameters provided by the requester and used by the ODE to send messages the Roadside Units.
"travelerdataframe_durationtime", -- payload/data/MessageFrame/value/TravelerInformation/dataFrames/TravelerDataFrame/durationTime
"travelerdataframe_priority", -- payload/data/MessageFrame/value/TravelerInformation/dataFrames/TravelerDataFrame/priority
"datatype", -- The data type.
"travelerdataframe_ssptimrights", -- payload/data/MessageFrame/value/TravelerInformation/dataFrames/TravelerDataFrame/sspTimRights
"metadata_request_snmp_status", -- RSU Status. Provided by the requester and used by the ODE to access the RSUs via the SNMP interface.
"metadata_logfilename", -- Name of the original file that deposited the message into the ODE
"metadata_recordtype", -- Type of message
"metadata_rmd_longitude", -- Longitude of vehicle when receiving the message
"travelerdataframe_content_itis", -- payload/data/MessageFrame/value/TravelerInformation/dataFrames/TravelerDataFrame/content/itis
"metadata_rmd_latitude", -- Latitude of vehicle when receiving the message
"travelerdataframe_closedpath", -- payload/data/MessageFrame/value/TravelerInformation/dataFrames/regions/GeographicalPath/closedPath
"travelerdataframe_anchor", -- payload/data/MessageFrame/value/TravelerInformation/dataFrames/TravelerDataFrame/regions/GeographicalPath/anchor/elevation
"travelerdataframe", -- payload/data/MessageFrame/value/TravelerInformation/dataFrames/TravelerDataFrame/regions/GeographicalPath/
"travelerdataframe_msgid_1", -- payload/data/MessageFrame/value/TravelerInformation/dataFrames/TravelerDataFrame/msgId/roadSignID/mutcdCode
"metadata_request_snmp_channel", -- SNMP channel. Provided by the requester and used by the ODE to access the RSUs via the SNMP interface.
"travelerdataframe_msgid_crc", -- payload/data/MessageFrame/value/TravelerInformation/dataFrames/TravelerDataFrame/msgId/roadSignID/crc
"metadata_serialid_bundleid", -- Bundle identifier
"travelerdataframe_msgid_long", -- payload/data/MessageFrame/value/TravelerInformation/dataFrames/TravelerDataFrame/msgId/position/long
"travelerdataframe_2", -- payload/data/MessageFrame/value/TravelerInformation/dataFrames/TravelerDataFrame/sspMsgRights1
"travelerinformation_urlb", -- payload/data/MessageFrame/value/TravelerInformation/urlB
"metadata_securityresultcode", -- Status of IEEE 1609.2 security validation.
"travelerdataframe_desc_scale", -- payload/data/MessageFrame/value/TravelerInformation/dataFrames/TravelerDataFrame/regions/GeographicalPath/description/path/scale
"travelerdataframe_url", -- payload/data/MessageFrame/value/TravelerInformation/dataFrames/TravelerDataFrame/url
"travelerinformation_timestamp", -- payload/data/MessageFrame/value/TravelerInformation/timeStamp
"metadata_generatedat", -- Closest time to which the record was created, either signed or received by the generatedBy source in UTC format. This information is taken from the communication header.
"metadata_schemaversion", -- Version of the metadata schema
"metadata_sanitized", -- Boolean value indicating whether the data has been sanitized by the Privacy Module
"metadata_serialid_bundlesize", -- Size of the bundle within the processed file
"metadata_rmd_speed", -- Speed of vehicle when receiving the message
"metadata_rmd_rxsource", -- Source that the vehicle originally received the message from (Sat, RSU, RV)
"metadata_request_snmp", -- ISO string for message delivery start time. Provided by the requester and used by the ODE to access the RSUs via the SNMP interface.
"metadata_request_snmp_mode", -- Mode. Provided by the requester and used by the ODE to access the RSUs via the SNMP interface.
"travelerdataframe_anchor_1", -- payload/data/MessageFrame/value/TravelerInformation/dataFrames/TravelerDataFrame/regions/GeographicalPath/anchor/lat
"travelerdataframe_anchor_2", -- payload/data/MessageFrame/value/TravelerInformation/dataFrames/TravelerDataFrame/regions/GeographicalPath/anchor/long
"travelerdataframe_content_speedlimit_sequence", -- payload/data/MessageFrame/value/TravelerInformation/dataFrames/TravelerDataFrame/content/speedLimit/SEQUENCE
"travelerinformation_packetid" -- payload/data/MessageFrame/value/TravelerInformation/packetID
FROM
"datahub-transportation-gov/wyoming-cv-pilot-traveler-information-message-6nxx-nmxk:latest"."wyoming_cv_pilot_traveler_information_message"
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/wyoming-cv-pilot-traveler-information-message-6nxx-nmxk
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/wyoming-cv-pilot-traveler-information-message-6nxx-nmxk: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/wyoming-cv-pilot-traveler-information-message-6nxx-nmxk
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/wyoming-cv-pilot-traveler-information-message-6nxx-nmxk:latest
This will download all the objects for the latest
tag of datahub-transportation-gov/wyoming-cv-pilot-traveler-information-message-6nxx-nmxk
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/wyoming-cv-pilot-traveler-information-message-6nxx-nmxk: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/wyoming-cv-pilot-traveler-information-message-6nxx-nmxk: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/wyoming-cv-pilot-traveler-information-message-6nxx-nmxk
is just another Postgres schema.