dynamicio 9.1.0__tar.gz → 9.2.0__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.
Files changed (164) hide show
  1. dynamicio-9.2.0/.github/dependabot.yml +12 -0
  2. {dynamicio-9.1.0 → dynamicio-9.2.0}/.github/workflows/build_and_publish.yml +1 -1
  3. {dynamicio-9.1.0 → dynamicio-9.2.0}/.github/workflows/pr_title_checker.yml +1 -1
  4. {dynamicio-9.1.0 → dynamicio-9.2.0}/AGENTS.md +3 -0
  5. {dynamicio-9.1.0 → dynamicio-9.2.0}/CHANGELOG.md +7 -0
  6. {dynamicio-9.1.0 → dynamicio-9.2.0}/PKG-INFO +1 -1
  7. {dynamicio-9.1.0 → dynamicio-9.2.0}/docs/adr/0001-direct-boto3-s3-io.md +1 -0
  8. dynamicio-9.2.0/docs/adr/0004-ranged-parquet-reads-with-filters.md +33 -0
  9. {dynamicio-9.1.0 → dynamicio-9.2.0}/docs/adr/README.md +1 -0
  10. {dynamicio-9.1.0 → dynamicio-9.2.0}/dynamicio/mixins/utils.py +4 -0
  11. {dynamicio-9.1.0 → dynamicio-9.2.0}/dynamicio/mixins/with_postgres.py +27 -4
  12. {dynamicio-9.1.0 → dynamicio-9.2.0}/dynamicio/mixins/with_s3.py +38 -0
  13. {dynamicio-9.1.0 → dynamicio-9.2.0}/pyproject.toml +4 -1
  14. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/test_mixins/test_postgres_mixins.py +150 -0
  15. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/test_mixins/test_s3_mixins.py +411 -0
  16. {dynamicio-9.1.0 → dynamicio-9.2.0}/uv.lock +1364 -21
  17. dynamicio-9.1.0/.github/dependabot.yml +0 -12
  18. {dynamicio-9.1.0 → dynamicio-9.2.0}/.claude/skills/create-pr/SKILL.md +0 -0
  19. {dynamicio-9.1.0 → dynamicio-9.2.0}/.coveragerc +0 -0
  20. {dynamicio-9.1.0 → dynamicio-9.2.0}/.flake8 +0 -0
  21. {dynamicio-9.1.0 → dynamicio-9.2.0}/.github/CODEOWNERS +0 -0
  22. {dynamicio-9.1.0 → dynamicio-9.2.0}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  23. {dynamicio-9.1.0 → dynamicio-9.2.0}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
  24. {dynamicio-9.1.0 → dynamicio-9.2.0}/.github/pull_request_template.md +0 -0
  25. {dynamicio-9.1.0 → dynamicio-9.2.0}/.gitignore +0 -0
  26. {dynamicio-9.1.0 → dynamicio-9.2.0}/.gitlint +0 -0
  27. {dynamicio-9.1.0 → dynamicio-9.2.0}/.pre-commit-config.yaml +0 -0
  28. {dynamicio-9.1.0 → dynamicio-9.2.0}/.pylintrc +0 -0
  29. {dynamicio-9.1.0 → dynamicio-9.2.0}/.python-version +0 -0
  30. {dynamicio-9.1.0 → dynamicio-9.2.0}/.yamllint +0 -0
  31. {dynamicio-9.1.0 → dynamicio-9.2.0}/CONTRIBUTING.md +0 -0
  32. {dynamicio-9.1.0 → dynamicio-9.2.0}/LICENSE +0 -0
  33. {dynamicio-9.1.0 → dynamicio-9.2.0}/Makefile +0 -0
  34. {dynamicio-9.1.0 → dynamicio-9.2.0}/README.md +0 -0
  35. {dynamicio-9.1.0 → dynamicio-9.2.0}/catalog-info.yaml +0 -0
  36. {dynamicio-9.1.0 → dynamicio-9.2.0}/demo/__init__.py +0 -0
  37. {dynamicio-9.1.0 → dynamicio-9.2.0}/demo/resources/definitions/input.yaml +0 -0
  38. {dynamicio-9.1.0 → dynamicio-9.2.0}/demo/resources/definitions/processed.yaml +0 -0
  39. {dynamicio-9.1.0 → dynamicio-9.2.0}/demo/resources/definitions/raw.yaml +0 -0
  40. {dynamicio-9.1.0 → dynamicio-9.2.0}/demo/resources/schemas/input/bar.yaml +0 -0
  41. {dynamicio-9.1.0 → dynamicio-9.2.0}/demo/resources/schemas/input/events.yaml +0 -0
  42. {dynamicio-9.1.0 → dynamicio-9.2.0}/demo/resources/schemas/input/foo.yaml +0 -0
  43. {dynamicio-9.1.0 → dynamicio-9.2.0}/demo/resources/schemas/processed/final_bar.yaml +0 -0
  44. {dynamicio-9.1.0 → dynamicio-9.2.0}/demo/resources/schemas/processed/final_foo.yaml +0 -0
  45. {dynamicio-9.1.0 → dynamicio-9.2.0}/demo/src/__init__.py +0 -0
  46. {dynamicio-9.1.0 → dynamicio-9.2.0}/demo/src/__main__.py +0 -0
  47. {dynamicio-9.1.0 → dynamicio-9.2.0}/demo/src/constants.py +0 -0
  48. {dynamicio-9.1.0 → dynamicio-9.2.0}/demo/src/environment.py +0 -0
  49. {dynamicio-9.1.0 → dynamicio-9.2.0}/demo/src/io.py +0 -0
  50. {dynamicio-9.1.0 → dynamicio-9.2.0}/demo/src/runner_selection.py +0 -0
  51. {dynamicio-9.1.0 → dynamicio-9.2.0}/demo/src/runners/__init__.py +0 -0
  52. {dynamicio-9.1.0 → dynamicio-9.2.0}/demo/src/runners/staging.py +0 -0
  53. {dynamicio-9.1.0 → dynamicio-9.2.0}/demo/src/runners/transform.py +0 -0
  54. {dynamicio-9.1.0 → dynamicio-9.2.0}/demo/tests/__init__.py +0 -0
  55. {dynamicio-9.1.0 → dynamicio-9.2.0}/demo/tests/conftest.py +0 -0
  56. {dynamicio-9.1.0 → dynamicio-9.2.0}/demo/tests/constants.py +0 -0
  57. {dynamicio-9.1.0 → dynamicio-9.2.0}/demo/tests/data/input/bar.parquet +0 -0
  58. {dynamicio-9.1.0 → dynamicio-9.2.0}/demo/tests/data/input/events/part_2026.parquet +0 -0
  59. {dynamicio-9.1.0 → dynamicio-9.2.0}/demo/tests/data/input/foo.csv +0 -0
  60. {dynamicio-9.1.0 → dynamicio-9.2.0}/demo/tests/data/processed/expected/final_bar.parquet +0 -0
  61. {dynamicio-9.1.0 → dynamicio-9.2.0}/demo/tests/data/processed/expected/final_foo.parquet +0 -0
  62. {dynamicio-9.1.0 → dynamicio-9.2.0}/demo/tests/data/raw/expected/staged_bar.parquet +0 -0
  63. {dynamicio-9.1.0 → dynamicio-9.2.0}/demo/tests/data/raw/expected/staged_foo.parquet +0 -0
  64. {dynamicio-9.1.0 → dynamicio-9.2.0}/demo/tests/runners/__init__.py +0 -0
  65. {dynamicio-9.1.0 → dynamicio-9.2.0}/demo/tests/runners/conftest.py +0 -0
  66. {dynamicio-9.1.0 → dynamicio-9.2.0}/demo/tests/runners/test_staging.py +0 -0
  67. {dynamicio-9.1.0 → dynamicio-9.2.0}/demo/tests/runners/test_transform.py +0 -0
  68. {dynamicio-9.1.0 → dynamicio-9.2.0}/demo/tests/test_pipeline.py +0 -0
  69. {dynamicio-9.1.0 → dynamicio-9.2.0}/demo/tests/test_prefix_schema_evolution.py +0 -0
  70. {dynamicio-9.1.0 → dynamicio-9.2.0}/demo/tests/test_runner_selection.py +0 -0
  71. {dynamicio-9.1.0 → dynamicio-9.2.0}/docs/adr/0002-tolerate-missing-columns-in-parquet-prefix-reads.md +0 -0
  72. {dynamicio-9.1.0 → dynamicio-9.2.0}/docs/adr/0003-athena-via-aws-wrangler.md +0 -0
  73. {dynamicio-9.1.0 → dynamicio-9.2.0}/docs/api.md +0 -0
  74. {dynamicio-9.1.0 → dynamicio-9.2.0}/docs/images/data-types.png +0 -0
  75. {dynamicio-9.1.0 → dynamicio-9.2.0}/docs/images/logo-original.png +0 -0
  76. {dynamicio-9.1.0 → dynamicio-9.2.0}/docs/images/logo-transparent.png +0 -0
  77. {dynamicio-9.1.0 → dynamicio-9.2.0}/docs/images/perf-awswrangler-vs-awscli/chart_read.png +0 -0
  78. {dynamicio-9.1.0 → dynamicio-9.2.0}/docs/images/perf-awswrangler-vs-awscli/chart_read_correction.png +0 -0
  79. {dynamicio-9.1.0 → dynamicio-9.2.0}/docs/images/perf-awswrangler-vs-awscli/chart_write.png +0 -0
  80. {dynamicio-9.1.0 → dynamicio-9.2.0}/docs/images/perf-pipeline-run/pipeline-task-delta.png +0 -0
  81. {dynamicio-9.1.0 → dynamicio-9.2.0}/docs/images/sample-pipeline.png +0 -0
  82. {dynamicio-9.1.0 → dynamicio-9.2.0}/docs/images/supported_sources.png +0 -0
  83. {dynamicio-9.1.0 → dynamicio-9.2.0}/docs/images/wrapped-panda.png +0 -0
  84. {dynamicio-9.1.0 → dynamicio-9.2.0}/docs/index.md +0 -0
  85. {dynamicio-9.1.0 → dynamicio-9.2.0}/docs/perf-s3-io.md +0 -0
  86. {dynamicio-9.1.0 → dynamicio-9.2.0}/dynamicio/__init__.py +0 -0
  87. {dynamicio-9.1.0 → dynamicio-9.2.0}/dynamicio/__main__.py +0 -0
  88. {dynamicio-9.1.0 → dynamicio-9.2.0}/dynamicio/animals.py +0 -0
  89. {dynamicio-9.1.0 → dynamicio-9.2.0}/dynamicio/cli.py +0 -0
  90. {dynamicio-9.1.0 → dynamicio-9.2.0}/dynamicio/config/__init__.py +0 -0
  91. {dynamicio-9.1.0 → dynamicio-9.2.0}/dynamicio/config/io_config.py +0 -0
  92. {dynamicio-9.1.0 → dynamicio-9.2.0}/dynamicio/config/pydantic/__init__.py +0 -0
  93. {dynamicio-9.1.0 → dynamicio-9.2.0}/dynamicio/config/pydantic/config.py +0 -0
  94. {dynamicio-9.1.0 → dynamicio-9.2.0}/dynamicio/config/pydantic/io_resources.py +0 -0
  95. {dynamicio-9.1.0 → dynamicio-9.2.0}/dynamicio/config/pydantic/table_schema.py +0 -0
  96. {dynamicio-9.1.0 → dynamicio-9.2.0}/dynamicio/core.py +0 -0
  97. {dynamicio-9.1.0 → dynamicio-9.2.0}/dynamicio/errors.py +0 -0
  98. {dynamicio-9.1.0 → dynamicio-9.2.0}/dynamicio/metrics.py +0 -0
  99. {dynamicio-9.1.0 → dynamicio-9.2.0}/dynamicio/mixins/__init__.py +0 -0
  100. {dynamicio-9.1.0 → dynamicio-9.2.0}/dynamicio/mixins/with_athena.py +0 -0
  101. {dynamicio-9.1.0 → dynamicio-9.2.0}/dynamicio/mixins/with_kafka.py +0 -0
  102. {dynamicio-9.1.0 → dynamicio-9.2.0}/dynamicio/mixins/with_local.py +0 -0
  103. {dynamicio-9.1.0 → dynamicio-9.2.0}/dynamicio/py.typed +0 -0
  104. {dynamicio-9.1.0 → dynamicio-9.2.0}/dynamicio/validations.py +0 -0
  105. {dynamicio-9.1.0 → dynamicio-9.2.0}/mkdocs.yaml +0 -0
  106. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/__init__.py +0 -0
  107. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/conftest.py +0 -0
  108. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/constants.py +0 -0
  109. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/mocking/__init__.py +0 -0
  110. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/mocking/io.py +0 -0
  111. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/mocking/models.py +0 -0
  112. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/resources/data/external/h5_with_more_columns.h5 +0 -0
  113. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/resources/data/external/json_with_more_columns.json +0 -0
  114. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/resources/data/input/batch/hdf/part_01.h5 +0 -0
  115. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/resources/data/input/batch/hdf/part_02.h5 +0 -0
  116. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/resources/data/input/batch/not_just_hdf/part_01.h5 +0 -0
  117. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/resources/data/input/batch/not_just_hdf/part_02.h5 +0 -0
  118. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/resources/data/input/batch/not_just_hdf/something_to_ignore.txt +0 -0
  119. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/resources/data/input/batch/not_just_parquet/part_01.parquet +0 -0
  120. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/resources/data/input/batch/not_just_parquet/part_02.parquet +0 -0
  121. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/resources/data/input/batch/not_just_parquet/something_to_ignore.txt +0 -0
  122. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/resources/data/input/batch/parquet/dynamic/dir_01/part_01.parquet +0 -0
  123. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/resources/data/input/batch/parquet/dynamic/dir_01/part_02.parquet +0 -0
  124. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/resources/data/input/batch/parquet/dynamic/dir_02/part_01.parquet +0 -0
  125. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/resources/data/input/batch/parquet/dynamic/dir_02/part_02.parquet +0 -0
  126. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/resources/data/input/batch/parquet/part_01.parquet +0 -0
  127. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/resources/data/input/batch/parquet/part_02.parquet +0 -0
  128. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/resources/data/input/batch/parquet_w_empty_files/emptyfile.parquet +0 -0
  129. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/resources/data/input/batch/parquet_w_empty_files/fullfile.parquet +0 -0
  130. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/resources/data/input/multi_row_json.json +0 -0
  131. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/resources/data/input/single_row_json.json +0 -0
  132. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/resources/data/input/some_csv_to_read.csv +0 -0
  133. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/resources/data/input/some_hdf_to_read.h5 +0 -0
  134. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/resources/data/input/some_json_to_read.json +0 -0
  135. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/resources/data/input/some_parquet_to_read.parquet +0 -0
  136. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/resources/data/input/some_pg_parquet_to_read.parquet +0 -0
  137. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/resources/data/processed/.gitkeep +0 -0
  138. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/resources/data/temp/.gitkeep +0 -0
  139. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/resources/definitions/external.yaml +0 -0
  140. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/resources/definitions/input.yaml +0 -0
  141. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/resources/definitions/processed.yaml +0 -0
  142. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/resources/definitions/test_input.yaml +0 -0
  143. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/resources/schemas/bar.yaml +0 -0
  144. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/resources/schemas/foo.yaml +0 -0
  145. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/resources/schemas/pg.yaml +0 -0
  146. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/resources/schemas/read_from_s3_csv.yaml +0 -0
  147. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/resources/schemas/some_csv_to_read.yaml +0 -0
  148. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/resources/schemas/some_hdf_to_read.yaml +0 -0
  149. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/resources/schemas/some_json_to_read.yaml +0 -0
  150. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/resources/schemas/some_parquet_to_read.yaml +0 -0
  151. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/resources/schemas/some_pg_parquet_to_read.yaml +0 -0
  152. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/resources/schemas/write_to_s3_csv.yaml +0 -0
  153. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/test_cli.py +0 -0
  154. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/test_config.py +0 -0
  155. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/test_core.py +0 -0
  156. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/test_errors.py +0 -0
  157. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/test_metrics.py +0 -0
  158. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/test_mixins/__init__.py +0 -0
  159. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/test_mixins/test_athena_mixin.py +0 -0
  160. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/test_mixins/test_kafka_mixins.py +0 -0
  161. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/test_mixins/test_local_mixins.py +0 -0
  162. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/test_mixins/test_utils.py +0 -0
  163. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/test_table_schema.py +0 -0
  164. {dynamicio-9.1.0 → dynamicio-9.2.0}/tests/test_validations.py +0 -0
