Skip to main content

Python Implementation of Pipelined Relational Query Language (PRQL)

Project description

PyPrql

Python implementation of PRQL.

Documentation of PRQL is at https://github.com/max-sixty/prql

from employees
filter country = "USA"
derive [
  gross_salary: salary + payroll_tax,
  gross_cost:   gross_salary + benefits_cost
]
filter gross_cost > 0
aggregate by:[title, country] [
    average salary,
    sum     salary,
    average gross_salary,
    sum     gross_salary,
    average gross_cost,
    sum_gross_cost: sum gross_cost,
    row_count: count salary
]
sort sum_gross_cost
filter row_count > 200
take 20

from pyprql import prql

sql = prql.to_sql(q)
print(sql)

SELECT AVG(salary),
       SUM(salary),
       AVG(salary + payroll_tax),
       SUM(salary + payroll_tax),
       AVG(salary + payroll_tax + benefits_cost),
       SUM(salary + payroll_tax + benefits_cost) as sum_gross_cost,
       COUNT(salary)                             as row_count,
       salary + payroll_tax                      as gross_salary,
       (salary + payroll_tax) + benefits_cost    as gross_cost
FROM ` employees ` employees_e
WHERE country="USA" AND (gross_salary+benefits_cost)>0
GROUP BY title, country
HAVING row_count >200
ORDER BY sum_gross_cost
LIMIT 20

Differences from the spec

The parser is only able to parse casts in select statements insde of [ ], so

select foo | as float

will fail, it must be wrapped in brackets as a single item list.

select [ foo | as float ]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyprql-0.1.2.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

pyprql-0.1.2-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

Details for the file pyprql-0.1.2.tar.gz.

File metadata

  • Download URL: pyprql-0.1.2.tar.gz
  • Upload date:
  • Size: 16.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for pyprql-0.1.2.tar.gz
Algorithm Hash digest
SHA256 f66742628e429fc6c6b9a8a33e6113ccdbf3163d89f42f12aa904ee9883db796
MD5 1159d6aace26b644ae115d98034ebf0f
BLAKE2b-256 d14df51d1e03df9fe29407f651ed78ac2023c391876aea5a497cb3f8cd872180

See more details on using hashes here.

Provenance

File details

Details for the file pyprql-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pyprql-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 15.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for pyprql-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ecea343ea69438031781071b8a585e3458b1f8fb409da83bca4ca2a2afee21bb
MD5 65490b0d2c40d4a0307547ed276a00ca
BLAKE2b-256 f931235656e1a2eb1c3ade53e047e0babc373af42250a73314c30a3c2611b421

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page