ftb-ca-gov/c4a-and-c4b-deductions-by-type-c-and-s-tc4b-z4fx
Loading...

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

"ftb-ca-gov/c4a-and-c4b-deductions-by-type-c-and-s-tc4b-z4fx:latest"."c4a_and_c4b_deductions_by_type_c_and_s"

or in a full query, like:

SELECT
    ":id", -- Socrata column ID
    "corporation_type", -- Designates either C or S Corporations.
    "interest", -- Interest total amount reported.
    "returns_with_contributions", -- Total number of returns reporting Contributions.
    "returns_with_total_deductions", -- Number of returns reporting total deductions.
    "recovery_property", -- Recovery Property amount reported.
    "contributions", -- Total Contributions amount reported.
    "returns_with_depreciation_amortization", -- Number of returns reporting Depreciation/Amortization.
    "returns_with_depletion", -- Number of returns reporting Depletion.
    "depletion", -- Depletion amount reported.
    "advertising", -- Total Advertising amount reported.
    "interest_on_investment_debts", -- Total Interest on Investment Debt amount reported.
    "returns_with_rents", -- Number of returns reporting Rents.
    "rents", -- Rents total amount reported.
    "returns_with_taxes", -- Number of returns reporting Tax on CA Schedule A. 
    "taxes", -- Taxes total amount reported. 
    "returns_with_interest", -- Number of returns reporting Interest.
    "bad_debts", -- Bad Debts total amount reported.
    "returns_with_bad_debts", -- Number of returns reporting Bad Debts.
    "repairs", -- Repairs total amount reported.
    "salaries_and_wages", -- Salaries and Wages total amount reported.
    "compensation_of_officers", -- Compensation of Officers total amount reported.
    "returns_with_compensation_of_officers", -- Number of returns reporting Compensation of Officers.
    "total_deductions", -- Total Deductions amount reported. 
    "returns_with_interest_on_investment_debts", -- Number of returns reporting Interest on Investment Debts.
    "returns_with_recovery_property", -- Number of returns reporting Total Recovery Property.
    "other_deductions", -- Total Other Deductions amount reported.
    "returns_with_other_deductions", -- Total number of returns reporting Other Deductions.
    "employee_benefit_plans", -- Total Employee Benefit Plans amount reported.
    "returns_with_employee_benefit_plans", -- Number of returns that reporting Employee Benefit Plans.
    "returns_with_advertising", -- Number of returns reporting Advertising. 
    "depreciation_amortization", -- Depreciation/Amortization total amount reported.
    "returns_with_repairs", -- Number of returns reporting Repairs.
    "taxable_year", -- Taxable year for which tax returns were filed in a number format that can be used to filter and sort, as well as display in charts.
    "returns_with_salaries_and_wages", -- Number of returns reporting Salaries and Wages.
    "returns_with_pension_profit_sharing_plans", -- Number of returns reporting Pension/Profit Sharing Plans.
    "pension_profit_sharing_plans", -- Total Pension/Profit Sharing Plans amount reported.
    "returns_with_misc_deductions", -- Number of returns reporting Miscellaneous Deductions.
    "misc_deductions", -- Total Miscellaneous Deductions amount reported.
    "portfolio_income", -- Total Portfolio Income amount reported.
    "returns_with_portfolio_income" -- Number of returns reporting Portfolio Income. 
FROM
    "ftb-ca-gov/c4a-and-c4b-deductions-by-type-c-and-s-tc4b-z4fx:latest"."c4a_and_c4b_deductions_by_type_c_and_s"
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 ftb-ca-gov/c4a-and-c4b-deductions-by-type-c-and-s-tc4b-z4fx with SQL in under 60 seconds.

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, 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 (like this repository), where the author has pushed Splitgraph Images to the repository, you can "clone" and/or "checkout" the data using sgr cloneand sgr checkout.

Cloning Data

Because ftb-ca-gov/c4a-and-c4b-deductions-by-type-c-and-s-tc4b-z4fx:latest is a Splitgraph Image, you can clone the data from Spltgraph Cloud to your local engine, where you can query it like any other Postgres database, using any of your existing tools.

First, install Splitgraph if you haven't already.

Clone the metadata with sgr clone

This will be quick, and does not download the actual data.

sgr clone ftb-ca-gov/c4a-and-c4b-deductions-by-type-c-and-s-tc4b-z4fx

Checkout the data

Once you've cloned the data, you need to "checkout" the tag that you want. For example, to checkout the latest tag:

sgr checkout ftb-ca-gov/c4a-and-c4b-deductions-by-type-c-and-s-tc4b-z4fx:latest

This will download all the objects for the latest tag of ftb-ca-gov/c4a-and-c4b-deductions-by-type-c-and-s-tc4b-z4fx and load them into the Splitgraph Engine. Depending on your connection speed and the size of the data, you will need to wait for the checkout to complete. Once it's complete, you will be able to query the data like you would any other Postgres database.

Alternatively, use "layered checkout" to avoid downloading all the data

The data in ftb-ca-gov/c4a-and-c4b-deductions-by-type-c-and-s-tc4b-z4fx:latest is 0 bytes. If this is too big to download all at once, or perhaps you only need to query a subset of it, you can use a layered checkout.:

sgr checkout --layered ftb-ca-gov/c4a-and-c4b-deductions-by-type-c-and-s-tc4b-z4fx:latest

This will not download all the data, but it will create a schema comprised of foreign tables, that you can query as you would any other data. Splitgraph will lazily download the required objects as you query the data. In some cases, this might be faster or more efficient than a regular checkout.

Read the layered querying documentation to learn about when and why you might want to use layered queries.

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, ftb-ca-gov/c4a-and-c4b-deductions-by-type-c-and-s-tc4b-z4fx is just another Postgres schema.

Related Documentation:

Loading...