@@ -0,0 +1,12 @@
1
+ # Keeps the pinned GitHub Actions (commit SHAs) up to date.
2
+ # https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
3
+
4
+ version: 2
5
+ updates:
6
+ - package-ecosystem: "github-actions"
7
+ directory: "/"
8
+ schedule:
9
+ interval: "weekly"
10
+ groups:
11
+ github-actions:
12
+ patterns: ["*"]
@@ -2,7 +2,7 @@ name: Build and Publish
2
2
 
3
3
  on:
4
4
  push:
5
- branches: ["*"]
5
+ branches: ["**"]
6
6
  tags: ["v*"]
7
7
  workflow_dispatch:
8
8
 
@@ -7,7 +7,7 @@ jobs:
7
7
  title-check:
8
8
  runs-on: ubuntu-latest
9
9
  steps:
10
- - uses: naveenk1223/action-pr-title@master
10
+ - uses: naveenk1223/action-pr-title@3aa93d134e256c2f2c2cbba87567728bbbd5b405 # master as of 2026-10; unmaintained since 2020
11
11
  with:
12
12
  regex: '^((?:Revert ")*)(build|ci|docs|feat|fix|bug|perf|refactor|style|test|eda|dag|adr|chore|dev|monitor|alert)(\(RND-\d{4,5}\))?: .+$(|" \(#\d+\))'
