xarray-sql 0.0.2__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 (52) hide show
  1. xarray_sql-0.0.2/.github/workflows/ci.yml +60 -0
  2. xarray_sql-0.0.2/.github/workflows/lint.yml +52 -0
  3. xarray_sql-0.0.2/.github/workflows/publish.yml +97 -0
  4. xarray_sql-0.0.2/.gitignore +6 -0
  5. xarray_sql-0.0.2/CONTRIBUTING.md +22 -0
  6. xarray_sql-0.0.2/LICENSE +202 -0
  7. xarray_sql-0.0.2/PKG-INFO +173 -0
  8. xarray_sql-0.0.2/README.md +136 -0
  9. xarray_sql-0.0.2/perf_tests/README.md +19 -0
  10. xarray_sql-0.0.2/perf_tests/compute_air.py +13 -0
  11. xarray_sql-0.0.2/perf_tests/compute_air.py-2024-02-26T22:57:59+07:00.svg +415 -0
  12. xarray_sql-0.0.2/perf_tests/compute_air.py-2024-03-03T07:42:36+05:30.svg +415 -0
  13. xarray_sql-0.0.2/perf_tests/compute_air.py-2024-03-03T07:50:18+05:30.svg +415 -0
  14. xarray_sql-0.0.2/perf_tests/groupby_air.py +36 -0
  15. xarray_sql-0.0.2/perf_tests/groupby_air.py-2024-02-15T13:01:22+07:00.svg +415 -0
  16. xarray_sql-0.0.2/perf_tests/groupby_air.py-2024-02-15T15:03:53+07:00.svg +415 -0
  17. xarray_sql-0.0.2/perf_tests/groupby_air.py-2024-02-17T18:42:14+07:00.svg +415 -0
  18. xarray_sql-0.0.2/perf_tests/groupby_air.py-2024-02-26T23:04:34+07:00.svg +415 -0
  19. xarray_sql-0.0.2/perf_tests/groupby_air.py-2024-03-03T07:43:22+05:30.svg +415 -0
  20. xarray_sql-0.0.2/perf_tests/groupby_air.py-2024-03-03T07:50:06+05:30.svg +415 -0
  21. xarray_sql-0.0.2/perf_tests/groupby_air_full.py +33 -0
  22. xarray_sql-0.0.2/perf_tests/groupby_air_full.py-2024-02-26T23:06:38+07:00.svg +415 -0
  23. xarray_sql-0.0.2/perf_tests/groupby_air_full.py-2024-03-03T07:44:17+05:30.svg +415 -0
  24. xarray_sql-0.0.2/perf_tests/groupby_air_full.py-2024-03-03T07:49:53+05:30.svg +415 -0
  25. xarray_sql-0.0.2/perf_tests/open_era5.py +15 -0
  26. xarray_sql-0.0.2/perf_tests/open_era5.py-2024-02-18T17:21:44+07:00.svg +415 -0
  27. xarray_sql-0.0.2/perf_tests/open_era5.py-2024-02-18T17:33:02+07:00.svg +415 -0
  28. xarray_sql-0.0.2/perf_tests/open_era5.py-2024-02-19T17:52:51+07:00.svg +415 -0
  29. xarray_sql-0.0.2/perf_tests/profile.sh +2 -0
  30. xarray_sql-0.0.2/perf_tests/sanity.py +16 -0
  31. xarray_sql-0.0.2/perf_tests/sanity.py-2024-02-15T09:08:28+07:00.svg +415 -0
  32. xarray_sql-0.0.2/perf_tests/sanity.py-2024-02-15T09:15:07+07:00.svg +415 -0
  33. xarray_sql-0.0.2/perf_tests/sanity.py-2024-02-15T12:51:37+07:00.svg +415 -0
  34. xarray_sql-0.0.2/perf_tests/sanity.py-2024-02-15T15:04:48+07:00.svg +415 -0
  35. xarray_sql-0.0.2/perf_tests/sanity.py-2024-02-17T18:42:08+07:00.svg +415 -0
  36. xarray_sql-0.0.2/perf_tests/sanity.py-2024-02-26T23:00:00+07:00.svg +415 -0
  37. xarray_sql-0.0.2/perf_tests/sanity.py-2024-03-03T07:45:47+05:30.svg +415 -0
  38. xarray_sql-0.0.2/perf_tests/sanity.py-2024-03-03T07:49:44+05:30.svg +415 -0
  39. xarray_sql-0.0.2/pyproject.toml +62 -0
  40. xarray_sql-0.0.2/setup.cfg +4 -0
  41. xarray_sql-0.0.2/xarray_sql/__init__.py +2 -0
  42. xarray_sql-0.0.2/xarray_sql/core.py +47 -0
  43. xarray_sql-0.0.2/xarray_sql/df.py +115 -0
  44. xarray_sql-0.0.2/xarray_sql/df_integrationtest.py +29 -0
  45. xarray_sql-0.0.2/xarray_sql/df_test.py +89 -0
  46. xarray_sql-0.0.2/xarray_sql/sql.py +20 -0
  47. xarray_sql-0.0.2/xarray_sql/sql_test.py +60 -0
  48. xarray_sql-0.0.2/xarray_sql.egg-info/PKG-INFO +173 -0
  49. xarray_sql-0.0.2/xarray_sql.egg-info/SOURCES.txt +50 -0
  50. xarray_sql-0.0.2/xarray_sql.egg-info/dependency_links.txt +1 -0
  51. xarray_sql-0.0.2/xarray_sql.egg-info/requires.txt +12 -0
  52. xarray_sql-0.0.2/xarray_sql.egg-info/top_level.txt +2 -0
