snowpark-checkpoints-collectors 0.1.0rc2__py3-none-any.whl → 0.1.1__py3-none-any.whl

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 (39) hide show
  1. snowflake/snowpark_checkpoints_collector/__init__.py +22 -0
  2. snowflake/snowpark_checkpoints_collector/collection_common.py +160 -0
  3. snowflake/snowpark_checkpoints_collector/collection_result/model/__init__.py +24 -0
  4. snowflake/snowpark_checkpoints_collector/collection_result/model/collection_point_result.py +91 -0
  5. snowflake/snowpark_checkpoints_collector/collection_result/model/collection_point_result_manager.py +69 -0
  6. snowflake/snowpark_checkpoints_collector/column_collection/__init__.py +22 -0
  7. snowflake/snowpark_checkpoints_collector/column_collection/column_collector_manager.py +253 -0
  8. snowflake/snowpark_checkpoints_collector/column_collection/model/__init__.py +75 -0
  9. snowflake/snowpark_checkpoints_collector/column_collection/model/array_column_collector.py +113 -0
  10. snowflake/snowpark_checkpoints_collector/column_collection/model/binary_column_collector.py +87 -0
  11. snowflake/snowpark_checkpoints_collector/column_collection/model/boolean_column_collector.py +71 -0
  12. snowflake/snowpark_checkpoints_collector/column_collection/model/column_collector_base.py +95 -0
  13. snowflake/snowpark_checkpoints_collector/column_collection/model/date_column_collector.py +74 -0
  14. snowflake/snowpark_checkpoints_collector/column_collection/model/day_time_interval_column_collector.py +67 -0
  15. snowflake/snowpark_checkpoints_collector/column_collection/model/decimal_column_collector.py +92 -0
  16. snowflake/snowpark_checkpoints_collector/column_collection/model/empty_column_collector.py +88 -0
  17. snowflake/snowpark_checkpoints_collector/column_collection/model/map_column_collector.py +120 -0
  18. snowflake/snowpark_checkpoints_collector/column_collection/model/null_column_collector.py +49 -0
  19. snowflake/snowpark_checkpoints_collector/column_collection/model/numeric_column_collector.py +108 -0
  20. snowflake/snowpark_checkpoints_collector/column_collection/model/string_column_collector.py +70 -0
  21. snowflake/snowpark_checkpoints_collector/column_collection/model/struct_column_collector.py +102 -0
  22. snowflake/snowpark_checkpoints_collector/column_collection/model/timestamp_column_collector.py +75 -0
  23. snowflake/snowpark_checkpoints_collector/column_collection/model/timestamp_ntz_column_collector.py +75 -0
  24. snowflake/snowpark_checkpoints_collector/column_pandera_checks/__init__.py +20 -0
  25. snowflake/snowpark_checkpoints_collector/column_pandera_checks/pandera_column_checks_manager.py +223 -0
  26. snowflake/snowpark_checkpoints_collector/singleton.py +23 -0
  27. snowflake/snowpark_checkpoints_collector/snow_connection_model/__init__.py +20 -0
  28. snowflake/snowpark_checkpoints_collector/snow_connection_model/snow_connection.py +172 -0
  29. snowflake/snowpark_checkpoints_collector/summary_stats_collector.py +366 -0
  30. snowflake/snowpark_checkpoints_collector/utils/checkpoint_name_utils.py +53 -0
  31. snowflake/snowpark_checkpoints_collector/utils/extra_config.py +112 -0
  32. snowflake/snowpark_checkpoints_collector/utils/file_utils.py +132 -0
  33. snowflake/snowpark_checkpoints_collector/utils/telemetry.py +889 -0
  34. snowpark_checkpoints_collectors-0.1.1.dist-info/METADATA +143 -0
  35. snowpark_checkpoints_collectors-0.1.1.dist-info/RECORD +37 -0
  36. {snowpark_checkpoints_collectors-0.1.0rc2.dist-info → snowpark_checkpoints_collectors-0.1.1.dist-info}/licenses/LICENSE +0 -25
  37. snowpark_checkpoints_collectors-0.1.0rc2.dist-info/METADATA +0 -347
  38. snowpark_checkpoints_collectors-0.1.0rc2.dist-info/RECORD +0 -4
  39. {snowpark_checkpoints_collectors-0.1.0rc2.dist-info → snowpark_checkpoints_collectors-0.1.1.dist-info}/WHEEL +0 -0
