A bad idea.
Project description
ersatz-table-valued-functions
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for ersatz-table-valued-functions-0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2247eed8c7784aaee28b1f1ccaa2618d9bc17b222493e416389f2e796fdacd17 |
|
MD5 | 0d97f9f83af620295a7bf571380197ef |
|
BLAKE2b-256 | 64495d87e3019503ed984b6b3f055ed9cde4b95478257afbd42cf7c6230b1018 |
Close
Hashes for ersatz_table_valued_functions-0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b58a91ea72007e89d58c282bc2915d2955415279152fffe6f63831bc7ed0000e |
|
MD5 | fd644ab4deeddbbe554d7f7c93e7ba98 |
|
BLAKE2b-256 | 5a095efd964cc057b3acc804cb8ff55fb4f45c644308856e802e80a138911292 |