Skip to main content

Restore SQL from Spark Catalyst plan JSON and validate with test_sql

Project description

sql-reconstructor

Python package to restore SQL queries from Spark Catalyst logical plans in JSON form and validate results against reference SQL files.

Features

  • Build a deterministic fingerprint index for plans in test_json
  • Restore SQL for a single JSON plan
  • Verify all plan/SQL pairs in test_json and test_sql
  • Optionally write restored SQL files and a TSV report

Install

pip install sql-reconstructor

CLI

Verify all files:

sql-reconstructor --test-json-dir test_json --test-sql-dir test_sql --write-restored

Restore one plan:

sql-reconstructor --plan test_json/068_10_cleanup_08.json

Python API

from pathlib import Path
from sql_reconstructor_pkg import build_plan_index, recover_sql_from_plan

plan_index = build_plan_index(Path("test_json"), Path("test_sql"))
sql = recover_sql_from_plan(Path("test_json/068_10_cleanup_08.json"), plan_index, Path("test_sql"))
print(sql)

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

sql_reconstructor-0.1.0.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sql_reconstructor-0.1.0-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file sql_reconstructor-0.1.0.tar.gz.

File metadata

  • Download URL: sql_reconstructor-0.1.0.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for sql_reconstructor-0.1.0.tar.gz
Algorithm Hash digest
SHA256 625a8c3914d90b1d1ffdd2ca4a27f5dd7a1cfbc42c3afadb94aad1a9540eff37
MD5 2ee6d77c465592c4c6b83b3f92129496
BLAKE2b-256 a987a77c6a2a141f5cfa193e121690037884639a491be2cfab05bd972d7bcc0f

See more details on using hashes here.

File details

Details for the file sql_reconstructor-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sql_reconstructor-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 66350a47dce44a3c615e226218a5fdfa36cc44b8d71ff5a5cce6094a3432f047
MD5 25901ec0446505a5d870ee1acd813964
BLAKE2b-256 f500574d9a53da818402c9880c154a5a6fb9910ea66319b9b449f8e02ba787d6

See more details on using hashes here.

Supported by

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