ny-gov/new-york-state-corporate-tax-credits-by-major-84qh-f5nv

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

"ny-gov/new-york-state-corporate-tax-credits-by-major-84qh-f5nv:latest"."new_york_state_corporate_tax_credits_by_major"

or in a full query, like:

SELECT 
    ":id", -- Socrata column ID
    "group_sort_order", -- Indicator to sort by NAICS description.
    "mean_amount_of_credit", -- Average amount of credit in a given category.
    "median_amount_of_credit", -- The central value representing an equal number of credit values above and below it.
    "percent_of_credit", -- Percentage of the amount of credit by NAICS description within each 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.
    "naics_description", -- The major industry group category is based on the North American Industry Classification System (NAICS). Taxpayers report their principal business activity using NAICS codes from their federal tax returns. Therefore, the NAICS code may not be indicative of the type of activities actually being undertaken in New York. The NAICS descriptions provided within the dataset may vary between years because NAICS codes are reviewed every five years (in the years ending in ‘2’ or ‘7’) for potential revisions so that the classification system can keep pace with the changing economy.
    "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.
    "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_sort_order", -- Indicator to sort the credit type.
    "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/ 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. 2/ Beginning in 2016 the Beer Production Credit was renamed the Alcoholic Beverage Production Credit and expanded to include wine, liquor and cider.
    "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 carried forward is any unused amount of credit that is allowed to offset tax liability in future years.
    "number_of_taxpayers", -- Number of taxpayers taking the credit.
    "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).
FROM
    "ny-gov/new-york-state-corporate-tax-credits-by-major-84qh-f5nv:latest"."new_york_state_corporate_tax_credits_by_major"
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-major-84qh-f5nv 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-major-84qh-f5nv: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-credits-by-major-84qh-f5nv" \
  --handler-options '{
    "domain": "data.ny.gov",
    "tables": {
        "new_york_state_corporate_tax_credits_by_major": "84qh-f5nv"
    }
}'

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-major-84qh-f5nv is just another Postgres schema.

Related Documentation: