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_ice_machines
table in this repository, by referencing it like:
"energystar-gov/energy-star-certified-commercial-ice-machines-nak5-fsjf:latest"."energy_star_certified_commercial_ice_machines"
or in a full query, like:
SELECT
":id", -- Socrata column ID
"markets", -- Includes products sold in the U.S. and/or Canada and other ENERGY STAR partner countries.
"refrigerant_with_gwp", -- Refrigerants are substances that cool or heat and are often used in refrigeration and HVAC equipment. Many refrigerants are harmful atmospheric pollutants that have a high global warming potential (GWP). Lower-GWP alternative refrigerant options for commercial ice machines include R-290, R-450A, and R-513A.
"capabilities_summary", -- This summarizes the connected functionality capabilities if the model has connected functionality.
"direct_on_premises_open_standard_based_interconnection", -- Connected products may or may not enable open-standards connectivity. Consider the following illustrative examples: "Yes" A product that can directly communicate using Wi-Fi and OpenADR, or wired Ethernet and SEP 2.x; "No" A product that uses proprietary communications to/from the cloud, and is capable of supporting open-standards communications only in the cloud.
"date_available_on_market", -- The date that the model is available for purchase.
"equipment_type", -- The type of equipment category the ice maker falls into. The three categories include Ice Making Head (IMH), Remote Condensing Unit (RCU) with remote compressor, Remote Condensing Unit (RCU) without remote compressor, and Self-Contained Unit (SCU).
"comminucation_standard_application_layer", -- Open Standard - Application Layer include SEP 1.x, SEP2.x, OpenADR, etc.
"ice_type", -- The type of ice the ice maker produces. Options include batch-type (which include cube type ice and other batch technologies) and continuous-type (which include flake and nugget ice types).
"connects_using", -- Provides guidance about what is needed to enable connected capabilities like smart phone control, e.g. ‘WiFi’ or Zigbee.
"refrigerant_type", -- Indicates the refrigerant type used.
"energy_use_kwh_100_lbs_ice", -- The total energy input rate, stated in kWh/100 lb [kWh/45.0 kg] of ice. For continuous type commercial ice makers this reflects the measured energy consumption per 100 lbs ice, multiplied by the ice hardness adjustment factor. (For batch type commercial ice makers the ice hardness is assumed to be 100%, therefore no adjustment is needed.) For RCU (with remote compressor), total energy consumed shall include the energy use of the ice-making mechanism, the compressor and the remote condensing unit.
"harvest_rate_lbs_ice_day", -- The gross weight of ice harvested, stated in lb/24 h [kg/24 h], stated in multiples of 1.
"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.
"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.
"energy_star_partner", -- An organization that signed a Partnership Agreement with EPA to manufacture or private label ENERGY STAR qualified products.
"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.
"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.
"date_qualified", -- The date on which the product was confirmed to meet the ENERGY STAR specification.
"condenser_unit_model_number_if_applicable", -- If the product type is RCU, this field provides the model number of the remote condenser unit that is to accompany the ice-making mechanism (i.e., what condenser the unit was tested with and qualifies for ENERGY STAR under).
"model_name", -- An identifier assigned by the manufacturer or private labeler to a product or family/series of products for sales and marketing purposes.
"brand_name", -- An identifier assigned by the manufacturer or private labeler to a product or family/series of products for sales and marketing purposes.
"ice_hardness_factor", -- The net cooling effect of ice harvested (Btu/lb) divided by 144 (Btu/lb), expressed as a percent. The Ice Hardness Factor for batch type machines is assumed to be 100%, but must be tested and reported for continuous type machine certification. (For certain models this may exceed 100%.)
"connected_functionality", -- Indicates whether the model offers advanced controls and increased functionality such as load shifting, ice level sensor and Demand Response exit points. Commercial ice machines with connected functionality are smart grid ready; if linked with your energy provider or an energy management system these products can dynamically adjust their energy use, potentially lowering electric bills.
"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.
"potable_water_use_gal_100_lbs_ice" -- The amount of potable water used in making ice, which is equal to the sum of the ice harvested, Dump or Purge Water, and the Harvest Water expressed in gal/100 lb [L/45.0 kg] of ice, stated in multiples of 0.1. Alternatively, the amount of water entering the ice maker per cycle can be measured.
FROM
"energystar-gov/energy-star-certified-commercial-ice-machines-nak5-fsjf:latest"."energy_star_certified_commercial_ice_machines"
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-ice-machines-nak5-fsjf
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-ice-machines-nak5-fsjf: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-ice-machines-nak5-fsjf" \
--handler-options '{
"domain": "data.energystar.gov",
"tables": {
"energy_star_certified_commercial_ice_machines": "nak5-fsjf"
}
}'
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-ice-machines-nak5-fsjf
is just another Postgres schema.