@@ -0,0 +1,143 @@
1
+ Metadata-Version: 2.4
2
+ Name: snowpark-checkpoints-collectors
3
+ Version: 0.1.1
4
+ Summary: Snowpark column and table statistics collection
5
+ Project-URL: Bug Tracker, https://github.com/snowflakedb/snowpark-checkpoints/issues
6
+ Project-URL: Source code, https://github.com/snowflakedb/snowpark-checkpoints/
7
+ Author-email: "Snowflake, Inc." <snowflake-python-libraries-dl@snowflake.com>
8
+ License: Apache License, Version 2.0
9
+ License-File: LICENSE
10
+ Keywords: Snowflake,Snowpark,analytics,cloud,database,db
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Environment :: Console
13
+ Classifier: Environment :: Other Environment
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: Education
16
+ Classifier: Intended Audience :: Information Technology
17
+ Classifier: Intended Audience :: System Administrators
18
+ Classifier: License :: OSI Approved :: Apache Software License
19
+ Classifier: Operating System :: OS Independent
20
+ Classifier: Programming Language :: Python :: 3 :: Only
21
+ Classifier: Programming Language :: SQL
22
+ Classifier: Topic :: Database
23
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
24
+ Classifier: Topic :: Software Development
25
+ Classifier: Topic :: Software Development :: Libraries
26
+ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
27
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
28
+ Requires-Python: <3.12,>=3.9
29
+ Requires-Dist: pandera[io]==0.20.4
30
+ Requires-Dist: pyspark
31
+ Requires-Dist: snowflake-connector-python==3.13.0
32
+ Requires-Dist: snowflake-snowpark-python==1.26.0
33
+ Provides-Extra: development
34
+ Requires-Dist: coverage>=7.6.7; extra == 'development'
35
+ Requires-Dist: deepdiff>=8.0.0; extra == 'development'
36
+ Requires-Dist: hatchling==1.25.0; extra == 'development'
37
+ Requires-Dist: pre-commit>=4.0.1; extra == 'development'
38
+ Requires-Dist: pyarrow>=18.0.0; extra == 'development'
39
+ Requires-Dist: pytest-cov>=6.0.0; extra == 'development'
40
+ Requires-Dist: pytest>=8.3.3; extra == 'development'
41
+ Requires-Dist: setuptools>=70.0.0; extra == 'development'
42
+ Requires-Dist: twine==5.1.1; extra == 'development'
43
+ Description-Content-Type: text/markdown
44
+
45
+ # snowpark-checkpoints-collectors
46
+
47
+ ---
48
+ **NOTE**
49
+ This package is on Public Preview.
50
+ ---
51
+ **snowpark-checkpoints-collector** package offers a function for extracting information from PySpark dataframes. We can then use that data to validate against the converted Snowpark dataframes to ensure that behavioral equivalence has been achieved.
52
+ ## Features
53
+
54
+ - Schema inference collected data mode (Schema): This is the default mode, which leverages Pandera schema inference to obtain the metadata and checks that will be evaluated for the specified dataframe. This mode also collects custom data from columns of the DataFrame based on the PySpark type.
55
+ - DataFrame collected data mode (DataFrame): This mode collects the data of the PySpark dataframe. In this case, the mechanism saves all data of the given dataframe in parquet format. Using the default user Snowflake connection, it tries to upload the parquet files into the Snowflake temporal stage and create a table based on the information in the stage. The name of the file and the table is the same as the checkpoint.
56
+
57
+
58
+
59
+ ## Functionalities
60
+
61
+ ### Collect DataFrame Checkpoint
62
+
63
+
64
+
65
+ ```python
66
+ from pyspark.sql import DataFrame as SparkDataFrame
67
+ from snowflake.snowpark_checkpoints_collector.collection_common import CheckpointMode
68
+ from typing import Optional
69
+
70
+ # Signature of the function
71
+ def collect_dataframe_checkpoint(
72
+ df: SparkDataFrame,
73
+ checkpoint_name: str,
74
+ sample: Optional[float] = None,
75
+ mode: Optional[CheckpointMode] = None,
76
+ output_path: Optional[str] = None,
77
+ ) -> None:
78
+ ...
79
+ ```
80
+
81
+ - `df`: The input Spark dataframe to collect.
82
+ - `checkpoint_name`: Name of the checkpoint schema file or dataframe.
83
+ - `sample`: Fraction of DataFrame to sample for schema inference, defaults to 1.0.
84
+ - `mode`: The mode to execution the collection (Schema or Dataframe), defaults to CheckpointMode.Schema.
85
+ - `output_path`: The output path to save the checkpoint, defaults to current working directory.
86
+
87
+
88
+ ## Usage Example
89
+
90
+ ### Schema mode
91
+
92
+ ```python
93
+ from pyspark.sql import SparkSession
94
+ from snowflake.snowpark_checkpoints_collector import collect_dataframe_checkpoint
95
+ from snowflake.snowpark_checkpoints_collector.collection_common import CheckpointMode
96
+
97
+ spark_session = SparkSession.builder.getOrCreate()
98
+ sample_size = 1.0
99
+
100
+ pyspark_df = spark_session.createDataFrame(
101
+ [("apple", 21), ("lemon", 34), ("banana", 50)], schema="fruit string, age integer"
102
+ )
103
+
104
+ collect_dataframe_checkpoint(
105
+ pyspark_df,
106
+ checkpoint_name="collect_checkpoint_mode_1",
107
+ sample=sample_size,
108
+ mode=CheckpointMode.SCHEMA,
109
+ )
110
+ ```
111
+
112
+
113
+ ### Dataframe mode
114
+
115
+ ```python
116
+ from pyspark.sql import SparkSession
117
+ from snowflake.snowpark_checkpoints_collector import collect_dataframe_checkpoint
118
+ from snowflake.snowpark_checkpoints_collector.collection_common import CheckpointMode
119
+ from pyspark.sql.types import StructType, StructField, ByteType, StringType, IntegerType
120
+
121
+ spark_schema = StructType(
122
+ [
123
+ StructField("BYTE", ByteType(), True),
124
+ StructField("STRING", StringType(), True),
125
+ StructField("INTEGER", IntegerType(), True)
126
+ ]
127
+ )
128
+
129
+ data = [(1, "apple", 21), (2, "lemon", 34), (3, "banana", 50)]
130
+
131
+ spark_session = SparkSession.builder.getOrCreate()
132
+ pyspark_df = spark_session.createDataFrame(data, schema=spark_schema).orderBy(
133
+ "INTEGER"
134
+ )
135
+
136
+ collect_dataframe_checkpoint(
137
+ pyspark_df,
138
+ checkpoint_name="collect_checkpoint_mode_2",
139
+ mode=CheckpointMode.DATAFRAME,
140
+ )
141
+ ```
142
+
143
+ ------
@@ -0,0 +1,37 @@
1
+ snowflake/snowpark_checkpoints_collector/__init__.py,sha256=yf_DmREHUwtC8y_boY8iaQC3qaKi1miEb5kytllrAaw,874
2
+ snowflake/snowpark_checkpoints_collector/collection_common.py,sha256=ff5vYffrTRjoJXZQvVQBaOlegAUj_vXBbl1IZidz8Qo,4510
3
+ snowflake/snowpark_checkpoints_collector/singleton.py,sha256=7AgIHQBXVRvPBBCkmBplzkdrrm-xVWf_N8svzA2vF8E,836
4
+ snowflake/snowpark_checkpoints_collector/summary_stats_collector.py,sha256=cvG1C9rLyF4w3Fybr3o_cno6mEHbXsbU17D_y2RrNck,12823
5
+ snowflake/snowpark_checkpoints_collector/collection_result/model/__init__.py,sha256=jZzx29WzrjH7C_6ZsBGoe4PxbW_oM4uIjySS1axIM34,1000
6
+ snowflake/snowpark_checkpoints_collector/collection_result/model/collection_point_result.py,sha256=8xD9zGnFJ7Rz9RUXIys7JnV3kQD4mk8QwNOTxAihSjQ,2908
7
+ snowflake/snowpark_checkpoints_collector/collection_result/model/collection_point_result_manager.py,sha256=4rFBPUdjjf-SuqEaz0_lxBv8szEWI6N1x48P6zDbqVw,2360
8
+ snowflake/snowpark_checkpoints_collector/column_collection/__init__.py,sha256=hpTh1V7hqBSHxNUqISwfxdz-NLD-7oZEMLXDUuRsoOU,783
9
+ snowflake/snowpark_checkpoints_collector/column_collection/column_collector_manager.py,sha256=_8CjfN0Q6g0g_hkvx6zBMat0RNAqQ89xfkid0MPLsRE,8961
10
+ snowflake/snowpark_checkpoints_collector/column_collection/model/__init__.py,sha256=d0WNMeayDyUKYFLLaVAMIC5Qt-DoWoWgOjj2ygJaHWA,2919
11
+ snowflake/snowpark_checkpoints_collector/column_collection/model/array_column_collector.py,sha256=10ITldLcri_3LoQaqrZJMUwvpcgs5gQy3-BFKQB77EA,4268
12
+ snowflake/snowpark_checkpoints_collector/column_collection/model/binary_column_collector.py,sha256=TuvKnwCIyoc3B9DfSeckGk6-bLLrDVDZdW8NDFkitMI,3255
13
+ snowflake/snowpark_checkpoints_collector/column_collection/model/boolean_column_collector.py,sha256=zfZ47YmYkKI-Zhg_8zmijgaGc6nOPJDVOyqi1RM6TfA,2397
14
+ snowflake/snowpark_checkpoints_collector/column_collection/model/column_collector_base.py,sha256=8ptauA7RwRwBIDG03tG0iO6FCOdLcLSwJbiUggb627s,3069
15
+ snowflake/snowpark_checkpoints_collector/column_collection/model/date_column_collector.py,sha256=GlQM7mJrExM4FZxK861RhjFPshGmavTO9IVnpclirwI,2550
16
+ snowflake/snowpark_checkpoints_collector/column_collection/model/day_time_interval_column_collector.py,sha256=Rfm_j6aYDCcKgJb_4WIz4q6rIhPKARSX6sqruuFnWdk,2468
17
+ snowflake/snowpark_checkpoints_collector/column_collection/model/decimal_column_collector.py,sha256=xuy6PH0USxpp8otLNRMbpKwVVGHM2EbQnLGB0_L6xlI,3389
18
+ snowflake/snowpark_checkpoints_collector/column_collection/model/empty_column_collector.py,sha256=6cniB9D4GLSL1rHpcIAIxsZpNgS1_FFkDfs_2Bd-PJ4,3181
19
+ snowflake/snowpark_checkpoints_collector/column_collection/model/map_column_collector.py,sha256=WchiONzWsubjM22D_ZReabYGAevMvD6MmcXickhScj8,4517
20
+ snowflake/snowpark_checkpoints_collector/column_collection/model/null_column_collector.py,sha256=nojzBg-5VU4bxVZDoEQYZaeUnEsUaoBNO6XwOAJHsmU,1750
21
+ snowflake/snowpark_checkpoints_collector/column_collection/model/numeric_column_collector.py,sha256=ZwLAyWTELSoNbwK9F74Ft3LxCptHBDUgXGGlNRWYUVo,4052
22
+ snowflake/snowpark_checkpoints_collector/column_collection/model/string_column_collector.py,sha256=6J2ONJojJP6Ss8xOBGgqBNd1QpeIqpA29_nWIZYscjM,2602
23
+ snowflake/snowpark_checkpoints_collector/column_collection/model/struct_column_collector.py,sha256=E6uG3UqsJERmS9XUQq14pFFTiWiZIGg7LuFR8ITATUc,3530
24
+ snowflake/snowpark_checkpoints_collector/column_collection/model/timestamp_column_collector.py,sha256=FAWxRUX25ep2XhhagsBVuNmB3QUMA1xMfNTVkaHilbY,2572
25
+ snowflake/snowpark_checkpoints_collector/column_collection/model/timestamp_ntz_column_collector.py,sha256=glUUnCLgTbGiPLpF2pSZ11KCgKSpHDRt5uhi1ZT9bxA,2578
26
+ snowflake/snowpark_checkpoints_collector/column_pandera_checks/__init__.py,sha256=JNZPOYx8rUTONGz_d7xyfAvEC2_umHmGkJLoNSATLs4,793
27
+ snowflake/snowpark_checkpoints_collector/column_pandera_checks/pandera_column_checks_manager.py,sha256=uugv4Pyq0wpYvJRFyQmJR1SvnXjlqBNHTLIDiTLTLhA,7311
28
+ snowflake/snowpark_checkpoints_collector/snow_connection_model/__init__.py,sha256=kLjZId-aGCljK7lF6yeEw-syEqeTOJDxdXfpv9YxvZA,755
29
+ snowflake/snowpark_checkpoints_collector/snow_connection_model/snow_connection.py,sha256=QH3kPQ5rHS9CV7f-djw0mhM7KT99cFNYXpjU6ADJHuo,6047
30
+ snowflake/snowpark_checkpoints_collector/utils/checkpoint_name_utils.py,sha256=WExQaZ4oL4otDCtM8kyGbf0Gn_v1a-tzM5j1p0wVDVg,1767
31
+ snowflake/snowpark_checkpoints_collector/utils/extra_config.py,sha256=xkXFH1PIS0Mtzpu-LrcOKBjzCbptp2zWqgGN9X1P_A0,3393
32
+ snowflake/snowpark_checkpoints_collector/utils/file_utils.py,sha256=deetkhQZOB0GUxQJvUHw4Ridp_rNYiCqmK9li3uwBL0,4324
33
+ snowflake/snowpark_checkpoints_collector/utils/telemetry.py,sha256=JZbPbHQCYYiNeHrpmylmSAMuP3VSl5sTd-4bUNWqquA,30833
34
+ snowpark_checkpoints_collectors-0.1.1.dist-info/METADATA,sha256=9ImPJDy_Ikijegi8okK29jFctGeh98iG4BtvxZqSQNU,5568
35
+ snowpark_checkpoints_collectors-0.1.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
36
+ snowpark_checkpoints_collectors-0.1.1.dist-info/licenses/LICENSE,sha256=DVQuDIgE45qn836wDaWnYhSdxoLXgpRRKH4RuTjpRZQ,10174
37
+ snowpark_checkpoints_collectors-0.1.1.dist-info/RECORD,,
@@ -175,28 +175,3 @@
175
175
  of your accepting any such warranty or additional liability.