13
13
  prefix_case_sensitive: false
@@ -49,6 +49,9 @@ Downstream pipelines upgrade by a **version bump only**, so I/O behaviour must s
49
49
  `lines=True` and `index=False`; 8.1.1 restored `lines=False` and a per-orient `index` default. Never "improve" defaults silently.
50
50
  - When changing a reader or writer, add a test that runs against a **CLOUD** resource definition with an in-memory object store
51
51
  (see `_json_object_store` in `tests/test_mixins/test_s3_mixins.py`). `ENVIRONMENT=LOCAL` tests do not exercise the S3 paths.
52
+ - A new option must be on the `utils.allow_options` list of each reader or writer that uses it. An option that is
53
+ not on the list is dropped with only a warning, so a missing entry fails silently. Add a test that the option
54
+ reaches the reader or writer through the public `IO(...)` call.
52
55
  - Add a `CHANGELOG.md` entry for every user-visible change, and update README/docs when options change.
53
56
 
54
57
  ## Testing against real AWS locally (no release needed)
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## v9.2.0
4
+
5
+ - feat: a single-file S3 parquet read with `filters` reads only the row groups whose footer statistics can match, over ranged `GetObject` requests through `pyarrow.fs.S3FileSystem` (one for each process and bucket). The rows, index and dtypes are the same as before. Reads without `filters` or with `filters=[]`, fastparquet reads, reads with a non-pyarrow `filesystem`, prefix reads and reads with wrangler-only kwargs do not change. On the ranged read, a missing key or a permission problem raises pyarrow `FileNotFoundError` or `OSError` in place of botocore `ClientError`, and a custom S3 endpoint of boto3 (`AWS_ENDPOINT_URL`) does not apply. See ADR 0004
6
+ - feat: new postgres write option `create_table` (default `False`). When `True`, the writer creates a missing table from the schema columns, with no primary key and with unbounded string columns, in the same transaction as the write. The postgres writer now lists its options (`truncate_and_append`, `create_table`), so it drops other options with a warning, as the other writers do. A `create_table` value that is not a bool (for example the YAML string `"false"`) raises `TypeError`
7
+ - fix: the cache of pyarrow S3 file systems is cleared at exit, before the pyarrow S3 finalizer runs. With pyarrow 24 and later, a process that read with `filters` on a pod with web identity credentials did not exit (https://github.com/apache/arrow/issues/50188)
8
+ - chore: dev dependency `moto[server]>=5` for the tests of the ranged read
9
+
3
10
  ## v9.1.0
4
11
 
5
12
  - chore(deps): dependency audit, ranges widened to what the code needs and CI proves. Removed packages the code never imports (`fsspec`, `libcst`, `logzero`, `no_implicit_optional`); dropped exact pins (`confluent-kafka>=2.4.0,<3`, `psycopg2-binary>=2.9.3,<3`, `python-json-logger>=2.0.1`, `simplejson>=3.17.2`); lifted the `numpy<2` ceiling (numpy 2.x passes the suite) and the `python<3.13` ceiling (3.13 and 3.14 pass; added to CI and classifiers). Raised floors so every allowed combination works with numpy 2 as well as numpy 1: `pandas>=2.2.2` (JSON writes with `index=False` for `records`/`values`, relied on since 8.1.1, need pandas 2.1, and pandas before 2.2.2 breaks with numpy 2), `pyarrow>=16.0.0`, `fastparquet>=2024.5.0`, `awswrangler>=3.9.0` (older ones cannot import against numpy 2 or pyarrow 16), `PyYAML>=6.0` (5.4.1 does not build with current toolchains). New CI job `dependency-ranges` tests the minimums (Python 3.10), the minimums with numpy 2 (Python 3.11) and the newest releases (Python 3.14); publishing waits for it
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: dynamicio
3
- Version: 9.1.0
3
+ Version: 9.2.0
4
4
  Summary: Panda's wrapper for IO operations
5
5
  Author-email: Christos Hadjinikolis <christos.hadjinikolis@gmail.com>, Radu Ghitescu <radu.ghitescu@gmail.com>
6
6
  License-Expression: Apache-2.0
@@ -2,6 +2,7 @@
2
2
 
3
3
  - Status: Accepted (branch `rnd-13624`, PR #88)
4
4
  - Date: 2026-10-08
5
+ - Amended by: [ADR 0004](0004-ranged-parquet-reads-with-filters.md) (decision 2, for reads with `filters` only)
5
6
 
6
7
  ## Context
7
8
 
@@ -0,0 +1,33 @@
1
+ # 0004. Read filtered single-file parquet over S3 byte ranges
2
+
3
+ - Status: Accepted
4
+ - Date: 2026-10-30
5
+ - Amends: decision 2 of [ADR 0001](0001-direct-boto3-s3-io.md), for reads with `filters` only
6
+
7
+ ## Context
8
+
9
+ [ADR 0001](0001-direct-boto3-s3-io.md) decision 2 reads a single parquet file with one `get_object` into memory. pandas then applies `filters` to the full object. A caller that needs a small part of a big file still downloads and decodes all of it.
10
+
11
+ A caller can need a small range of rows from a large file that is sorted on the filter column. To read less data, the caller must open the file with `pyarrow.fs.S3FileSystem` in its own code. This puts IO code outside dynamicio.
12
+
13
+ ## Decision
14
+
15
+ 1. When the caller gives non-empty `filters` for a single-file parquet read (and the engine is not fastparquet), open the object with `pyarrow.fs.S3FileSystem` and give the path and the file system to `pd.read_parquet`.
16
+ 2. pyarrow reads the footer and skips the row groups whose statistics cannot match `filters`. Then it reads only the column chunks of the remaining row groups, over ranged `GetObject` requests.
17
+ 3. Keep one `S3FileSystem` for each process and bucket, in the region of the bucket (`resolve_s3_region`). It uses the default AWS credential chain, as boto3 does.
18
+ 4. A caller `filesystem` is used for the ranged read only if it is a `pyarrow.fs.FileSystem`. With another file system (for example fsspec), the object is downloaded, as before.
19
+ 5. All other reads do not change: reads without `filters` or with `filters=[]`, fastparquet reads, prefix and directory reads, and reads with wrangler-only kwargs.
20
+
21
+ ## Consequences
22
+
23
+ - The rows, index and dtypes are the same as the `get_object` read with the same `filters`. A test compares the two reads.
24
+ - On a test file of 72 row groups, a filtered read of one key range read 936 MB of the file in 29 ranged reads. Peak memory and time were the same as a hand-written pyarrow read of the same range. With a moto server, a read of 1 of 3 row groups sent 1.9 MB of a 5.5 MB object.
25
+ - Each filtered read sends HEAD requests and a footer read before the data reads. For a read of the full file, this is more requests than one `get_object`. Callers that do not give `filters` do not pay this cost.
26
+ - A forked child makes its own file system, because the cache key has the process id. A local test read in 8 forked children after a read in the parent.
27
+ - The pyarrow S3 client is C++. The in-process moto mock does not intercept it, so the tests use a moto server.
28
+ - A file with no useful row-group statistics (for example, not sorted on the filter column) gets no gain. pyarrow then reads all row groups over ranged requests.
29
+ - Errors on the ranged read come from pyarrow: a missing key gives `FileNotFoundError` and a permission problem gives `OSError`. The download path gives botocore `ClientError`. A caller that catches `ClientError` must also catch these errors when it gives `filters`.
30
+ - The pyarrow client does not share the boto3 configuration. Shared: the default credential chain (environment, profile, SSO, instance or pod role). Not shared: a custom endpoint (`AWS_ENDPOINT_URL` or `endpoint_url` in the AWS config, for example LocalStack or MinIO), the boto3 retry and pool settings, and `botocore.config.Config`. pyarrow 25 ignores `AWS_ENDPOINT_URL`, and `resolve_s3_region` calls AWS. A caller on a non-AWS endpoint must give its own `filesystem=pyarrow.fs.S3FileSystem(endpoint_override=...)`.
31
+ - The region lookup is a network call. It runs outside the lock of the boto3 caches, so a slow lookup does not block other threads. A failed lookup raises and is not cached, so the next filtered read tries again.
32
+ - The file system cache has one entry for each bucket of the current process. It has no size bound. A process that reads many buckets keeps one C++ S3 client for each bucket. Entries of other processes are dropped on the first read after a fork.
33
+ - pyarrow 24 and later can deadlock at interpreter exit when an `S3FileSystem` is still referenced as the pyarrow S3 finalizer runs ([apache/arrow issue 50188](https://github.com/apache/arrow/issues/50188)). On a Kubernetes pod with web identity credentials, a process that read with `filters` did not exit after its work ended. dynamicio clears the file system cache in an `atexit` handler. Python runs `atexit` handlers in reverse order, and dynamicio imports `pyarrow.fs` first, so the cache is empty when the pyarrow finalizer runs. A caller that keeps its own `S3FileSystem` until exit must delete it before exit.
@@ -8,3 +8,4 @@ Number sequentially, never rewrite an accepted ADR (supersede it with a new one)
8
8
  | [0001](0001-direct-boto3-s3-io.md) | Direct boto3 for S3 I/O; drop awscli and s3fs | Accepted |
9
9
  | [0002](0002-tolerate-missing-columns-in-parquet-prefix-reads.md) | Tolerate missing columns in parquet prefix reads | Accepted |
10
10
  | [0003](0003-athena-via-aws-wrangler.md) | Read Athena through AWS Wrangler; drop PyAthena and `s3_staging_dir` | Accepted |
11
+ | [0004](0004-ranged-parquet-reads-with-filters.md) | Read filtered single-file parquet over S3 byte ranges | Accepted |
@@ -15,6 +15,10 @@ from magic_logger import logger
15
15
  def allow_options(options: Union[Iterable[str], Callable]):
16
16
  """Decorator to filter **kwargs passed to a function, allowing only valid ones.
17
17
 
18
+ Options are filtered per reader or writer: a key that is not in `options` is dropped with a warning only.
19
+ A new dynamicio option (one that the target library does not accept, e.g. `truncate_and_append`) must be
20
+ added to the list of each reader or writer that reads it, as in `[*args_of(pd.HDFStore.put), "pickle_protocol"]`.
21
+
18
22
  Args:
19
23
  options: A list of valid options or a callable that returns a list of valid options.
20
24
 
@@ -9,7 +9,7 @@ from typing import Any, Dict, Generator, MutableMapping, Union
9
9
 
10
10
  import pandas as pd
11
11
  from magic_logger import logger
12
- from sqlalchemy import BigInteger, Boolean, Column, Date, DateTime, Float, Integer, String, create_engine, text
12
+ from sqlalchemy import BigInteger, Boolean, Column, Date, DateTime, Float, Integer, MetaData, String, Table, create_engine, text
13
13
  from sqlalchemy.dialects.postgresql import JSONB
14
14
  from sqlalchemy.ext.declarative import declarative_base
15
15
  from sqlalchemy.orm import Query
@@ -76,6 +76,8 @@ class WithPostgres:
76
76
  - `truncate_and_append: bool`: If True, truncates the table with CASCADE and appends new rows (faster but destructive).
77
77
  If False (default), safely deletes all existing rows and then appends new rows.
78
78
  Use truncate only if you are certain views and FK constraints can be dropped or tolerated.
79
+ - `create_table: bool`: If True, creates the table from the schema before writing when it does not exist.
80
+ The table has no primary key, because the schema does not say which columns form it.
79
81
  """
80
82
 
81
83
  sources_config: PostgresDataEnvironment
@@ -180,11 +182,32 @@ class WithPostgres:
180
182
  assert self.sources_config.dynamicio_schema is not None, "The schema must be specified for SQL tables"
181
183
  model = self._generate_model_from_schema(self.sources_config.dynamicio_schema)
182
184
 
183
- is_truncate_and_append = self.options.get("truncate_and_append", False)
184
-
185
185
  logger.info(f"[postgres] Started uploading table: {self.sources_config.dynamicio_schema.name} from: {db_host}:{db_name}")
186
+ self._write_model(connection_string, model, df, **self.options)
187
+
188
+ @staticmethod
189
+ @utils.allow_options(["truncate_and_append", "create_table"])
190
+ def _write_model(connection_string: str, model: DeclarativeMeta, df: pd.DataFrame, truncate_and_append: bool = False, create_table: bool = False):
191
+ if not isinstance(create_table, bool):
192
+ raise TypeError(f"create_table must be a bool, got {create_table!r}")
186
193
  with session_for(connection_string) as session:
187
- self._write_to_database(session, model.__tablename__, df, is_truncate_and_append) # type: ignore
194
+ if create_table:
195
+ WithPostgres._create_table(session, model)
196
+ WithPostgres._write_to_database(session, model.__tablename__, df, truncate_and_append) # type: ignore
197
+
198
+ @staticmethod
199
+ def _create_table(session: SqlAlchemySession, model: DeclarativeMeta):
200
+ """Create the table of `model` without a primary key if it does not exist, inside the write transaction.
201
+
202
+ The generated model makes the first column a primary key, which tables holding many rows per first-column value
203
+ violate. Its string columns are `String(255)`, a limit the schema does not state, so the new table uses unbounded
204
+ strings. Each column keeps only its name and type: the table has no constraints, all columns are nullable with
205
+ no defaults, and it is created in the default schema of the connection. Postgres DDL is transactional, so a
206
+ failed write also rolls back the new table.
207
+ """
208
+ columns = [Column(column.name, String() if isinstance(column.type, String) else column.type) for column in model.__table__.columns] # type: ignore
209
+ table = Table(model.__tablename__, MetaData(), *columns) # type: ignore
210
+ table.create(session.connection(), checkfirst=True)
188
211
 
189
212
  @staticmethod
190
213
  def _write_to_database(session: SqlAlchemySession, table_name: str, df: pd.DataFrame, is_truncate_and_append: bool):
@@ -1,5 +1,6 @@
1
1
  """This module provides mixins that are providing S3 I/O support."""
2
2
 
3
+ import atexit
3
4
  import collections
4
5
  import dataclasses
5
6
  import fnmatch
@@ -20,6 +21,7 @@ import boto3
20
21
  import boto3.s3.transfer
21
22
  import pandas as pd
22
23
  import pyarrow as pa
24
+ import pyarrow.fs as pafs
23
25
  import pyarrow.parquet as pq
24
26
  import s3transfer.futures
25
27
  import tables
@@ -35,6 +37,11 @@ from dynamicio.mixins.utils import get_file_type_value
35
37
  _SESSION_LOCK = threading.Lock()
36
38
  _SESSION: Dict[int, boto3.Session] = {}
37
39
  _CLIENT: Dict[int, object] = {}
40
+ _FILESYSTEM: Dict[tuple, pafs.S3FileSystem] = {}
41
+ # pyarrow 24+ can deadlock at exit in its S3 finalizer while an S3FileSystem is still referenced, at least with web
42
+ # identity credentials (https://github.com/apache/arrow/issues/50188). atexit runs handlers in reverse order and
43
+ # `pyarrow.fs` registers its finalizer on import above, so this clear runs first.
44
+ atexit.register(_FILESYSTEM.clear)
38
45
 
39
46
 
40
47
  def _shared_boto3_session() -> boto3.Session:
@@ -156,6 +163,24 @@ def _shared_s3_client():
156
163
  return _CLIENT[pid]
157
164
 
158
165
 
166
+ def _s3_filesystem(bucket: str) -> pafs.S3FileSystem:
167
+ """Return a per-process pyarrow S3 file system in the region of `bucket` (same default credential chain as boto3).
168
+
169
+ The region lookup is a network call, so it runs outside `_SESSION_LOCK`: a slow lookup must not block the boto3
170
+ client of other threads. A failed lookup raises and caches nothing. Entries of other processes are dropped, as
171
+ the boto3 session and client caches do.
172
+ """
173
+ key = (os.getpid(), bucket)
174
+ filesystem = _FILESYSTEM.get(key)
175
+ if filesystem is not None:
176
+ return filesystem
177
+ filesystem = pafs.S3FileSystem(region=pafs.resolve_s3_region(bucket))
178
+ with _SESSION_LOCK:
179
+ for stale in [k for k in _FILESYSTEM if k[0] != key[0]]:
180
+ del _FILESYSTEM[stale]
181
+ return _FILESYSTEM.setdefault(key, filesystem)
182
+
183
+
159
184
  def _split_s3_url(url: str):
160
185
  parsed = urlparse(url)
161
186
  assert parsed.scheme == "s3", f"{url!r} should be an s3 url"
@@ -599,6 +624,12 @@ class WithS3File:
599
624
  By default the object is fetched in a single round trip over a shared boto3 client and parsed in memory with
600
625
  the same pandas/pyarrow options as local reads. If options only awswrangler understands are given (e.g.
601
626
  `s3_additional_kwargs`, `pyarrow_additional_kwargs`), awswrangler does the read instead.
627
+
628
+ With non-empty `filters`, pyarrow reads the object over S3 byte ranges: it reads the footer, skips the row groups
629
+ whose statistics cannot match, and fetches only the column chunks of the remaining ones. A caller `filesystem`
630
+ is used for this read only if it is a `pyarrow.fs.FileSystem`; with another file system (e.g. fsspec) or with
631
+ fastparquet, the object is downloaded as without `filters`. Errors on the ranged read come from pyarrow
632
+ (`FileNotFoundError`, `OSError`), not from botocore (`ClientError`).
602
633
  """
603
634
  if _WRANGLER_ONLY_READ_PARQUET & kwargs.keys():
604
635
  return WithS3File._read_s3_parquet_file_with_wrangler(s3_path, schema, **kwargs)
@@ -606,6 +637,13 @@ class WithS3File:
606
637
  # A "directory" is read as a dataset of all its objects, as pandas/pyarrow did before.
607
638
  return WithS3File._read_s3_parquet_directory(s3_path, schema, **kwargs)
608
639
  bucket, key = _split_s3_url(s3_path)
640
+ engine = kwargs.get("engine", "auto")
641
+ if engine == "auto":
642
+ engine = pd.get_option("io.parquet.engine")
643
+ filesystem = kwargs.get("filesystem")
644
+ if kwargs.get("filters") and engine != "fastparquet" and (filesystem is None or isinstance(filesystem, pafs.FileSystem)):
645
+ filesystem = filesystem or _s3_filesystem(bucket)
646
+ return with_local.WithLocal._read_parquet_file(f"{bucket}/{key}", schema, **{**kwargs, "filesystem": filesystem}) # pylint: disable=protected-access
609
647
  return with_local.WithLocal._read_parquet_file(_download_to_memory(bucket, key), schema, **kwargs) # type: ignore[arg-type] # pylint: disable=protected-access
610
648
 
611
649
  @staticmethod
@@ -45,9 +45,12 @@ dev = [
45
45
  "flake8-print",
46
46
  "flake8-tidy-imports",
47
47
  "flake8",
48
- "gitlint",
48
+ # `gitlint` itself requires `gitlint-core[trusted-deps]`, which pins `sh==1.14.3` (GHSA-q38v-wp89-2w55, fixed in 2.2.4)
49
+ "gitlint-core",
50
+ "sh>=2.2.4; sys_platform != 'win32'",
49
51
  "isort",
50
52
  "mock",
53
+ "moto[server]>=5",
51
54
  "pandas-stubs",
52
55
  "pre-commit",
53
56
  "pydocstyle",
@@ -5,6 +5,10 @@ from unittest.mock import ANY, MagicMock, patch
5
5
 
6
6
  import pandas as pd
7
7
  import pytest
8
+ from sqlalchemy import Table, create_engine, inspect, text
9
+ from sqlalchemy.dialects import postgresql
10
+ from sqlalchemy.orm import Session
11
+ from sqlalchemy.schema import CreateTable
8
12
  from sqlalchemy.sql.base import ColumnCollection
9
13
 
10
14
  # Application Imports
@@ -317,3 +321,149 @@ class TestPostgresIO:
317
321
 
318
322
  # Then
319
323
  assert is_valid is True
324
+
325
+
326
+ class TestCreateTable:
327
+ @staticmethod
328
+ def _model():
329
+ schema = types.SimpleNamespace(
330
+ name="create_if_missing_table",
331
+ columns={
332
+ "item_id": types.SimpleNamespace(name="item_id", data_type="object"),
333
+ "quantity": types.SimpleNamespace(name="quantity", data_type="int64"),
334
+ "is_active": types.SimpleNamespace(name="is_active", data_type="bool"),
335
+ },
336
+ )
337
+ return WithPostgres._generate_model_from_schema(schema)
338
+
339
+ @staticmethod
340
+ def _config():
341
+ return IOConfig(
342
+ path_to_source_yaml=(os.path.join(constants.TEST_RESOURCES, "definitions/input.yaml")),
343
+ env_identifier="CLOUD",
344
+ dynamic_vars=constants,
345
+ ).get(source_key="READ_FROM_POSTGRES")
346
+
347
+ @staticmethod
348
+ def _df():
349
+ return pd.DataFrame({"id": ["a"], "foo": ["b"], "bar": [2000], "baz": ["c"]})
350
+
351
+ @pytest.mark.unit
352
+ def test_create_table_creates_the_schema_columns_without_a_primary_key(self):
353
+ # Given
354
+ engine = create_engine("sqlite://")
355
+ session = Session(bind=engine)
356
+
357
+ # When
358
+ WithPostgres._create_table(session, self._model())
359
+ session.commit()
360
+
361
+ # Then
362
+ inspector = inspect(engine)
363
+ assert [column["name"] for column in inspector.get_columns("create_if_missing_table")] == ["item_id", "quantity", "is_active"]
364
+ assert not inspector.get_pk_constraint("create_if_missing_table")["constrained_columns"]
365
+ assert inspector.get_columns("create_if_missing_table")[0]["type"].length is None
366
+ session.execute(text("INSERT INTO create_if_missing_table VALUES ('a', 1, 1), ('a', 2, 0)")) # many rows per first column
367
+ session.commit()
368
+ session.close()
369
+
370
+ @pytest.mark.unit
371
+ def test_create_table_keeps_an_existing_table_and_its_rows(self):
372
+ # Given
373
+ engine = create_engine("sqlite://")
374
+ session = Session(bind=engine)
375
+ session.execute(text("CREATE TABLE create_if_missing_table (item_id VARCHAR, quantity BIGINT, is_active BOOLEAN, extra VARCHAR)"))
376
+ session.execute(text("INSERT INTO create_if_missing_table VALUES ('a', 1, 1, 'x')"))
377
+ session.commit()
378
+
379
+ # When
380
+ WithPostgres._create_table(session, self._model())
381
+ session.commit()
382
+
383
+ # Then
384
+ assert [column["name"] for column in inspect(engine).get_columns("create_if_missing_table")] == ["item_id", "quantity", "is_active", "extra"]
385
+ assert session.execute(text("SELECT count(*) FROM create_if_missing_table")).scalar() == 1
386
+ session.close()
387
+
388
+ @pytest.mark.unit
389
+ def test_create_table_renders_postgres_ddl_without_a_primary_key_and_with_jsonb(self):
390
+ # Given
391
+ schema = types.SimpleNamespace(
392
+ name="create_table_ddl",
393
+ columns={
394
+ "item_id": types.SimpleNamespace(name="item_id", data_type="object"),
395
+ "payload": types.SimpleNamespace(name="payload", data_type="json"),
396
+ },
397
+ )
398
+
399
+ # When
400
+ with patch.object(Table, "create", autospec=True) as mock_create:
401
+ WithPostgres._create_table(MagicMock(), WithPostgres._generate_model_from_schema(schema))
402
+
403
+ # Then
404
+ ddl = str(CreateTable(mock_create.call_args.args[0]).compile(dialect=postgresql.dialect()))
405
+ assert " ".join(ddl.split()) == "CREATE TABLE create_table_ddl ( item_id VARCHAR, payload JSONB )"
406
+ assert mock_create.call_args.kwargs == {"checkfirst": True}
407
+
408
+ @pytest.mark.unit
409
+ def test_write_creates_the_missing_table_before_writing_when_the_option_is_set(self):
410
+ # Given
411
+ calls = MagicMock()
412
+
413
+ # When
414
+ with (
415
+ patch("dynamicio.mixins.with_postgres.session_for") as mock_session_for,
416
+ patch.object(WithPostgres, "_create_table", calls.create),
417
+ patch.object(WithPostgres, "_write_to_database", calls.write),
418
+ ):
419
+ WritePostgresIO(source_config=self._config(), create_table=True).write(self._df())
420
+
421
+ # Then
422
+ session = mock_session_for.return_value.__enter__.return_value
423
+ assert [name for name, _, _ in calls.mock_calls] == ["create", "write"]
424
+ assert calls.create.call_args.args[0] is session
425
+ assert calls.create.call_args.args[1].__tablename__ == calls.write.call_args.args[1]
426
+
427
+ @pytest.mark.unit
428
+ def test_write_drops_options_that_the_postgres_writer_does_not_list(self):
429
+ # When
430
+ with (
431
+ patch("dynamicio.mixins.with_postgres.session_for"),
432
+ patch.object(WithPostgres, "_create_table") as mock_create,
433
+ patch.object(WithPostgres, "_write_to_database") as mock_write,
434
+ patch("dynamicio.mixins.utils.logger") as mock_logger,
435
+ ):
436
+ WritePostgresIO(source_config=self._config(), truncate_and_append=True, unknown_option=1).write(self._df())
437
+
438
+ # Then
439
+ mock_create.assert_not_called()
440
+ assert mock_write.call_args.args[3] is True
441
+ assert "unknown_option" in mock_logger.warning.call_args.args[0]
442
+
443
+ @pytest.mark.unit
444
+ @pytest.mark.parametrize("options", [{}, {"create_table": False}])
445
+ def test_write_does_not_create_tables_without_the_option(self, options):
446
+ # When
447
+ with (
448
+ patch("dynamicio.mixins.with_postgres.session_for"),
449
+ patch.object(WithPostgres, "_create_table") as mock_create,
450
+ patch.object(WithPostgres, "_write_to_database") as mock_write,
451
+ ):
452
+ WritePostgresIO(source_config=self._config(), **options).write(self._df())
453
+
454
+ # Then
455
+ mock_create.assert_not_called()
456
+ mock_write.assert_called_once()
457
+
458
+ @pytest.mark.unit
459
+ @pytest.mark.parametrize("value", ["false", "true", 1, None])
460
+ def test_write_rejects_a_create_table_value_that_is_not_a_bool(self, value):
461
+ # When / Then
462
+ with (
463
+ patch("dynamicio.mixins.with_postgres.session_for") as mock_session,
464
+ patch.object(WithPostgres, "_create_table") as mock_create,
465
+ pytest.raises(TypeError, match="create_table must be a bool"),
466
+ ):
467
+ WritePostgresIO(source_config=self._config(), create_table=value).write(self._df())
468
+ mock_session.assert_not_called()
469
+ mock_create.assert_not_called()