etlplus 0.12.5__tar.gz → 0.12.10__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {etlplus-0.12.5/etlplus.egg-info → etlplus-0.12.10}/PKG-INFO +119 -1
- {etlplus-0.12.5 → etlplus-0.12.10}/README.md +118 -0
- etlplus-0.12.10/etlplus/file/_imports.py +141 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/file/_io.py +1 -0
- etlplus-0.12.10/etlplus/file/accdb.py +78 -0
- etlplus-0.12.10/etlplus/file/arrow.py +78 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/file/avro.py +17 -27
- etlplus-0.12.10/etlplus/file/bson.py +77 -0
- etlplus-0.12.10/etlplus/file/cbor.py +78 -0
- etlplus-0.12.10/etlplus/file/cfg.py +79 -0
- etlplus-0.12.10/etlplus/file/conf.py +80 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/file/core.py +119 -89
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/file/csv.py +13 -1
- etlplus-0.12.10/etlplus/file/dat.py +78 -0
- etlplus-0.12.10/etlplus/file/duckdb.py +78 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/file/enums.py +113 -16
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/file/feather.py +14 -2
- etlplus-0.12.10/etlplus/file/fwf.py +77 -0
- etlplus-0.12.10/etlplus/file/ini.py +79 -0
- etlplus-0.12.10/etlplus/file/ion.py +78 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/file/json.py +13 -1
- etlplus-0.12.10/etlplus/file/log.py +78 -0
- etlplus-0.12.10/etlplus/file/mdb.py +78 -0
- etlplus-0.12.10/etlplus/file/msgpack.py +78 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/file/ndjson.py +14 -15
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/file/orc.py +14 -2
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/file/parquet.py +14 -2
- etlplus-0.12.10/etlplus/file/pb.py +78 -0
- etlplus-0.12.10/etlplus/file/pbf.py +77 -0
- etlplus-0.12.10/etlplus/file/properties.py +78 -0
- etlplus-0.12.10/etlplus/file/proto.py +77 -0
- etlplus-0.12.10/etlplus/file/psv.py +79 -0
- etlplus-0.12.10/etlplus/file/sqlite.py +78 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/file/stub.py +13 -4
- etlplus-0.12.10/etlplus/file/tab.py +81 -0
- etlplus-0.12.10/etlplus/file/toml.py +78 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/file/tsv.py +14 -1
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/file/txt.py +13 -10
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/file/xls.py +1 -1
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/file/xlsx.py +1 -1
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/file/xml.py +12 -1
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/file/yaml.py +15 -44
- {etlplus-0.12.5 → etlplus-0.12.10/etlplus.egg-info}/PKG-INFO +119 -1
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus.egg-info/SOURCES.txt +23 -1
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/unit/database/test_u_database_ddl.py +3 -2
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/unit/file/test_u_file_core.py +73 -7
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/unit/file/test_u_file_enums.py +1 -1
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/unit/file/test_u_file_yaml.py +4 -4
- etlplus-0.12.5/etlplus/file/_pandas.py +0 -58
- {etlplus-0.12.5 → etlplus-0.12.10}/.coveragerc +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/.editorconfig +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/.gitattributes +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/.github/actions/python-bootstrap/action.yml +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/.github/workflows/ci.yml +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/.gitignore +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/.pre-commit-config.yaml +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/.ruff.toml +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/CODE_OF_CONDUCT.md +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/CONTRIBUTING.md +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/DEMO.md +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/LICENSE +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/MANIFEST.in +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/Makefile +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/REFERENCES.md +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/SECURITY.md +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/SUPPORT.md +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/docs/README.md +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/docs/pipeline-guide.md +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/docs/snippets/installation_version.md +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/README.md +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/__init__.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/__main__.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/__version__.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/api/README.md +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/api/__init__.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/api/auth.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/api/config.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/api/endpoint_client.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/api/errors.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/api/pagination/__init__.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/api/pagination/client.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/api/pagination/config.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/api/pagination/paginator.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/api/rate_limiting/__init__.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/api/rate_limiting/config.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/api/rate_limiting/rate_limiter.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/api/request_manager.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/api/retry_manager.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/api/transport.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/api/types.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/cli/README.md +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/cli/__init__.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/cli/commands.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/cli/constants.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/cli/handlers.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/cli/io.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/cli/main.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/cli/options.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/cli/state.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/cli/types.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/config/README.md +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/config/__init__.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/config/connector.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/config/jobs.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/config/pipeline.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/config/profile.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/config/types.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/config/utils.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/database/README.md +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/database/__init__.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/database/ddl.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/database/engine.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/database/orm.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/database/schema.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/database/types.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/enums.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/extract.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/file/README.md +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/file/__init__.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/file/gz.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/file/zip.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/load.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/mixins.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/py.typed +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/run.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/run_helpers.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/templates/README.md +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/templates/__init__.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/templates/ddl.sql.j2 +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/templates/view.sql.j2 +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/transform.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/types.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/utils.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/validate.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/validation/README.md +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/validation/__init__.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus/validation/utils.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus.egg-info/dependency_links.txt +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus.egg-info/entry_points.txt +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus.egg-info/requires.txt +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/etlplus.egg-info/top_level.txt +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/examples/README.md +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/examples/configs/ddl_spec.yml +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/examples/configs/pipeline.yml +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/examples/data/sample.csv +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/examples/data/sample.json +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/examples/data/sample.xml +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/examples/data/sample.xsd +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/examples/data/sample.yaml +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/examples/quickstart_python.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/pyproject.toml +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/pytest.ini +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/setup.cfg +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/setup.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/__init__.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/conftest.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/integration/conftest.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/integration/test_i_cli.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/integration/test_i_examples_data_parity.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/integration/test_i_pagination_strategy.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/integration/test_i_pipeline_smoke.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/integration/test_i_pipeline_yaml_load.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/integration/test_i_run.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/integration/test_i_run_profile_pagination_defaults.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/integration/test_i_run_profile_rate_limit_defaults.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/unit/api/conftest.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/unit/api/test_u_auth.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/unit/api/test_u_config.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/unit/api/test_u_endpoint_client.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/unit/api/test_u_mocks.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/unit/api/test_u_pagination_client.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/unit/api/test_u_pagination_config.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/unit/api/test_u_paginator.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/unit/api/test_u_rate_limit_config.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/unit/api/test_u_rate_limiter.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/unit/api/test_u_request_manager.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/unit/api/test_u_retry_manager.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/unit/api/test_u_transport.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/unit/api/test_u_types.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/unit/cli/conftest.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/unit/cli/test_u_cli_handlers.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/unit/cli/test_u_cli_io.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/unit/cli/test_u_cli_main.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/unit/cli/test_u_cli_state.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/unit/config/test_u_config_utils.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/unit/config/test_u_connector.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/unit/config/test_u_jobs.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/unit/config/test_u_pipeline.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/unit/conftest.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/unit/database/test_u_database_engine.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/unit/database/test_u_database_orm.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/unit/database/test_u_database_schema.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/unit/test_u_enums.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/unit/test_u_extract.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/unit/test_u_load.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/unit/test_u_main.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/unit/test_u_mixins.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/unit/test_u_run.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/unit/test_u_run_helpers.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/unit/test_u_transform.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/unit/test_u_utils.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/unit/test_u_validate.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/unit/test_u_version.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tests/unit/validation/test_u_validation_utils.py +0 -0
- {etlplus-0.12.5 → etlplus-0.12.10}/tools/update_demo_snippets.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: etlplus
|
|
3
|
-
Version: 0.12.
|
|
3
|
+
Version: 0.12.10
|
|
4
4
|
Summary: A Swiss Army knife for simple ETL operations
|
|
5
5
|
Home-page: https://github.com/Dagitali/ETLPlus
|
|
6
6
|
Author: ETLPlus Team
|
|
@@ -68,6 +68,19 @@ package and command-line interface for data extraction, validation, transformati
|
|
|
68
68
|
- [Features](#features)
|
|
69
69
|
- [Installation](#installation)
|
|
70
70
|
- [Quickstart](#quickstart)
|
|
71
|
+
- [Data Connectors](#data-connectors)
|
|
72
|
+
- [REST APIs (`api`)](#rest-apis-api)
|
|
73
|
+
- [Databases (`database`)](#databases-database)
|
|
74
|
+
- [Files (`file`)](#files-file)
|
|
75
|
+
- [Stubbed / Placeholder](#stubbed--placeholder)
|
|
76
|
+
- [Tabular \& Delimited Text](#tabular--delimited-text)
|
|
77
|
+
- [Semi-Structured Text](#semi-structured-text)
|
|
78
|
+
- [Columnar / Analytics-Friendly](#columnar--analytics-friendly)
|
|
79
|
+
- [Binary Serialization and Interchange](#binary-serialization-and-interchange)
|
|
80
|
+
- [Databases and Embedded Storage](#databases-and-embedded-storage)
|
|
81
|
+
- [Spreadsheets](#spreadsheets)
|
|
82
|
+
- [Data Archives](#data-archives)
|
|
83
|
+
- [Logs and Event Streams](#logs-and-event-streams)
|
|
71
84
|
- [Usage](#usage)
|
|
72
85
|
- [Command Line Interface](#command-line-interface)
|
|
73
86
|
- [Argument Order and Required Options](#argument-order-and-required-options)
|
|
@@ -191,6 +204,111 @@ assert validate(filtered, rules)["valid"]
|
|
|
191
204
|
load(filtered, "file", "temp/sample_output.json", file_format="json")
|
|
192
205
|
```
|
|
193
206
|
|
|
207
|
+
## Data Connectors
|
|
208
|
+
|
|
209
|
+
Data connectors abstract sources from which to extract data and targets to which to load data. They
|
|
210
|
+
are differentiated by their types, each of which is represented in the subsections below.
|
|
211
|
+
|
|
212
|
+
### REST APIs (`api`)
|
|
213
|
+
|
|
214
|
+
ETLPlus can extract from REST APIs and load results via common HTTP methods. Supported operations
|
|
215
|
+
include GET for extract and PATCH/POST/PUT for load.
|
|
216
|
+
|
|
217
|
+
### Databases (`database`)
|
|
218
|
+
|
|
219
|
+
Database connectors use connection strings for extraction and loading, and
|
|
220
|
+
DDL can be rendered from table specs for migrations or schema checks.
|
|
221
|
+
|
|
222
|
+
### Files (`file`)
|
|
223
|
+
|
|
224
|
+
File formats are grouped as in `FileFormat`. Support is marked as:
|
|
225
|
+
|
|
226
|
+
- **Y**: implemented (may require optional dependencies)
|
|
227
|
+
- **N**: stubbed or not yet implemented
|
|
228
|
+
|
|
229
|
+
#### Stubbed / Placeholder
|
|
230
|
+
|
|
231
|
+
| Format | Supported | Description |
|
|
232
|
+
| --- | --- | --- |
|
|
233
|
+
| `stub` | N | Placeholder format for tests and future connectors. |
|
|
234
|
+
|
|
235
|
+
#### Tabular & Delimited Text
|
|
236
|
+
|
|
237
|
+
| Format | Supported | Description |
|
|
238
|
+
| --- | --- | --- |
|
|
239
|
+
| `csv` | Y | Comma-Separated Values |
|
|
240
|
+
| `fwf` | N | Fixed-Width Fields |
|
|
241
|
+
| `dat` | N | Generic data file, often delimited or fixed-width |
|
|
242
|
+
| `psv` | N | Pipe-Separated Values |
|
|
243
|
+
| `tab` | N | Often synonymous with TSV |
|
|
244
|
+
| `tsv` | Y | Tab-Separated Values |
|
|
245
|
+
| `txt` | Y | Plain text, often delimited or fixed-width |
|
|
246
|
+
|
|
247
|
+
#### Semi-Structured Text
|
|
248
|
+
|
|
249
|
+
| Format | Supported | Description |
|
|
250
|
+
| --- | --- | --- |
|
|
251
|
+
| `cfg` | N | Config-style key-value pairs |
|
|
252
|
+
| `conf` | N | Config-style key-value pairs |
|
|
253
|
+
| `ini` | N | Config-style key-value pairs |
|
|
254
|
+
| `json` | Y | JavaScript Object Notation |
|
|
255
|
+
| `ndjson` | Y | Newline-Delimited JSON |
|
|
256
|
+
| `properties` | N | Java-style key-value pairs |
|
|
257
|
+
| `toml` | N | Tom's Obvious Minimal Language |
|
|
258
|
+
| `xml` | Y | Extensible Markup Language |
|
|
259
|
+
| `yaml` | Y | YAML Ain't Markup Language |
|
|
260
|
+
|
|
261
|
+
#### Columnar / Analytics-Friendly
|
|
262
|
+
|
|
263
|
+
| Format | Supported | Description |
|
|
264
|
+
| --- | --- | --- |
|
|
265
|
+
| `arrow` | N | Apache Arrow IPC |
|
|
266
|
+
| `feather` | Y | Apache Arrow Feather |
|
|
267
|
+
| `orc` | Y | Optimized Row Columnar; common in Hadoop |
|
|
268
|
+
| `parquet` | Y | Apache Parquet; common in Big Data |
|
|
269
|
+
|
|
270
|
+
#### Binary Serialization and Interchange
|
|
271
|
+
|
|
272
|
+
| Format | Supported | Description |
|
|
273
|
+
| --- | --- | --- |
|
|
274
|
+
| `avro` | Y | Apache Avro |
|
|
275
|
+
| `bson` | N | Binary JSON; common with MongoDB exports/dumps |
|
|
276
|
+
| `cbor` | N | Concise Binary Object Representation |
|
|
277
|
+
| `ion` | N | Amazon Ion |
|
|
278
|
+
| `msgpack` | N | MessagePack |
|
|
279
|
+
| `pb` | N | Protocol Buffers (Google Protobuf) |
|
|
280
|
+
| `pbf` | N | Protocolbuffer Binary Format; often for GIS data |
|
|
281
|
+
| `proto` | N | Protocol Buffers schema; often in .pb / .bin |
|
|
282
|
+
|
|
283
|
+
#### Databases and Embedded Storage
|
|
284
|
+
|
|
285
|
+
| Format | Supported | Description |
|
|
286
|
+
| --- | --- | --- |
|
|
287
|
+
| `accdb` | N | Microsoft Access database file (newer format) |
|
|
288
|
+
| `duckdb` | N | DuckDB database file |
|
|
289
|
+
| `mdb` | N | Microsoft Access database file (older format) |
|
|
290
|
+
| `sqlite` | N | SQLite database file |
|
|
291
|
+
|
|
292
|
+
#### Spreadsheets
|
|
293
|
+
|
|
294
|
+
| Format | Supported | Description |
|
|
295
|
+
| --- | --- | --- |
|
|
296
|
+
| `xls` | Y | Microsoft Excel (BIFF); read-only |
|
|
297
|
+
| `xlsx` | Y | Microsoft Excel (Open XML) |
|
|
298
|
+
|
|
299
|
+
#### Data Archives
|
|
300
|
+
|
|
301
|
+
| Format | Supported | Description |
|
|
302
|
+
| --- | --- | --- |
|
|
303
|
+
| `gz` | Y | Gzip-compressed file |
|
|
304
|
+
| `zip` | Y | ZIP archive |
|
|
305
|
+
|
|
306
|
+
#### Logs and Event Streams
|
|
307
|
+
|
|
308
|
+
| Format | Supported | Description |
|
|
309
|
+
| --- | --- | --- |
|
|
310
|
+
| `log` | N | Generic log file |
|
|
311
|
+
|
|
194
312
|
## Usage
|
|
195
313
|
|
|
196
314
|
### Command Line Interface
|
|
@@ -18,6 +18,19 @@ package and command-line interface for data extraction, validation, transformati
|
|
|
18
18
|
- [Features](#features)
|
|
19
19
|
- [Installation](#installation)
|
|
20
20
|
- [Quickstart](#quickstart)
|
|
21
|
+
- [Data Connectors](#data-connectors)
|
|
22
|
+
- [REST APIs (`api`)](#rest-apis-api)
|
|
23
|
+
- [Databases (`database`)](#databases-database)
|
|
24
|
+
- [Files (`file`)](#files-file)
|
|
25
|
+
- [Stubbed / Placeholder](#stubbed--placeholder)
|
|
26
|
+
- [Tabular \& Delimited Text](#tabular--delimited-text)
|
|
27
|
+
- [Semi-Structured Text](#semi-structured-text)
|
|
28
|
+
- [Columnar / Analytics-Friendly](#columnar--analytics-friendly)
|
|
29
|
+
- [Binary Serialization and Interchange](#binary-serialization-and-interchange)
|
|
30
|
+
- [Databases and Embedded Storage](#databases-and-embedded-storage)
|
|
31
|
+
- [Spreadsheets](#spreadsheets)
|
|
32
|
+
- [Data Archives](#data-archives)
|
|
33
|
+
- [Logs and Event Streams](#logs-and-event-streams)
|
|
21
34
|
- [Usage](#usage)
|
|
22
35
|
- [Command Line Interface](#command-line-interface)
|
|
23
36
|
- [Argument Order and Required Options](#argument-order-and-required-options)
|
|
@@ -141,6 +154,111 @@ assert validate(filtered, rules)["valid"]
|
|
|
141
154
|
load(filtered, "file", "temp/sample_output.json", file_format="json")
|
|
142
155
|
```
|
|
143
156
|
|
|
157
|
+
## Data Connectors
|
|
158
|
+
|
|
159
|
+
Data connectors abstract sources from which to extract data and targets to which to load data. They
|
|
160
|
+
are differentiated by their types, each of which is represented in the subsections below.
|
|
161
|
+
|
|
162
|
+
### REST APIs (`api`)
|
|
163
|
+
|
|
164
|
+
ETLPlus can extract from REST APIs and load results via common HTTP methods. Supported operations
|
|
165
|
+
include GET for extract and PATCH/POST/PUT for load.
|
|
166
|
+
|
|
167
|
+
### Databases (`database`)
|
|
168
|
+
|
|
169
|
+
Database connectors use connection strings for extraction and loading, and
|
|
170
|
+
DDL can be rendered from table specs for migrations or schema checks.
|
|
171
|
+
|
|
172
|
+
### Files (`file`)
|
|
173
|
+
|
|
174
|
+
File formats are grouped as in `FileFormat`. Support is marked as:
|
|
175
|
+
|
|
176
|
+
- **Y**: implemented (may require optional dependencies)
|
|
177
|
+
- **N**: stubbed or not yet implemented
|
|
178
|
+
|
|
179
|
+
#### Stubbed / Placeholder
|
|
180
|
+
|
|
181
|
+
| Format | Supported | Description |
|
|
182
|
+
| --- | --- | --- |
|
|
183
|
+
| `stub` | N | Placeholder format for tests and future connectors. |
|
|
184
|
+
|
|
185
|
+
#### Tabular & Delimited Text
|
|
186
|
+
|
|
187
|
+
| Format | Supported | Description |
|
|
188
|
+
| --- | --- | --- |
|
|
189
|
+
| `csv` | Y | Comma-Separated Values |
|
|
190
|
+
| `fwf` | N | Fixed-Width Fields |
|
|
191
|
+
| `dat` | N | Generic data file, often delimited or fixed-width |
|
|
192
|
+
| `psv` | N | Pipe-Separated Values |
|
|
193
|
+
| `tab` | N | Often synonymous with TSV |
|
|
194
|
+
| `tsv` | Y | Tab-Separated Values |
|
|
195
|
+
| `txt` | Y | Plain text, often delimited or fixed-width |
|
|
196
|
+
|
|
197
|
+
#### Semi-Structured Text
|
|
198
|
+
|
|
199
|
+
| Format | Supported | Description |
|
|
200
|
+
| --- | --- | --- |
|
|
201
|
+
| `cfg` | N | Config-style key-value pairs |
|
|
202
|
+
| `conf` | N | Config-style key-value pairs |
|
|
203
|
+
| `ini` | N | Config-style key-value pairs |
|
|
204
|
+
| `json` | Y | JavaScript Object Notation |
|
|
205
|
+
| `ndjson` | Y | Newline-Delimited JSON |
|
|
206
|
+
| `properties` | N | Java-style key-value pairs |
|
|
207
|
+
| `toml` | N | Tom's Obvious Minimal Language |
|
|
208
|
+
| `xml` | Y | Extensible Markup Language |
|
|
209
|
+
| `yaml` | Y | YAML Ain't Markup Language |
|
|
210
|
+
|
|
211
|
+
#### Columnar / Analytics-Friendly
|
|
212
|
+
|
|
213
|
+
| Format | Supported | Description |
|
|
214
|
+
| --- | --- | --- |
|
|
215
|
+
| `arrow` | N | Apache Arrow IPC |
|
|
216
|
+
| `feather` | Y | Apache Arrow Feather |
|
|
217
|
+
| `orc` | Y | Optimized Row Columnar; common in Hadoop |
|
|
218
|
+
| `parquet` | Y | Apache Parquet; common in Big Data |
|
|
219
|
+
|
|
220
|
+
#### Binary Serialization and Interchange
|
|
221
|
+
|
|
222
|
+
| Format | Supported | Description |
|
|
223
|
+
| --- | --- | --- |
|
|
224
|
+
| `avro` | Y | Apache Avro |
|
|
225
|
+
| `bson` | N | Binary JSON; common with MongoDB exports/dumps |
|
|
226
|
+
| `cbor` | N | Concise Binary Object Representation |
|
|
227
|
+
| `ion` | N | Amazon Ion |
|
|
228
|
+
| `msgpack` | N | MessagePack |
|
|
229
|
+
| `pb` | N | Protocol Buffers (Google Protobuf) |
|
|
230
|
+
| `pbf` | N | Protocolbuffer Binary Format; often for GIS data |
|
|
231
|
+
| `proto` | N | Protocol Buffers schema; often in .pb / .bin |
|
|
232
|
+
|
|
233
|
+
#### Databases and Embedded Storage
|
|
234
|
+
|
|
235
|
+
| Format | Supported | Description |
|
|
236
|
+
| --- | --- | --- |
|
|
237
|
+
| `accdb` | N | Microsoft Access database file (newer format) |
|
|
238
|
+
| `duckdb` | N | DuckDB database file |
|
|
239
|
+
| `mdb` | N | Microsoft Access database file (older format) |
|
|
240
|
+
| `sqlite` | N | SQLite database file |
|
|
241
|
+
|
|
242
|
+
#### Spreadsheets
|
|
243
|
+
|
|
244
|
+
| Format | Supported | Description |
|
|
245
|
+
| --- | --- | --- |
|
|
246
|
+
| `xls` | Y | Microsoft Excel (BIFF); read-only |
|
|
247
|
+
| `xlsx` | Y | Microsoft Excel (Open XML) |
|
|
248
|
+
|
|
249
|
+
#### Data Archives
|
|
250
|
+
|
|
251
|
+
| Format | Supported | Description |
|
|
252
|
+
| --- | --- | --- |
|
|
253
|
+
| `gz` | Y | Gzip-compressed file |
|
|
254
|
+
| `zip` | Y | ZIP archive |
|
|
255
|
+
|
|
256
|
+
#### Logs and Event Streams
|
|
257
|
+
|
|
258
|
+
| Format | Supported | Description |
|
|
259
|
+
| --- | --- | --- |
|
|
260
|
+
| `log` | N | Generic log file |
|
|
261
|
+
|
|
144
262
|
## Usage
|
|
145
263
|
|
|
146
264
|
### Command Line Interface
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"""
|
|
2
|
+
:mod:`etlplus.file._imports` module.
|
|
3
|
+
|
|
4
|
+
Shared helpers for optional dependency imports.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from importlib import import_module
|
|
10
|
+
from typing import Any
|
|
11
|
+
|
|
12
|
+
# SECTION: INTERNAL CONSTANTS =============================================== #
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
_MODULE_CACHE: dict[str, Any] = {}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# SECTION: INTERNAL FUNCTIONS =============================================== #
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _error_message(
|
|
22
|
+
module_name: str,
|
|
23
|
+
format_name: str,
|
|
24
|
+
) -> str:
|
|
25
|
+
"""
|
|
26
|
+
Build an import error message for an optional dependency.
|
|
27
|
+
|
|
28
|
+
Parameters
|
|
29
|
+
----------
|
|
30
|
+
module_name : str
|
|
31
|
+
Module name to look up.
|
|
32
|
+
format_name : str
|
|
33
|
+
Human-readable format name for templated messages.
|
|
34
|
+
|
|
35
|
+
Returns
|
|
36
|
+
-------
|
|
37
|
+
str
|
|
38
|
+
Formatted error message.
|
|
39
|
+
"""
|
|
40
|
+
return (
|
|
41
|
+
f'{format_name} support requires '
|
|
42
|
+
f'optional dependency "{module_name}".\n'
|
|
43
|
+
f'Install with: pip install {module_name}'
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
# SECTION: FUNCTIONS ======================================================== #
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def get_optional_module(
|
|
51
|
+
module_name: str,
|
|
52
|
+
*,
|
|
53
|
+
error_message: str,
|
|
54
|
+
) -> Any:
|
|
55
|
+
"""
|
|
56
|
+
Return an optional dependency module, caching on first import.
|
|
57
|
+
|
|
58
|
+
Parameters
|
|
59
|
+
----------
|
|
60
|
+
module_name : str
|
|
61
|
+
Name of the module to import.
|
|
62
|
+
error_message : str
|
|
63
|
+
Error message to surface when the module is missing.
|
|
64
|
+
|
|
65
|
+
Returns
|
|
66
|
+
-------
|
|
67
|
+
Any
|
|
68
|
+
The imported module.
|
|
69
|
+
|
|
70
|
+
Raises
|
|
71
|
+
------
|
|
72
|
+
ImportError
|
|
73
|
+
If the optional dependency is missing.
|
|
74
|
+
"""
|
|
75
|
+
cached = _MODULE_CACHE.get(module_name)
|
|
76
|
+
if cached is not None: # pragma: no cover - tiny branch
|
|
77
|
+
return cached
|
|
78
|
+
try:
|
|
79
|
+
module = import_module(module_name)
|
|
80
|
+
except ImportError as e: # pragma: no cover
|
|
81
|
+
raise ImportError(error_message) from e
|
|
82
|
+
_MODULE_CACHE[module_name] = module
|
|
83
|
+
return module
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def get_fastavro() -> Any:
|
|
87
|
+
"""
|
|
88
|
+
Return the fastavro module, importing it on first use.
|
|
89
|
+
|
|
90
|
+
Raises an informative ImportError if the optional dependency is missing.
|
|
91
|
+
|
|
92
|
+
Notes
|
|
93
|
+
-----
|
|
94
|
+
Prefer :func:`get_optional_module` for new call sites.
|
|
95
|
+
"""
|
|
96
|
+
return get_optional_module(
|
|
97
|
+
'fastavro',
|
|
98
|
+
error_message=_error_message('fastavro', format_name='AVRO'),
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def get_pandas(
|
|
103
|
+
format_name: str,
|
|
104
|
+
) -> Any:
|
|
105
|
+
"""
|
|
106
|
+
Return the pandas module, importing it on first use.
|
|
107
|
+
|
|
108
|
+
Parameters
|
|
109
|
+
----------
|
|
110
|
+
format_name : str
|
|
111
|
+
Human-readable format name for error messages.
|
|
112
|
+
|
|
113
|
+
Returns
|
|
114
|
+
-------
|
|
115
|
+
Any
|
|
116
|
+
The pandas module.
|
|
117
|
+
|
|
118
|
+
Notes
|
|
119
|
+
-----
|
|
120
|
+
Prefer :func:`get_optional_module` for new call sites.
|
|
121
|
+
"""
|
|
122
|
+
return get_optional_module(
|
|
123
|
+
'pandas',
|
|
124
|
+
error_message=_error_message('pandas', format_name=format_name),
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def get_yaml() -> Any:
|
|
129
|
+
"""
|
|
130
|
+
Return the PyYAML module, importing it on first use.
|
|
131
|
+
|
|
132
|
+
Raises an informative ImportError if the optional dependency is missing.
|
|
133
|
+
|
|
134
|
+
Notes
|
|
135
|
+
-----
|
|
136
|
+
Prefer :func:`get_optional_module` for new call sites.
|
|
137
|
+
"""
|
|
138
|
+
return get_optional_module(
|
|
139
|
+
'yaml',
|
|
140
|
+
error_message=_error_message('PyYAML', format_name='YAML'),
|
|
141
|
+
)
|
|
@@ -107,6 +107,7 @@ def write_delimited(path: Path, data: JSONData, *, delimiter: str) -> int:
|
|
|
107
107
|
return 0
|
|
108
108
|
|
|
109
109
|
fieldnames = sorted({key for row in rows for key in row})
|
|
110
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
110
111
|
with path.open('w', encoding='utf-8', newline='') as handle:
|
|
111
112
|
writer = csv.DictWriter(
|
|
112
113
|
handle,
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"""
|
|
2
|
+
:mod:`etlplus.file.accdb` module.
|
|
3
|
+
|
|
4
|
+
Helpers for reading/writing newer Microsoft Access database (ACCDB) files.
|
|
5
|
+
|
|
6
|
+
Notes
|
|
7
|
+
-----
|
|
8
|
+
- An ACCDB file is a proprietary database file format used by Microsoft Access
|
|
9
|
+
2007 and later.
|
|
10
|
+
- Common cases:
|
|
11
|
+
- Storing relational data for small to medium-sized applications.
|
|
12
|
+
- Desktop database applications.
|
|
13
|
+
- Data management for non-enterprise solutions.
|
|
14
|
+
- Rule of thumb:
|
|
15
|
+
- If the file follows the ACCDB specification, use this module for reading
|
|
16
|
+
and writing.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
from __future__ import annotations
|
|
20
|
+
|
|
21
|
+
from pathlib import Path
|
|
22
|
+
|
|
23
|
+
from ..types import JSONData
|
|
24
|
+
from ..types import JSONList
|
|
25
|
+
from . import stub
|
|
26
|
+
|
|
27
|
+
# SECTION: EXPORTS ========================================================== #
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
__all__ = [
|
|
31
|
+
'read',
|
|
32
|
+
'write',
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
# SECTION: FUNCTIONS ======================================================== #
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def read(
|
|
40
|
+
path: Path,
|
|
41
|
+
) -> JSONList:
|
|
42
|
+
"""
|
|
43
|
+
Read ACCDB content from ``path``.
|
|
44
|
+
|
|
45
|
+
Parameters
|
|
46
|
+
----------
|
|
47
|
+
path : Path
|
|
48
|
+
Path to the ACCDB file on disk.
|
|
49
|
+
|
|
50
|
+
Returns
|
|
51
|
+
-------
|
|
52
|
+
JSONList
|
|
53
|
+
The list of dictionaries read from the ACCDB file.
|
|
54
|
+
"""
|
|
55
|
+
return stub.read(path, format_name='ACCDB')
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def write(
|
|
59
|
+
path: Path,
|
|
60
|
+
data: JSONData,
|
|
61
|
+
) -> int:
|
|
62
|
+
"""
|
|
63
|
+
Write ``data`` to ACCDB at ``path`` and return record count.
|
|
64
|
+
|
|
65
|
+
Parameters
|
|
66
|
+
----------
|
|
67
|
+
path : Path
|
|
68
|
+
Path to the ACCDB file on disk.
|
|
69
|
+
data : JSONData
|
|
70
|
+
Data to write as ACCDB. Should be a list of dictionaries or a single
|
|
71
|
+
dictionary.
|
|
72
|
+
|
|
73
|
+
Returns
|
|
74
|
+
-------
|
|
75
|
+
int
|
|
76
|
+
The number of rows written to the ACCDB file.
|
|
77
|
+
"""
|
|
78
|
+
return stub.write(path, data, format_name='ACCDB')
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"""
|
|
2
|
+
:mod:`etlplus.file.arrow` module.
|
|
3
|
+
|
|
4
|
+
Helpers for reading/writing Apache Arrow (ARROW) files.
|
|
5
|
+
|
|
6
|
+
Notes
|
|
7
|
+
-----
|
|
8
|
+
- An ARROW file is a binary file format designed for efficient
|
|
9
|
+
columnar data storage and processing.
|
|
10
|
+
- Common cases:
|
|
11
|
+
- High-performance data analytics.
|
|
12
|
+
- Interoperability between different data processing systems.
|
|
13
|
+
- In-memory data representation for fast computations.
|
|
14
|
+
- Rule of thumb:
|
|
15
|
+
- If the file follows the Apache Arrow specification, use this module for
|
|
16
|
+
reading and writing.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
from __future__ import annotations
|
|
20
|
+
|
|
21
|
+
from pathlib import Path
|
|
22
|
+
|
|
23
|
+
from ..types import JSONData
|
|
24
|
+
from ..types import JSONList
|
|
25
|
+
from . import stub
|
|
26
|
+
|
|
27
|
+
# SECTION: EXPORTS ========================================================== #
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
__all__ = [
|
|
31
|
+
'read',
|
|
32
|
+
'write',
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
# SECTION: FUNCTIONS ======================================================== #
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def read(
|
|
40
|
+
path: Path,
|
|
41
|
+
) -> JSONList:
|
|
42
|
+
"""
|
|
43
|
+
Read ARROW content from ``path``.
|
|
44
|
+
|
|
45
|
+
Parameters
|
|
46
|
+
----------
|
|
47
|
+
path : Path
|
|
48
|
+
Path to the Apache Arrow file on disk.
|
|
49
|
+
|
|
50
|
+
Returns
|
|
51
|
+
-------
|
|
52
|
+
JSONList
|
|
53
|
+
The list of dictionaries read from the Apache Arrow file.
|
|
54
|
+
"""
|
|
55
|
+
return stub.read(path, format_name='ARROW')
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def write(
|
|
59
|
+
path: Path,
|
|
60
|
+
data: JSONData,
|
|
61
|
+
) -> int:
|
|
62
|
+
"""
|
|
63
|
+
Write ``data`` to ARROW at ``path`` and return record count.
|
|
64
|
+
|
|
65
|
+
Parameters
|
|
66
|
+
----------
|
|
67
|
+
path : Path
|
|
68
|
+
Path to the ARROW file on disk.
|
|
69
|
+
data : JSONData
|
|
70
|
+
Data to write as ARROW. Should be a list of dictionaries or a
|
|
71
|
+
single dictionary.
|
|
72
|
+
|
|
73
|
+
Returns
|
|
74
|
+
-------
|
|
75
|
+
int
|
|
76
|
+
The number of rows written to the ARROW file.
|
|
77
|
+
"""
|
|
78
|
+
return stub.write(path, data, format_name='ARROW')
|
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
"""
|
|
2
2
|
:mod:`etlplus.file.avro` module.
|
|
3
3
|
|
|
4
|
-
Helpers for reading/writing Avro files.
|
|
4
|
+
Helpers for reading/writing Apache Avro (AVRO) files.
|
|
5
|
+
|
|
6
|
+
Notes
|
|
7
|
+
-----
|
|
8
|
+
- An AVRO file is a binary file format designed for efficient
|
|
9
|
+
on-disk storage of data, with a schema definition.
|
|
10
|
+
- Common cases:
|
|
11
|
+
- Data serialization for distributed systems.
|
|
12
|
+
- Interoperability between different programming languages.
|
|
13
|
+
- Storage of large datasets with schema evolution support.
|
|
14
|
+
- Rule of thumb:
|
|
15
|
+
- If the file follows the Apache Avro specification, use this module for
|
|
16
|
+
reading and writing.
|
|
5
17
|
"""
|
|
6
18
|
|
|
7
19
|
from __future__ import annotations
|
|
@@ -10,6 +22,8 @@ from pathlib import Path
|
|
|
10
22
|
from typing import Any
|
|
11
23
|
from typing import cast
|
|
12
24
|
|
|
25
|
+
from etlplus.file._imports import get_fastavro
|
|
26
|
+
|
|
13
27
|
from ..types import JSONData
|
|
14
28
|
from ..types import JSONDict
|
|
15
29
|
from ..types import JSONList
|
|
@@ -27,9 +41,6 @@ __all__ = [
|
|
|
27
41
|
# SECTION: INTERNAL CONSTANTS =============================================== #
|
|
28
42
|
|
|
29
43
|
|
|
30
|
-
_FASTAVRO_CACHE: dict[str, Any] = {}
|
|
31
|
-
|
|
32
|
-
|
|
33
44
|
_PRIMITIVE_TYPES: tuple[type, ...] = (
|
|
34
45
|
bool,
|
|
35
46
|
int,
|
|
@@ -43,27 +54,6 @@ _PRIMITIVE_TYPES: tuple[type, ...] = (
|
|
|
43
54
|
# SECTION: INTERNAL FUNCTIONS =============================================== #
|
|
44
55
|
|
|
45
56
|
|
|
46
|
-
def _get_fastavro() -> Any:
|
|
47
|
-
"""
|
|
48
|
-
Return the fastavro module, importing it on first use.
|
|
49
|
-
|
|
50
|
-
Raises an informative ImportError if the optional dependency is missing.
|
|
51
|
-
"""
|
|
52
|
-
mod = _FASTAVRO_CACHE.get('mod')
|
|
53
|
-
if mod is not None: # pragma: no cover - tiny branch
|
|
54
|
-
return mod
|
|
55
|
-
try:
|
|
56
|
-
_fastavro = __import__('fastavro') # type: ignore[assignment]
|
|
57
|
-
except ImportError as e: # pragma: no cover
|
|
58
|
-
raise ImportError(
|
|
59
|
-
'AVRO support requires optional dependency "fastavro".\n'
|
|
60
|
-
'Install with: pip install fastavro',
|
|
61
|
-
) from e
|
|
62
|
-
_FASTAVRO_CACHE['mod'] = _fastavro
|
|
63
|
-
|
|
64
|
-
return _fastavro
|
|
65
|
-
|
|
66
|
-
|
|
67
57
|
def _infer_schema(records: JSONList) -> dict[str, Any]:
|
|
68
58
|
"""
|
|
69
59
|
Infer a basic Avro schema from record payloads.
|
|
@@ -146,7 +136,7 @@ def read(
|
|
|
146
136
|
JSONList
|
|
147
137
|
The list of dictionaries read from the AVRO file.
|
|
148
138
|
"""
|
|
149
|
-
fastavro =
|
|
139
|
+
fastavro = get_fastavro()
|
|
150
140
|
with path.open('rb') as handle:
|
|
151
141
|
reader = fastavro.reader(handle)
|
|
152
142
|
return [cast(JSONDict, record) for record in reader]
|
|
@@ -175,7 +165,7 @@ def write(
|
|
|
175
165
|
if not records:
|
|
176
166
|
return 0
|
|
177
167
|
|
|
178
|
-
fastavro =
|
|
168
|
+
fastavro = get_fastavro()
|
|
179
169
|
schema = _infer_schema(records)
|
|
180
170
|
parsed_schema = fastavro.parse_schema(schema)
|
|
181
171
|
|