ny-gov/new-york-state-corporate-tax-credits-by-basis-of-2rxu-2uqk
Icon for Socrata external plugin

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

"ny-gov/new-york-state-corporate-tax-credits-by-basis-of-2rxu-2uqk:latest"."new_york_state_corporate_tax_credits_by_basis_of"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "credit_type_sort_order", -- Indicator to sort the credit type.
    "group_sort_order", -- Indicator to sort by basis type.
    "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.
    "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.
    "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.
    "mean_amount_of_credit", -- Average amount of credit in a given category.
    "basis_type", -- Tax is based on either the entire net income (ENI) base, the capital base, the alternative minimum tax (AMT) base, or the fixed dollar minimum tax. Under corporate tax reform, the AMT is eliminated beginning in tax year 2015. The capital base phases out over a six‐year period beginning in tax year 2016. In tax year 2021 and thereafter, the capital base will also be eliminated. The ENI and capital bases represent taxpayers who began under these bases, used credits, and remained under these bases (despite the use of credits). The fixed dollar minimum and AMT bases represent two different classes of taxpayers. The bases could include taxpayers who started under one of the other bases such as ENI, but because of credits, ended up paying either the fixed dollar minimum tax or the AMT. These bases could also include taxpayers who used credits strictly to offset their subsidiary capital tax.
    "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. 1/ ‐ The provisions of this credit do not allow a carryforward of excess credit. Therefore, the credit earned is the same as credit claimed. 2/ ‐ The provisions of this credit do not allow a carryforward of excess credit. However, credit earned may not equal credit claimed due to statutory credit limitations. 3/ 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. 4/ Beginning in 2016 the Beer Production Credit was renamed the Alcoholic Beverage Production Credit and expanded to include wine, liquor and cider.
    "number_of_taxpayers", -- Number of taxpayers taking the credit.
    "amount_of_credit", -- The amount of the credit generated, claimed, used, refunded, or carried forward in the tax year based on the credit type.
    "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).
    "percent_of_credit", -- Percentage of the amount of credit by basis of taxation within each credit type.
    "median_amount_of_credit" -- The central value representing an equal number of credit values above and below it.
FROM
    "ny-gov/new-york-state-corporate-tax-credits-by-basis-of-2rxu-2uqk:latest"."new_york_state_corporate_tax_credits_by_basis_of"
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-credits-by-basis-of-2rxu-2uqk 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-credits-by-basis-of-2rxu-2uqk: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)"
 

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 (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-credits-by-basis-of-2rxu-2uqk" \
  --handler-options '{
    "domain": "data.ny.gov",
    "tables": {
        "new_york_state_corporate_tax_credits_by_basis_of": "2rxu-2uqk"
    }
}'

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-credits-by-basis-of-2rxu-2uqk is just another Postgres schema.