• article 9‐a
  • credits

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 procotol. 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 new_york_state_corporate_tax_credit_utilization table in this repository, by referencing it like:


or in a full query, like:

    ":id", -- Socrata column ID
    "credit_type_sort_order", -- Indicator to sort the credit type.
    "amount_of_credit", -- The amount of the credit generated, claimed, used, refunded, or carried forward in the tax year based on the credit type.
    "number_of_taxpayers", -- Number of taxpayers taking the credit.
    "credit_name", -- Name of the credit. For a list of credits with detailed credit information and expiration dates, see the link to Article 9‐A credit provisions, under Additional Resources.
    "credit_type", -- Profile of credit values consisting of the components credit earned, claimed, used and carried forward. Credit earned is the amount of credit generated in the current tax year. Credit claimed is the amount of credit that taxpayers have available to use and refund during the taxable year. Credit used is the amount of credit that taxpayers actually apply to their tax liability. Credit refunded is unused credit amounts requested as a refund or applied against the next period’s liability. Credit carried forward is any unused amount of credit that is allowed to offset tax liability in future years.
    "tax_article", -- The dataset only contains data for corporate franchise taxpayers filing under Article 9‐A of the Tax Law. It does not include statistics for taxpayers filing as banks under Article 32*, insurance companies filing under Article 33, or taxpayers filing under any of the various sections of Article 9. Nor does it provide data for taxpayers claiming credits under Article 22, the Personal Income Tax. *Starting in 2015, banks and general business corporations file under the same tax article – (Article 9‐A).
    "tax_year", -- Tax year of the credit claim; typically, the year preceding the calendar year, although extensions and fiscal years may result in a longer interval.
    "notes" -- Disclosure identifies whether the data in columns have a value, but is not reported. d/ ‐ Tax Law secrecy provisions prohibit the disclosure of data for instances of less than three taxpayers. na/ ‐ credit component does not apply to the credit or that the data for that component are not available. 1/ Credit claimed for the film credit is the amount that will be used and refunded during the tax year. This differs from other credits where the claimed amount includes amounts that may ultimately go unused during the tax year and instead are carried forward for future use. The reason is because of the film credit’s unique utilization rules, which have changed since enactment. In 2006 and 2007, film credit in excess of liability was refundable across two years. In 2008, the film credit was fully refundable. Therefore, the entire amount earned in 2008 plus all amounts carried forward from 2007 were eligible to be used and refunded. In tax years 2009 and after, taxpayers must spread the credit across 1, 2, or 3 years, depending on the size of the claim. In 2006‐2007 and 2009 onward, credit carried forward amounts include the amounts that are statutorily required to be delayed 1 or 2 years. 2/ Both rules and credit rates for the Brownfield Redevelopment Tax Credit are based on the acceptance date of qualified sites into the Brownfield Cleanup Program (BCP). Acceptance date categories include sites accepted into the BCP prior to 6/23/08; sites accepted into the BCP on or after 6/23/08 but before 7/1/15; and sites accepted into the BCP on or after 7/1/15. For purposes of this dataset the acceptance date categories are combined and reported as a single credit amount and count. 3/ Data reported prior to 2011 are for a similar credit that existed for tax years beginning on or after January 1, 2006 and before January 1, 2011. Any unused credit carried forward from tax years prior to 2011 are combined with the existing credit and reported as a single credit amount and count. 4/ Data reported for the QEZE Credit for Real Property Taxes and the QEZE Tax Reduction Credit include the corresponding credit amounts for corporate partners. 5/ Chapter 56 of the Laws of 2011 created the New York Youth Works Tax Credit Program. Chapter 56 of the Laws of 2015 renamed the program the Urban Youth Jobs Program Tax Credit. Chapter 59 of the Laws of 2017 further renamed the program the New York Youth Jobs Program Tax Credit.  6/ Beginning in 2016 the Beer Production Credit was renamed the Alcoholic Beverage Production Credit and expanded to include wine, liquor and cider.
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 ny-gov/new-york-state-corporate-tax-credit-utilization-6axi-iwd2 with SQL in under 60 seconds.

This repository is an "external" repository. That means it's hosted elsewhere, in this case at data.ny.gov. When you queryny-gov/new-york-state-corporate-tax-credit-utilization-6axi-iwd2: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

Install Splitgraph Locally
bash -c "$(curl -sL https://github.com/splitgraph/splitgraph/releases/latest/download/install.sh)"

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

Mounting Data

This repository is an external repository. It's not hosted by Splitgraph. It is hosted by data.ny.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 \
  "ny-gov/new-york-state-corporate-tax-credit-utilization-6axi-iwd2" \
  --handler-options '{
    "domain": "data.ny.gov",
    "tables": {
        "new_york_state_corporate_tax_credit_utilization": "6axi-iwd2"

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, ny-gov/new-york-state-corporate-tax-credit-utilization-6axi-iwd2 is just another Postgres schema.

Related Documentation: