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 energy_star_certified_commercial_griddles
table in this repository, by referencing it like:
"energystar-gov/energy-star-certified-commercial-griddles-nw5s-r5ca:latest"."energy_star_certified_commercial_griddles"
or in a full query, like:
SELECT
":id", -- Socrata column ID
"brand_name", -- An identifier assigned by the manufacturer or private labeler to a product or family/series of products for sales and marketing purposes.
"model_name", -- An identifier assigned by the manufacturer or private labeler to a product or family/series of products for sales and marketing purposes.
"product_type", -- Designates whether the model is a single-sided or double-sided commercial griddle. A double-sided griddle has hinged upper griddle plates (platens) that swing down over the food, thereby cooking the food from both sides at once.
"additional_model_information", -- This column includes for the qualified model or family, family members, additional model names, model numbers and other identifying information associated with a product or family/series of products for sales and marketing purposes. Other identifying information includes, but is not limited to, SKUs, UPC codes, retail numbers, and/or descriptions of models included/not included in the reported Model Family.
"energy_star_model_identifier", -- A unique string of characters assigned by certification bodies (CBs) to identify a model or set of models with the same performance characteristics. This identifier should remain the same for a model even if it is recertified to a new version of an ENERGY STAR specification. This string of characters is determined by CBs and is not the ENERGY STAR Unique ID assigned by EPA.
"fuel_type", -- Designates the fuel type used by the commercial griddle. Qualified commercial griddle models are either gas or electric.
"markets", -- Includes products sold in the U.S. and/or Canada and other ENERGY STAR partner countries.
"tested_configuration", -- This column designates whether the model was tested in the single-sided or double-sided configuration.
"energy_star_partner", -- An organization that signed a Partnership Agreement with EPA to manufacture or private label ENERGY STAR qualified products.
"upc", -- UPC codes provided by partners for ENERGY STAR certified products. The brand, model name and model number continue to serve as the identifiers used to establish certification. The UPC code data below is intended to aid in identification of ENERGY STAR models. UPC code data is not provided for all certified models.
"top_platen_type", -- This field demonstrates whether the product has integrated or add-on top platens. This impacts the testing of the models as single- or double-sided.
"width_ft", -- Designates the width of the griddle in ft. For qualification of a product family, the 3 ft. model within the product family can serve as the representative model. (If product family includes units smaller than 3 ft.; however, each additional unit shall be tested and qualified separately from its product family.)
"griddle_plate_type_description", -- This field provides additional details as to the type of griddle plate used (e.g., polished steel or chrome ½-inch grooved plate).
"cooking_surface_sq_ft", -- Represents the surface area of the commercial griddle (width multiplied by the depth).
"normalized_idle_energy_rate_watts_per_ft", -- For electric griddles, this field expresses the rate of griddle energy consumption while it is maintaining or holding at a stabilized operating condition or temperature. The idle rate is normalized based on the area of the (bottom) cooking surface.
"model_number", -- A distinguishing, alphanumeric identifier, assigned to a product by the manufacturer or private labeler. The model number may include a wildcard that can be replaced by any letter or digit and still accurately capture what is covered by the model’s ENERGY STAR certification; an asterisk symbol (*) represents a letter, and a number symbol (#) a digit.
"cooking_energy_efficiency", -- The ratio of energy absorbed by the food product to the total energy supplied to the griddle during cooking.
"production_capacity_lbs_hr", -- The maximum production rate of the griddle while cooking a specified food product in accordance with the heavy-load cooking-energy efficiency test, expressed in pounds per hour. The production rate is the average rate at which the griddle brings a specified food product to a specified final temperature.
"date_available_on_market", -- The date that the model is available for purchase.
"date_qualified", -- The date on which the product was confirmed to meet the ENERGY STAR specification.
"pd_id", -- The ENERGY STAR Unique ID (ESUID) is a string of seven numbers EPA assigns to an ENERGY STAR model or set of models with unique performance characteristics. This ESUID is unique to both the model and product specification version and is assigned by EPA upon receipt of certification information from the certification body. Each row within the product list will have a unique ESUID. Developers may wish to use this ESUID to track information on certified models in their information systems.
"normalized_idle_energy_rate_btu_h_per_ft", -- For gas griddles, this field expresses the rate of griddle energy consumption while it is maintaining or holding at a stabilized operating condition or temperature. The idle rate is normalized based on the area of the (bottom) cooking surface.
"depth_ft" -- Designates the depth of the griddle in ft.
FROM
"energystar-gov/energy-star-certified-commercial-griddles-nw5s-r5ca:latest"."energy_star_certified_commercial_griddles"
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 energystar-gov/energy-star-certified-commercial-griddles-nw5s-r5ca
with SQL in under 60 seconds.
This repository is an "external" repository. That means it's hosted elsewhere, in this case at data.energystar.gov. When you queryenergystar-gov/energy-star-certified-commercial-griddles-nw5s-r5ca: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 data.energystar.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 \
"energystar-gov/energy-star-certified-commercial-griddles-nw5s-r5ca" \
--handler-options '{
"domain": "data.energystar.gov",
"tables": {
"energy_star_certified_commercial_griddles": "nw5s-r5ca"
}
}'
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, energystar-gov/energy-star-certified-commercial-griddles-nw5s-r5ca
is just another Postgres schema.