176
176
 
177
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 2025 Snowflake
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.
@@ -1,347 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: snowpark-checkpoints-collectors
3
- Version: 0.1.0rc2
4
- Summary: Snowpark column and table statistics collection
5
- Project-URL: Bug Tracker, https://github.com/snowflakedb/snowpark-checkpoints/issues
6
- Project-URL: Source code, https://github.com/snowflakedb/snowpark-checkpoints/
7
- Author: Snowflake Inc.
8
- License:
9
- Apache License
10
- Version 2.0, January 2004
11
- http://www.apache.org/licenses/
12
-
13
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
14
-
15
- 1. Definitions.
16
-
17
- "License" shall mean the terms and conditions for use, reproduction,
18
- and distribution as defined by Sections 1 through 9 of this document.
19
-
20
- "Licensor" shall mean the copyright owner or entity authorized by
21
- the copyright owner that is granting the License.
22
-
23
- "Legal Entity" shall mean the union of the acting entity and all
24
- other entities that control, are controlled by, or are under common
25
- control with that entity. For the purposes of this definition,
26
- "control" means (i) the power, direct or indirect, to cause the
27
- direction or management of such entity, whether by contract or
28
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
29
- outstanding shares, or (iii) beneficial ownership of such entity.
30
-
31
- "You" (or "Your") shall mean an individual or Legal Entity
32
- exercising permissions granted by this License.
33
-
34
- "Source" form shall mean the preferred form for making modifications,
35
- including but not limited to software source code, documentation
36
- source, and configuration files.
37
-
38
- "Object" form shall mean any form resulting from mechanical
39
- transformation or translation of a Source form, including but
40
- not limited to compiled object code, generated documentation,
41
- and conversions to other media types.
42
-
43
- "Work" shall mean the work of authorship, whether in Source or
44
- Object form, made available under the License, as indicated by a
45
- copyright notice that is included in or attached to the work
46
- (an example is provided in the Appendix below).
47
-
48
- "Derivative Works" shall mean any work, whether in Source or Object
49
- form, that is based on (or derived from) the Work and for which the
50
- editorial revisions, annotations, elaborations, or other modifications
51
- represent, as a whole, an original work of authorship. For the purposes
52
- of this License, Derivative Works shall not include works that remain
53
- separable from, or merely link (or bind by name) to the interfaces of,
54
- the Work and Derivative Works thereof.
55
-
56
- "Contribution" shall mean any work of authorship, including
57
- the original version of the Work and any modifications or additions
58
- to that Work or Derivative Works thereof, that is intentionally
59
- submitted to Licensor for inclusion in the Work by the copyright owner
60
- or by an individual or Legal Entity authorized to submit on behalf of
61
- the copyright owner. For the purposes of this definition, "submitted"
62
- means any form of electronic, verbal, or written communication sent
63
- to the Licensor or its representatives, including but not limited to
64
- communication on electronic mailing lists, source code control systems,
65
- and issue tracking systems that are managed by, or on behalf of, the
66
- Licensor for the purpose of discussing and improving the Work, but
67
- excluding communication that is conspicuously marked or otherwise
68
- designated in writing by the copyright owner as "Not a Contribution."
69
-
70
- "Contributor" shall mean Licensor and any individual or Legal Entity
71
- on behalf of whom a Contribution has been received by Licensor and
72
- subsequently incorporated within the Work.
73
-
74
- 2. Grant of Copyright 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
- copyright license to reproduce, prepare Derivative Works of,
78
- publicly display, publicly perform, sublicense, and distribute the
79
- Work and such Derivative Works in Source or Object form.
80
-
81
- 3. Grant of Patent License. Subject to the terms and conditions of
82
- this License, each Contributor hereby grants to You a perpetual,
83
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
84
- (except as stated in this section) patent license to make, have made,
85
- use, offer to sell, sell, import, and otherwise transfer the Work,
86
- where such license applies only to those patent claims licensable
87
- by such Contributor that are necessarily infringed by their
88
- Contribution(s) alone or by combination of their Contribution(s)
89
- with the Work to which such Contribution(s) was submitted. If You
90
- institute patent litigation against any entity (including a
91
- cross-claim or counterclaim in a lawsuit) alleging that the Work
92
- or a Contribution incorporated within the Work constitutes direct
93
- or contributory patent infringement, then any patent licenses
94
- granted to You under this License for that Work shall terminate
95
- as of the date such litigation is filed.
96
-
97
- 4. Redistribution. You may reproduce and distribute copies of the
98
- Work or Derivative Works thereof in any medium, with or without
99
- modifications, and in Source or Object form, provided that You
100
- meet the following conditions:
101
-
102
- (a) You must give any other recipients of the Work or
103
- Derivative Works a copy of this License; and
104
-
105
- (b) You must cause any modified files to carry prominent notices
106
- stating that You changed the files; and
107
-
108
- (c) You must retain, in the Source form of any Derivative Works
109
- that You distribute, all copyright, patent, trademark, and
110
- attribution notices from the Source form of the Work,
111
- excluding those notices that do not pertain to any part of
112
- the Derivative Works; and
113
-
114
- (d) If the Work includes a "NOTICE" text file as part of its
115
- distribution, then any Derivative Works that You distribute must
116
- include a readable copy of the attribution notices contained
117
- within such NOTICE file, excluding those notices that do not
118
- pertain to any part of the Derivative Works, in at least one
119
- of the following places: within a NOTICE text file distributed
120
- as part of the Derivative Works; within the Source form or
121
- documentation, if provided along with the Derivative Works; or,
122
- within a display generated by the Derivative Works, if and
123
- wherever such third-party notices normally appear. The contents
124
- of the NOTICE file are for informational purposes only and
125
- do not modify the License. You may add Your own attribution
126
- notices within Derivative Works that You distribute, alongside
127
- or as an addendum to the NOTICE text from the Work, provided
128
- that such additional attribution notices cannot be construed
129
- as modifying the License.
130
-
131
- You may add Your own copyright statement to Your modifications and
132
- may provide additional or different license terms and conditions
133
- for use, reproduction, or distribution of Your modifications, or
134
- for any such Derivative Works as a whole, provided Your use,
135
- reproduction, and distribution of the Work otherwise complies with
136
- the conditions stated in this License.
137
-
138
- 5. Submission of Contributions. Unless You explicitly state otherwise,
139
- any Contribution intentionally submitted for inclusion in the Work
140
- by You to the Licensor shall be under the terms and conditions of
141
- this License, without any additional terms or conditions.
142
- Notwithstanding the above, nothing herein shall supersede or modify
143
- the terms of any separate license agreement you may have executed
144
- with Licensor regarding such Contributions.
145
-
146
- 6. Trademarks. This License does not grant permission to use the trade
147
- names, trademarks, service marks, or product names of the Licensor,
148
- except as required for reasonable and customary use in describing the
149
- origin of the Work and reproducing the content of the NOTICE file.
150
-
151
- 7. Disclaimer of Warranty. Unless required by applicable law or
152
- agreed to in writing, Licensor provides the Work (and each
153
- Contributor provides its Contributions) on an "AS IS" BASIS,
154
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
155
- implied, including, without limitation, any warranties or conditions
156
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
157
- PARTICULAR PURPOSE. You are solely responsible for determining the
158
- appropriateness of using or redistributing the Work and assume any
159
- risks associated with Your exercise of permissions under this License.
160
-
161
- 8. Limitation of Liability. In no event and under no legal theory,
162
- whether in tort (including negligence), contract, or otherwise,
163
- unless required by applicable law (such as deliberate and grossly
164
- negligent acts) or agreed to in writing, shall any Contributor be
165
- liable to You for damages, including any direct, indirect, special,
166
- incidental, or consequential damages of any character arising as a
167
- result of this License or out of the use or inability to use the
168
- Work (including but not limited to damages for loss of goodwill,
169
- work stoppage, computer failure or malfunction, or any and all
170
- other commercial damages or losses), even if such Contributor
171
- has been advised of the possibility of such damages.
172
-
173
- 9. Accepting Warranty or Additional Liability. While redistributing
174
- the Work or Derivative Works thereof, You may choose to offer,
175
- and charge a fee for, acceptance of support, warranty, indemnity,
176
- or other liability obligations and/or rights consistent with this
177
- License. However, in accepting such obligations, You may act only
178
- on Your own behalf and on Your sole responsibility, not on behalf
179
- of any other Contributor, and only if You agree to indemnify,
180
- defend, and hold each Contributor harmless for any liability
181
- incurred by, or claims asserted against, such Contributor by reason
182
- of your accepting any such warranty or additional liability.
183
-
184
- END OF TERMS AND CONDITIONS
185
-
186
- APPENDIX: How to apply the Apache License to your work.
187
-
188
- To apply the Apache License to your work, attach the following
189
- boilerplate notice, with the fields enclosed by brackets "[]"
190
- replaced with your own identifying information. (Don't include
191
- the brackets!) The text should be enclosed in the appropriate
192
- comment syntax for the file format. We also recommend that a
193
- file or class name and description of purpose be included on the
194
- same "printed page" as the copyright notice for easier
195
- identification within third-party archives.
196
-
197
- Copyright 2025 Snowflake
198
-
199
- Licensed under the Apache License, Version 2.0 (the "License");
200
- you may not use this file except in compliance with the License.
201
- You may obtain a copy of the License at
202
-
203
- http://www.apache.org/licenses/LICENSE-2.0
204
-
205
- Unless required by applicable law or agreed to in writing, software
206
- distributed under the License is distributed on an "AS IS" BASIS,
207
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
208
- See the License for the specific language governing permissions and
209
- limitations under the License.
210
- License-File: LICENSE
211
- Keywords: Snowflake,Snowpark,analytics,cloud,database,db
212
- Classifier: Development Status :: 4 - Beta
213
- Classifier: Environment :: Console
214
- Classifier: Environment :: Other Environment
215
- Classifier: Intended Audience :: Developers
216
- Classifier: Intended Audience :: Education
217
- Classifier: Intended Audience :: Information Technology
218
- Classifier: Intended Audience :: System Administrators
219
- Classifier: License :: OSI Approved :: Apache Software License
220
- Classifier: Operating System :: OS Independent
221
- Classifier: Programming Language :: Python :: 3 :: Only
222
- Classifier: Programming Language :: SQL
223
- Classifier: Topic :: Database
224
- Classifier: Topic :: Scientific/Engineering :: Information Analysis
225
- Classifier: Topic :: Software Development
226
- Classifier: Topic :: Software Development :: Libraries
227
- Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
228
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
229
- Requires-Python: <3.12,>=3.9
230
- Requires-Dist: pandera[io]==0.20.4
231
- Requires-Dist: pyspark
232
- Requires-Dist: snowflake-connector-python
233
- Requires-Dist: snowflake-snowpark-python
234
- Provides-Extra: development
235
- Requires-Dist: coverage>=7.6.7; extra == 'development'
236
- Requires-Dist: deepdiff>=8.0.0; extra == 'development'
237
- Requires-Dist: hatchling==1.25.0; extra == 'development'
238
- Requires-Dist: pre-commit>=4.0.1; extra == 'development'
239
- Requires-Dist: pyarrow>=18.0.0; extra == 'development'
240
- Requires-Dist: pytest-cov>=6.0.0; extra == 'development'
241
- Requires-Dist: pytest>=8.3.3; extra == 'development'
242
- Requires-Dist: setuptools>=70.0.0; extra == 'development'
243
- Requires-Dist: twine==5.1.1; extra == 'development'
244
- Description-Content-Type: text/markdown
245
-
246
- # snowpark-checkpoints-collectors
247
-
248
- ---
249
- **NOTE**
250
-
251
- This package is on Private Preview.
252
-
253
- ---
254
-
255
- **snowpark-checkpoints-collector** package offers a function for extracting information from PySpark dataframes. We can then use that data to validate against the converted Snowpark dataframes to ensure that behavioral equivalence has been achieved.
256
- ## Features
257
-
258
- - Schema inference collected data mode (Schema): This is the default mode, which leverages Pandera schema inference to obtain the metadata and checks that will be evaluated for the specified dataframe. This mode also collects custom data from columns of the DataFrame based on the PySpark type.
259
- - DataFrame collected data mode (DataFrame): This mode collects the data of the PySpark dataframe. In this case, the mechanism saves all data of the given dataframe in parquet format. Using the default user Snowflake connection, it tries to upload the parquet files into the Snowflake temporal stage and create a table based on the information in the stage. The name of the file and the table is the same as the checkpoint.
260
-
261
-
262
-
263
- ## Functionalities
264
-
265
- ### Collect DataFrame Checkpoint
266
-
267
-
268
-
269
- ```python
270
- from pyspark.sql import DataFrame as SparkDataFrame
271
- from snowflake.snowpark_checkpoints_collector.collection_common import CheckpointMode
272
- from typing import Optional
273
-
274
- # Signature of the function
275
- def collect_dataframe_checkpoint(
276
- df: SparkDataFrame,
277
- checkpoint_name: str,
278
- sample: Optional[float] = None,
279
- mode: Optional[CheckpointMode] = None,
280
- output_path: Optional[str] = None,
281
- ) -> None:
282
- ...
283
- ```
284
-
285
- - `df`: The input Spark dataframe to collect.
286
- - `checkpoint_name`: Name of the checkpoint schema file or dataframe.
287
- - `sample`: Fraction of DataFrame to sample for schema inference, defaults to 1.0.
288
- - `mode`: The mode to execution the collection (Schema or Dataframe), defaults to CheckpointMode.Schema.
289
- - `output_path`: The output path to save the checkpoint, defaults to current working directory.
290
-
291
-
292
- ## Usage Example
293
-
294
- ### Schema mode
295
-
296
- ```python
297
- from pyspark.sql import SparkSession
298
- from snowflake.snowpark_checkpoints_collector import collect_dataframe_checkpoint
299
- from snowflake.snowpark_checkpoints_collector.collection_common import CheckpointMode
300
-
301
- spark_session = SparkSession.builder.getOrCreate()
302
- sample_size = 1.0
303
-
304
- pyspark_df = spark_session.createDataFrame(
305
- [("apple", 21), ("lemon", 34), ("banana", 50)], schema="fruit string, age integer"
306
- )
307
-
308
- collect_dataframe_checkpoint(
309
- pyspark_df,
310
- checkpoint_name="collect_checkpoint_mode_1",
311
- sample=sample_size,
312
- mode=CheckpointMode.SCHEMA,
313
- )
314
- ```
315
-
316
-
317
- ### Dataframe mode
318
-
319
- ```python
320
- from pyspark.sql import SparkSession
321
- from snowflake.snowpark_checkpoints_collector import collect_dataframe_checkpoint
322
- from snowflake.snowpark_checkpoints_collector.collection_common import CheckpointMode
323
- from pyspark.sql.types import StructType, StructField, ByteType, StringType, IntegerType
324
-
325
- spark_schema = StructType(
326
- [
327
- StructField("BYTE", ByteType(), True),
328
- StructField("STRING", StringType(), True),
329
- StructField("INTEGER", IntegerType(), True)
330
- ]
331
- )
332
-
333
- data = [(1, "apple", 21), (2, "lemon", 34), (3, "banana", 50)]
334
-
335
- spark_session = SparkSession.builder.getOrCreate()
336
- pyspark_df = spark_session.createDataFrame(data, schema=spark_schema).orderBy(
337
- "INTEGER"
338
- )
339
-
340
- collect_dataframe_checkpoint(
341
- pyspark_df,
342
- checkpoint_name="collect_checkpoint_mode_2",
343
- mode=CheckpointMode.DATAFRAME,
344
- )
345
- ```
346
-
347
- ------
@@ -1,4 +0,0 @@
1
- snowpark_checkpoints_collectors-0.1.0rc2.dist-info/METADATA,sha256=8Ep1fq-1C-mR2_uhK11XBnnIOJth9ZMvACaVDKof0nw,18424
2
- snowpark_checkpoints_collectors-0.1.0rc2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
3
- snowpark_checkpoints_collectors-0.1.0rc2.dist-info/licenses/LICENSE,sha256=pmjhbh6uVhV5MBXOlou_UZgFP7CYVQITkCCdvfcS5lY,11340
4
- snowpark_checkpoints_collectors-0.1.0rc2.dist-info/RECORD,,