Skip to main content

ersatz-table-valued-functions

PyPI Changelog License

A bad idea.

ersatz (adj.): made or used as a substitute, typically an inferior one, for something else.

Installation

Install this library using pip:

pip install ersatz-table-valued-functions

Usage

This library lets you rewrite queries like:

SELECT root, square FROM tbl_squares(3)

into queries like:

WITH _ersatz_1 AS (
  SELECT
    JSON_EXTRACT(value, '$[0]') AS "root",
    JSON_EXTRACT(value, '$[1]') AS "square"
  FROM JSON_EACH((SELECT tbl_squares(3)))
)
SELECT root, square FROM _ersatz_1

That is: it translates a query that looks like it needs a table-valued function into one that uses a scalar-valued function that returns a JSON 2D array.

To use it:

from ersatz_table_valued_functions import rewrite

rewrite('SELECT root, square FROM tbl_squares(3)', { 'TBL_SQUARES': ['root', 'square'] })

Development

To contribute to this library, first checkout the code. Then create a new virtual environment:

cd ersatz-table-valued-functions
python -m venv venv
source venv/bin/activate

Now install the dependencies and test dependencies:

pip install -e '.[test]'

To run the tests:

pytest

Metadata

Release files for ersatz-table-valued-functions 0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ersatz-table-valued-functions 0.2
File Size Uploaded
ersatz-table-valued-functions-0.2.tar.gz 7.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ersatz-table-valued-functions 0.2
File Interpreter ABI Platform
ersatz_table_valued_functions-0.2-py3-none-any.whl Python 3 none any Details

Total release size: 15.0 kB

Release files / ersatz-table-valued-functions-0.2.tar.gz

Download URL ersatz-table-valued-functions-0.2.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
2247eed8c7784aaee28b1f1ccaa2618d9bc17b222493e416389f2e796fdacd17
BLAKE2b-256 checksum
How to use checksums
64495d87e3019503ed984b6b3f055ed9cde4b95478257afbd42cf7c6230b1018
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.1

Release files / ersatz_table_valued_functions-0.2-py3-none-any.whl

Download URL ersatz_table_valued_functions-0.2-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b58a91ea72007e89d58c282bc2915d2955415279152fffe6f63831bc7ed0000e
BLAKE2b-256 checksum
How to use checksums
5a095efd964cc057b3acc804cb8ff55fb4f45c644308856e802e80a138911292
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.1

Release history Release notifications | RSS feed

This release

0.2 This release

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page