@@ -0,0 +1,60 @@
1
+ # Taken from Xee and minimally modified: https://github.com/google/Xee/blob/main/.github/workflows/ci-build.yml
2
+ #
3
+ # Copyright 2023 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ # ==============================================================================
17
+ name: ci
18
+
19
+ on:
20
+ # Triggers the workflow on push or pull request events but only for the main branch
21
+ push:
22
+ branches: [ main ]
23
+ pull_request:
24
+ branches: [ main ]
25
+ # Allows you to run this workflow manually from the Actions tab
26
+ workflow_dispatch:
27
+
28
+ jobs:
29
+ build:
30
+ name: "python ${{ matrix.python-version }} tests"
31
+ runs-on: ubuntu-latest
32
+ strategy:
33
+ fail-fast: false
34
+ matrix:
35
+ python-version: [
36
+ "3.8",
37
+ "3.9",
38
+ "3.10",
39
+ "3.11",
40
+ "3.12",
41
+ ]
42
+ steps:
43
+ - name: Cancel previous
44
+ uses: styfle/cancel-workflow-action@0.7.0
45
+ with:
46
+ access_token: ${{ github.token }}
47
+ if: ${{github.ref != 'refs/head/main'}}
48
+ - uses: actions/checkout@v2
49
+ - name: Set up Python ${{ matrix.python-version }}
50
+ uses: actions/setup-python@v4
51
+ with:
52
+ python-version: ${{ matrix.python-version }}
53
+ cache: 'pip'
54
+ - name: Install xarray_sql
55
+ run: |
56
+ pip install -e .[test]
57
+ - uses: 'actions/checkout@v4'
58
+ - name: Run unit tests
59
+ run: |
60
+ pytest xarray_sql
@@ -0,0 +1,52 @@
1
+ # Taken from Xee and minimally modified: https://github.com/google/Xee/blob/main/.github/workflows/lint.yml
2
+ #
3
+ # Copyright 2023 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ # ==============================================================================
17
+ name: lint
18
+
19
+ on:
20
+ # Triggers the workflow on push or pull request events but only for the main branch
21
+ push:
22
+ branches: [ main ]
23
+ pull_request:
24
+ branches: [ main ]
25
+ # Allows you to run this workflow manually from the Actions tab
26
+ workflow_dispatch:
27
+
28
+ jobs:
29
+ build:
30
+ name: "python ${{ matrix.python-version }} lint"
31
+ runs-on: ubuntu-latest
32
+ strategy:
33
+ fail-fast: false
34
+ matrix:
35
+ python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
36
+ steps:
37
+ - name: Cancel previous
38
+ uses: styfle/cancel-workflow-action@0.7.0
39
+ with:
40
+ access_token: ${{ github.token }}
41
+ if: ${{github.ref != 'refs/head/main'}}
42
+ - uses: actions/checkout@v2
43
+ - name: Set up Python ${{ matrix.python-version }}
44
+ uses: actions/setup-python@v2
45
+ with:
46
+ python-version: ${{ matrix.python-version }}
47
+ - name: Install linter
48
+ run: |
49
+ pip install pyink
50
+ - name: Lint with pyink
51
+ run: |
52
+ pyink --check .
@@ -0,0 +1,97 @@
1
+ # Taken from Xee and minimally modified: https://github.com/google/Xee/blob/main/.github/workflows/publish.yml
2
+ #
3
+ # Copyright 2023 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ name: Publish to PyPi
17
+
18
+ on:
19
+ release:
20
+ types: [published]
21
+
22
+ jobs:
23
+ build-artifacts:
24
+ runs-on: ubuntu-latest
25
+ steps:
26
+ - uses: actions/checkout@v2
27
+ - name: Set up Python
28
+ uses: actions/setup-python@v2.3.1
29
+ with:
30
+ python-version: 3.9
31
+
32
+ - name: Install dependencies
33
+ run: |
34
+ python -m pip install --upgrade pip
35
+ python -m pip install setuptools setuptools-scm wheel twine check-manifest
36
+
37
+ - name: Build tarball and wheels
38
+ run: |
39
+ git clean -xdf
40
+ git restore -SW .
41
+ python -m build --sdist --wheel .
42
+ - name: Check built artifacts
43
+ run: |
44
+ python -m twine check dist/*
45
+ pwd
46
+ - uses: actions/upload-artifact@v2
47
+ with:
48
+ name: releases
49
+ path: dist
50
+
51
+ test-built-dist:
52
+ needs: build-artifacts
53
+ runs-on: ubuntu-latest
54
+ steps:
55
+ - uses: actions/setup-python@v2.3.1
56
+ name: Install Python
57
+ with:
58
+ python-version: 3.9
59
+ - uses: actions/download-artifact@v2
60
+ with:
61
+ name: releases
62
+ path: dist
63
+ - name: List contents of built dist
64
+ run: |
65
+ ls -ltrh
66
+ ls -ltrh dist
67
+ - name: Publish package to TestPyPI
68
+ if: github.event_name == 'push'
69
+ uses: pypa/gh-action-pypi-publish@v1.4.2
70
+ with:
71
+ user: __token__
72
+ password: ${{ secrets.TESTPYPI_TOKEN }}
73
+ repository_url: https://test.pypi.org/legacy/
74
+ verbose: true
75
+
76
+ - name: Check uploaded package
77
+ if: github.event_name == 'push'
78
+ run: |
79
+ sleep 3
80
+ python -m pip install --upgrade pip
81
+ python -m pip install --extra-index-url https://test.pypi.org/simple --upgrade de
82
+ python -c "import qarray; print(qarray.__version__)"
83
+ upload-to-pypi:
84
+ needs: test-built-dist
85
+ if: github.event_name == 'release'
86
+ runs-on: ubuntu-latest
87
+ steps:
88
+ - uses: actions/download-artifact@v2
89
+ with:
90
+ name: releases
91
+ path: dist
92
+ - name: Publish package to PyPI
93
+ uses: pypa/gh-action-pypi-publish@v1.4.2
94
+ with:
95
+ user: __token__
96
+ password: ${{ secrets.PYPI_TOKEN }}
97
+ verbose: true
@@ -0,0 +1,6 @@
1
+ *.egg-info
2
+ .DS_Store
3
+ build
4
+ dist
5
+ __pycache__
6
+ .pytest_cache
@@ -0,0 +1,22 @@
1
+ # Contributing Guide
2
+
3
+ ## Where to start?
4
+
5
+ Please check out the [issues tab](https://github.com/alxmrs/qarray/issues).
6
+ Let's have a discussion over there before proceeding with any changes. Great
7
+ minds think alike -- someone may have already created an issue related to your
8
+ inquiry. If there's a bug, please let us know.
9
+
10
+ If you're totally new to open source development, I recommend
11
+ reading [Xarray's contributing guide](https://docs.xarray.dev/en/stable/contributing.html)
12
+ .
13
+
14
+ ## Developer setup
15
+
16
+ 0. (Recommended) Create a project-specific python
17
+ environment. [(mini)Conda](https://docs.anaconda.com/free/miniconda/index.html)
18
+ or [Mamba](https://mamba.readthedocs.io/en/latest/)
19
+ is preferred.
20
+ 1. Clone the repository (bonus: [via SSH](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account))
21
+ and `cd xarray_sql` (the project root).
22
+ 1. Install dev dependencies via: `pip install -e ".[dev]`
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,173 @@
1
+ Metadata-Version: 2.1
2
+ Name: xarray_sql
3
+ Version: 0.0.2
4
+ Summary: Querry Xarray with SQL.
5
+ Author-email: Alexander Merose <al@merose.com>
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/alxmrs/xarray-sql
8
+ Project-URL: Issues, https://github.com/alxmrs/xarray-sql/issues
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Intended Audience :: Science/Research
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Intended Audience :: Information Technology
13
+ Classifier: License :: OSI Approved :: Apache Software License
14
+ Classifier: Operating System :: MacOS :: MacOS X
15
+ Classifier: Operating System :: Microsoft :: Windows
16
+ Classifier: Operating System :: POSIX
17
+ Classifier: Programming Language :: Python :: 3.8
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Topic :: Scientific/Engineering :: Atmospheric Science
23
+ Classifier: Topic :: Database :: Front-Ends
24
+ Requires-Python: >=3.8
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Requires-Dist: xarray
28
+ Requires-Dist: dask-sql
29
+ Provides-Extra: test
30
+ Requires-Dist: pytest; extra == "test"
31
+ Requires-Dist: xarray[io]; extra == "test"
32
+ Requires-Dist: gcsfs; extra == "test"
33
+ Provides-Extra: dev
34
+ Requires-Dist: xarray_sql[test]; extra == "dev"
35
+ Requires-Dist: pyink; extra == "dev"
36
+ Requires-Dist: py-spy; extra == "dev"
37
+
38
+ # xarray-sql
39
+
40
+ _Query Xarray with SQL_
41
+
42
+ [![ci](https://github.com/alxmrs/xarray-sql/actions/workflows/ci.yml/badge.svg)](https://github.com/alxmrs/xarray-sql/actions/workflows/ci.yml)
43
+ [![lint](https://github.com/alxmrs/xarray-sql/actions/workflows/lint.yml/badge.svg)](https://github.com/alxmrs/xarray-sql/actions/workflows/lint.yml)
44
+
45
+
46
+ ## What is this?
47
+
48
+ This is an experiment to provide a SQL interface for raster data.
49
+
50
+ ```python
51
+ import xarray as xr
52
+ import xarray_sql as qr
53
+
54
+ ds = xr.tutorial.open_dataset('air_temperature')
55
+
56
+ # The same as a dask-sql Context; i.e. an Apache DataFusion Context.
57
+ c = qr.Context(ds)
58
+ c.create_table('air', ds, chunks=dict(time=24))
59
+
60
+ df = c.sql('''
61
+ SELECT
62
+ "lat", "lon", AVG("air") as air_total
63
+ FROM
64
+ "air"
65
+ GROUP BY
66
+ "lat", "lon"
67
+ ''')
68
+
69
+ # A table of the average temperature for each location across time.
70
+ df.compute()
71
+
72
+ # Alternatively, you can just create the DataFrame from the Dataset:
73
+ df = qr.read_xarray(ds)
74
+ df.head()
75
+ ```
76
+
77
+ Succinctly, we "pivot" Xarray Datasets to treat them like tables so we can run
78
+ SQL queries against them.
79
+
80
+ ## Why build this?
81
+
82
+ A few reasons:
83
+
84
+ * Even though SQL is the lingua franca of data, scientific datasets are often
85
+ inaccessible to non-scientists.
86
+ * Joining tabular data with raster data is common yet difficult. It could be
87
+ easy.
88
+ * There are many cloud-native, Xarray-openable datasets,
89
+ from [Google Earth Engine](https://github.com/google/Xee)
90
+ to [Pangeo Forge](https://pangeo-forge.org/). Wouldn’t it be great if these
91
+ were also SQL-accessible? How can the bridge be built with minimal effort?
92
+
93
+ This is a light-weight way to prove the value of the interface.
94
+
95
+ The larger goal is to explore the hypothesis that [Pangeo](https://pangeo.io/)
96
+ is a scientific database. Here, xarray-sql can be thought of as a missing DB
97
+ front end.
98
+
99
+ ## How does it work?
100
+
101
+ All chunks in an Xarray Dataset are transformed into a Dask DataFrame via
102
+ `from_map()` and `to_dataframe()`. For SQL support, we just use `dask-sql`.
103
+ That's it!
104
+
105
+ ## Why does this work?
106
+
107
+ Underneath Xarray, Dask, and Pandas, there are NumPy arrays. These are paged in
108
+ chucks and represented contiguously in memory. It is only a matter of metadata
109
+ that breaks them up into ndarrays. `to_dataframe()`
110
+ just changes this metadata (via a `ravel()`/`reshape()`), back into a column
111
+ amenable to a DataFrame.
112
+
113
+ There is added overhead from duplicating dimensions as columns, which we see as
114
+ worth the convenience of DataFrames.
115
+
116
+ ## What are the current limitations?
117
+
118
+ Dask doesn't support
119
+ `MultiIndex`s ([dask/dask#1493](https://github.com/dask/dask/issues/1493)). If
120
+ it did, I suspect performance for many types of queries would greatly improve.
121
+
122
+ Further, while this does play well with `dask-geopandas` (for geospatial query
123
+ support), certain types of operations don't quite match standard geopandas.
124
+ Spatial joins come to mind as a killer feature, but only inner joins are
125
+ supported ([geopandas/dask-geopandas#72](https://github.com/geopandas/dask-geopandas/issues/72))
126
+ .
127
+
128
+ ## What would a deeper integration look like?
129
+
130
+ I have a few ideas so far. One approach involves applying operations directly on
131
+ Xarray Datasets. This approach is being pursued
132
+ [here](https://github.com/google/weather-tools/tree/main/xql), as `xql`.
133
+
134
+ Deeper still: I was thinking we could make
135
+ a [virtual](https://fsspec.github.io/kerchunk/)
136
+ filesystem for parquet that would internally map to Zarr. Raster-backed virtual
137
+ parquet would open up integrations to numeroustools like dask, pyarrow, duckdb,
138
+ and BigQuery. More thoughts on this
139
+ in [#4](https://github.com/alxmrs/xarray-sql/issues/4).
140
+
141
+ ## Sponsors & Contributors
142
+
143
+ I want to give a special thanks to the following folks and institutions:
144
+
145
+ - Pramod Gupta and the Anthromet Team at Google Research for the problem
146
+ formation and design inspiration.
147
+ - Jake Wall and AI2/Ecoscope for compute resources and key use cases.
148
+ - Charles Stern, Stephan Hoyer, and Qiusheng Wu for the early review and
149
+ discussion of this project.
150
+
151
+ ## License
152
+
153
+ ```
154
+ Copyright 2024 Alexander Merose
155
+
156
+ Licensed under the Apache License, Version 2.0 (the "License");
157
+ you may not use this file except in compliance with the License.
158
+ You may obtain a copy of the License at
159
+
160
+ https://www.apache.org/licenses/LICENSE-2.0
161
+
162
+ Unless required by applicable law or agreed to in writing, software
163
+ distributed under the License is distributed on an "AS IS" BASIS,
164
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
165
+ See the License for the specific language governing permissions and
166
+ limitations under the License.
167
+ ```
168
+
169
+ Some sources are re-distributed from Google LLC
170
+ via https://github.com/google/Xee (also Apache-2.0 License) with and without
171
+ modification (specifically, Github Actions workflows). These files are subject
172
+ to the original copyright; they include the original license header comment as
173
+ well as a note to indicate modifications (when appropriate).