datahub-transportation-gov/2014-its-world-congress-connected-vehicle-test-bed-swef-k9yw
Loading...

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 2014_its_world_congress_connected_vehicle_test_bed table in this repository, by referencing it like:

"datahub-transportation-gov/2014-its-world-congress-connected-vehicle-test-bed-swef-k9yw:latest"."2014_its_world_congress_connected_vehicle_test_bed"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "asdbundles_asdrecords_broadcastinst_bidelievrystop_hour", -- This field contains the hour in which the message should stop being available to vehicles.
    "dialogid", -- This field contains the ID of the type of data being transmitted.  In this instance all entries will be “advSitDatDistRSE” indicating that traveler situation data (TSD) is being transmitted / presented here.
    "asdbundles_asdrecords_broadcastinst_bideliverystop_year", -- This field contains the year in which the message should stop being available to vehicles.
    "asdbundles_asdrecords_broadcastinst_bisignature", -- This field contains information on whether the message has been signed.
    "asdbundles_asdrecords_broadcastinst_bideliverystart_minute", -- This field contains the minute in which the message should become available to vehicles
    "asdbundles_bundlenumber", -- This field contains the sequence number in a bundle of TSDs
    "asdbundles_asdrecords_broadcastinst_bideliverystop_day", -- This field contains the day in which the message should stop being available to vehicles.
    "asdbundles_bundlecount", -- This field contains the number of bundles in the TSD.
    "asdbundles_asdrecords_broadcastinst_bideliverystop_month", -- This field contains the month in which the message should stop being available to vehicles.
    "requestid", -- This field contains the ID (number) of the TSD.
    "asdbundles_bundleid", -- This field contains the ID (number) of a bundle.
    "asdbundles_asdrecords_broadcastinst_bipriority", -- This field contains the priority of the broadcast message, presented in an 8 bit binary string. The 5 least significant bits are reserved (and set to 0). A priority of all zeros is used for routing messages such as roadside signage where not displaying the message to the driver is only of modest impact. A value of 111xxxxx indicates a message of the highest priority. Other priorities are set according to local conventions.  Values in decimal should be converted back to the 8 bit binary string and interpreted as described above.  For example, a value of 32 is 00100000 in binary and corresponds to a broadcast priority of 1 (low). 
    "asdbundles_asdrecords_broadcastinst_bitxchannel", -- This field contains the transmission channel of the broadcast message. Possible values are chControl, chService, and ch172, 174,176, 178, 780, 182, and 184.
    "asdbundles_asdrecords_broadcastinst_bideliverystart_year", -- This field contains the year in which the message should become available to vehicles
    "asdbundles_asdrecords_broadcastinst_bideliverystart_month", -- This field contains the month in which the message should become available to vehicles
    "asdbundles_asdrecords_broadcastinst_biencryption", -- This field contains information on whether the message is encrypted.
    "asdbundles_asdrecords_broadcastinst_bipsid", -- This field contains the ID (number) of the broadcast.
    "asdbundles_asdrecords_broadcastinst_bideliverystart_hour", -- This field contains the hour in which the message should become available to vehicles
    "asdbundles_asdrecords_broadcastinst_bidelievrystop_minute", -- This field contains the minute in which the message should stop being available to vehicles.
    "recordcount", -- This field contains the total number of records received in the TSD query, summed across all bundles.
    "asdbundles_asdrecords_advisorymessage", -- This field contains a complete TIM according to the SAE J2735 Standard which is based on a tag-length-value structure of the ASN.1 BER-DER formatted data. To provide insight into decoding these entries the following table will present the breakdown of a single message and summarize each of its components.  As one will see in the table below, critical to decoding these entries in the translation of the ITIS codes into their meaning.  To translate these codes user are advised to consult the SAE J2540 Standard.  TIM messages, which are contained in this *_advisoryMessage field is comprised of three parts: Part I is header, Part II is common anchor, Part III is content, all of them are colored coded in the table below.  Additionally, in the table below data element are shown in two colors, blue is for data type and red is data name.
    "asdbundles_asdrecords_broadcastinst_bitxinterval", -- This field contains the time interval at which to transmit message snapshots, in 1/10th integer seconds.
    "asdbundles_asdrecords_broadcastinst_bitype", -- This field contains the type of broadcast message. For the TSD dataset, this data element takes only one value: {tim}, since this data file is communicating TSDs
    "asdbundles_asdrecords_broadcastinst_bitxmode", -- This field contains the transmission mode of the broadcast message. For the TSD dataset, this data element takes only one value: {alternating}
    "seqid", -- This field communicate the message content type.  All entries in this instance will be “data” indicating that the data portion of the transmitted message is presented. 
    "asdbundles_asdrecords_broadcastinst_bideliverystart_day" -- This field contains the day in which the message should become available to vehicles
FROM
    "datahub-transportation-gov/2014-its-world-congress-connected-vehicle-test-bed-swef-k9yw:latest"."2014_its_world_congress_connected_vehicle_test_bed"
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/2014-its-world-congress-connected-vehicle-test-bed-swef-k9yw with SQL in under 60 seconds.

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, 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 cloneand sgr checkout.

Cloning Data

Because datahub-transportation-gov/2014-its-world-congress-connected-vehicle-test-bed-swef-k9yw: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/2014-its-world-congress-connected-vehicle-test-bed-swef-k9yw

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/2014-its-world-congress-connected-vehicle-test-bed-swef-k9yw:latest

This will download all the objects for the latest tag of datahub-transportation-gov/2014-its-world-congress-connected-vehicle-test-bed-swef-k9yw 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/2014-its-world-congress-connected-vehicle-test-bed-swef-k9yw: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/2014-its-world-congress-connected-vehicle-test-bed-swef-k9yw: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/2014-its-world-congress-connected-vehicle-test-bed-swef-k9yw is just another Postgres schema.

Related Documentation:

Loading...