snowpark-connect 0.23.0__py3-none-any.whl → 0.25.0__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.

Potentially problematic release.


This version of snowpark-connect might be problematic. Click here for more details.

Files changed (476) hide show
  1. snowflake/snowpark_connect/column_name_handler.py +116 -4
  2. snowflake/snowpark_connect/config.py +13 -0
  3. snowflake/snowpark_connect/constants.py +0 -29
  4. snowflake/snowpark_connect/dataframe_container.py +6 -0
  5. snowflake/snowpark_connect/execute_plan/map_execution_command.py +56 -1
  6. snowflake/snowpark_connect/expression/function_defaults.py +207 -0
  7. snowflake/snowpark_connect/expression/literal.py +18 -2
  8. snowflake/snowpark_connect/expression/map_cast.py +5 -8
  9. snowflake/snowpark_connect/expression/map_expression.py +10 -1
  10. snowflake/snowpark_connect/expression/map_extension.py +12 -2
  11. snowflake/snowpark_connect/expression/map_sql_expression.py +23 -1
  12. snowflake/snowpark_connect/expression/map_udf.py +26 -8
  13. snowflake/snowpark_connect/expression/map_unresolved_attribute.py +199 -15
  14. snowflake/snowpark_connect/expression/map_unresolved_extract_value.py +44 -16
  15. snowflake/snowpark_connect/expression/map_unresolved_function.py +836 -365
  16. snowflake/snowpark_connect/expression/map_unresolved_star.py +3 -2
  17. snowflake/snowpark_connect/hidden_column.py +39 -0
  18. snowflake/snowpark_connect/includes/jars/hadoop-client-api-trimmed-3.3.4.jar +0 -0
  19. snowflake/snowpark_connect/includes/jars/{hadoop-client-api-3.3.4.jar → spark-connect-client-jvm_2.12-3.5.6.jar} +0 -0
  20. snowflake/snowpark_connect/relation/map_column_ops.py +18 -36
  21. snowflake/snowpark_connect/relation/map_extension.py +56 -15
  22. snowflake/snowpark_connect/relation/map_join.py +258 -62
  23. snowflake/snowpark_connect/relation/map_row_ops.py +2 -29
  24. snowflake/snowpark_connect/relation/map_sql.py +88 -11
  25. snowflake/snowpark_connect/relation/map_udtf.py +4 -2
  26. snowflake/snowpark_connect/relation/read/map_read.py +3 -3
  27. snowflake/snowpark_connect/relation/read/map_read_jdbc.py +1 -1
  28. snowflake/snowpark_connect/relation/read/map_read_json.py +8 -1
  29. snowflake/snowpark_connect/relation/read/map_read_table.py +1 -9
  30. snowflake/snowpark_connect/relation/read/reader_config.py +3 -1
  31. snowflake/snowpark_connect/relation/read/utils.py +6 -7
  32. snowflake/snowpark_connect/relation/utils.py +1 -170
  33. snowflake/snowpark_connect/relation/write/map_write.py +62 -53
  34. snowflake/snowpark_connect/resources_initializer.py +29 -1
  35. snowflake/snowpark_connect/server.py +18 -3
  36. snowflake/snowpark_connect/type_mapping.py +29 -25
  37. snowflake/snowpark_connect/typed_column.py +14 -0
  38. snowflake/snowpark_connect/utils/artifacts.py +23 -0
  39. snowflake/snowpark_connect/utils/context.py +6 -1
  40. snowflake/snowpark_connect/utils/scala_udf_utils.py +588 -0
  41. snowflake/snowpark_connect/utils/telemetry.py +6 -17
  42. snowflake/snowpark_connect/utils/udf_helper.py +2 -0
  43. snowflake/snowpark_connect/utils/udf_utils.py +38 -7
  44. snowflake/snowpark_connect/utils/udtf_utils.py +17 -3
  45. snowflake/snowpark_connect/version.py +1 -1
  46. {snowpark_connect-0.23.0.dist-info → snowpark_connect-0.25.0.dist-info}/METADATA +1 -1
  47. snowpark_connect-0.25.0.dist-info/RECORD +477 -0
  48. snowflake/snowpark_connect/includes/jars/scala-compiler-2.12.18.jar +0 -0
  49. snowflake/snowpark_connect/includes/jars/spark-kubernetes_2.12-3.5.6.jar +0 -0
  50. snowflake/snowpark_connect/includes/jars/spark-mllib_2.12-3.5.6.jar +0 -0
  51. snowflake/snowpark_connect/includes/jars/spark-streaming_2.12-3.5.6.jar +0 -0
  52. snowflake/snowpark_connect/includes/python/pyspark/errors/tests/__init__.py +0 -16
  53. snowflake/snowpark_connect/includes/python/pyspark/errors/tests/test_errors.py +0 -60
  54. snowflake/snowpark_connect/includes/python/pyspark/ml/deepspeed/tests/test_deepspeed_distributor.py +0 -306
  55. snowflake/snowpark_connect/includes/python/pyspark/ml/tests/__init__.py +0 -16
  56. snowflake/snowpark_connect/includes/python/pyspark/ml/tests/connect/test_connect_classification.py +0 -53
  57. snowflake/snowpark_connect/includes/python/pyspark/ml/tests/connect/test_connect_evaluation.py +0 -50
  58. snowflake/snowpark_connect/includes/python/pyspark/ml/tests/connect/test_connect_feature.py +0 -43
  59. snowflake/snowpark_connect/includes/python/pyspark/ml/tests/connect/test_connect_function.py +0 -114
  60. snowflake/snowpark_connect/includes/python/pyspark/ml/tests/connect/test_connect_pipeline.py +0 -47
  61. snowflake/snowpark_connect/includes/python/pyspark/ml/tests/connect/test_connect_summarizer.py +0 -43
  62. snowflake/snowpark_connect/includes/python/pyspark/ml/tests/connect/test_connect_tuning.py +0 -46
  63. snowflake/snowpark_connect/includes/python/pyspark/ml/tests/connect/test_legacy_mode_classification.py +0 -238
  64. snowflake/snowpark_connect/includes/python/pyspark/ml/tests/connect/test_legacy_mode_evaluation.py +0 -194
  65. snowflake/snowpark_connect/includes/python/pyspark/ml/tests/connect/test_legacy_mode_feature.py +0 -156
  66. snowflake/snowpark_connect/includes/python/pyspark/ml/tests/connect/test_legacy_mode_pipeline.py +0 -184
  67. snowflake/snowpark_connect/includes/python/pyspark/ml/tests/connect/test_legacy_mode_summarizer.py +0 -78
  68. snowflake/snowpark_connect/includes/python/pyspark/ml/tests/connect/test_legacy_mode_tuning.py +0 -292
  69. snowflake/snowpark_connect/includes/python/pyspark/ml/tests/connect/test_parity_torch_data_loader.py +0 -50
  70. snowflake/snowpark_connect/includes/python/pyspark/ml/tests/connect/test_parity_torch_distributor.py +0 -152
  71. snowflake/snowpark_connect/includes/python/pyspark/ml/tests/test_algorithms.py +0 -456
  72. snowflake/snowpark_connect/includes/python/pyspark/ml/tests/test_base.py +0 -96
  73. snowflake/snowpark_connect/includes/python/pyspark/ml/tests/test_dl_util.py +0 -186
  74. snowflake/snowpark_connect/includes/python/pyspark/ml/tests/test_evaluation.py +0 -77
  75. snowflake/snowpark_connect/includes/python/pyspark/ml/tests/test_feature.py +0 -401
  76. snowflake/snowpark_connect/includes/python/pyspark/ml/tests/test_functions.py +0 -528
  77. snowflake/snowpark_connect/includes/python/pyspark/ml/tests/test_image.py +0 -82
  78. snowflake/snowpark_connect/includes/python/pyspark/ml/tests/test_linalg.py +0 -409
  79. snowflake/snowpark_connect/includes/python/pyspark/ml/tests/test_model_cache.py +0 -55
  80. snowflake/snowpark_connect/includes/python/pyspark/ml/tests/test_param.py +0 -441
  81. snowflake/snowpark_connect/includes/python/pyspark/ml/tests/test_persistence.py +0 -546
  82. snowflake/snowpark_connect/includes/python/pyspark/ml/tests/test_pipeline.py +0 -71
  83. snowflake/snowpark_connect/includes/python/pyspark/ml/tests/test_stat.py +0 -52
  84. snowflake/snowpark_connect/includes/python/pyspark/ml/tests/test_training_summary.py +0 -494
  85. snowflake/snowpark_connect/includes/python/pyspark/ml/tests/test_util.py +0 -85
  86. snowflake/snowpark_connect/includes/python/pyspark/ml/tests/test_wrapper.py +0 -138
  87. snowflake/snowpark_connect/includes/python/pyspark/ml/tests/tuning/__init__.py +0 -16
  88. snowflake/snowpark_connect/includes/python/pyspark/ml/tests/tuning/test_cv_io_basic.py +0 -151
  89. snowflake/snowpark_connect/includes/python/pyspark/ml/tests/tuning/test_cv_io_nested.py +0 -97
  90. snowflake/snowpark_connect/includes/python/pyspark/ml/tests/tuning/test_cv_io_pipeline.py +0 -143
  91. snowflake/snowpark_connect/includes/python/pyspark/ml/tests/tuning/test_tuning.py +0 -551
  92. snowflake/snowpark_connect/includes/python/pyspark/ml/tests/tuning/test_tvs_io_basic.py +0 -137
  93. snowflake/snowpark_connect/includes/python/pyspark/ml/tests/tuning/test_tvs_io_nested.py +0 -96
  94. snowflake/snowpark_connect/includes/python/pyspark/ml/tests/tuning/test_tvs_io_pipeline.py +0 -142
  95. snowflake/snowpark_connect/includes/python/pyspark/ml/torch/tests/__init__.py +0 -16
  96. snowflake/snowpark_connect/includes/python/pyspark/ml/torch/tests/test_data_loader.py +0 -137
  97. snowflake/snowpark_connect/includes/python/pyspark/ml/torch/tests/test_distributor.py +0 -561
  98. snowflake/snowpark_connect/includes/python/pyspark/ml/torch/tests/test_log_communication.py +0 -172
  99. snowflake/snowpark_connect/includes/python/pyspark/mllib/tests/__init__.py +0 -16
  100. snowflake/snowpark_connect/includes/python/pyspark/mllib/tests/test_algorithms.py +0 -353
  101. snowflake/snowpark_connect/includes/python/pyspark/mllib/tests/test_feature.py +0 -192
  102. snowflake/snowpark_connect/includes/python/pyspark/mllib/tests/test_linalg.py +0 -680
  103. snowflake/snowpark_connect/includes/python/pyspark/mllib/tests/test_stat.py +0 -206
  104. snowflake/snowpark_connect/includes/python/pyspark/mllib/tests/test_streaming_algorithms.py +0 -471
  105. snowflake/snowpark_connect/includes/python/pyspark/mllib/tests/test_util.py +0 -108
  106. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/__init__.py +0 -16
  107. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/computation/__init__.py +0 -16
  108. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/computation/test_any_all.py +0 -177
  109. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/computation/test_apply_func.py +0 -575
  110. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/computation/test_binary_ops.py +0 -235
  111. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/computation/test_combine.py +0 -653
  112. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/computation/test_compute.py +0 -463
  113. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/computation/test_corrwith.py +0 -86
  114. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/computation/test_cov.py +0 -151
  115. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/computation/test_cumulative.py +0 -139
  116. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/computation/test_describe.py +0 -458
  117. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/computation/test_eval.py +0 -86
  118. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/computation/test_melt.py +0 -202
  119. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/computation/test_missing_data.py +0 -520
  120. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/computation/test_pivot.py +0 -361
  121. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/__init__.py +0 -16
  122. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/computation/__init__.py +0 -16
  123. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/computation/test_parity_any_all.py +0 -40
  124. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/computation/test_parity_apply_func.py +0 -42
  125. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/computation/test_parity_binary_ops.py +0 -40
  126. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/computation/test_parity_combine.py +0 -37
  127. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/computation/test_parity_compute.py +0 -60
  128. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/computation/test_parity_corrwith.py +0 -40
  129. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/computation/test_parity_cov.py +0 -40
  130. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/computation/test_parity_cumulative.py +0 -90
  131. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/computation/test_parity_describe.py +0 -40
  132. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/computation/test_parity_eval.py +0 -40
  133. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/computation/test_parity_melt.py +0 -40
  134. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/computation/test_parity_missing_data.py +0 -42
  135. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/computation/test_parity_pivot.py +0 -37
  136. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/data_type_ops/__init__.py +0 -16
  137. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/data_type_ops/test_parity_base.py +0 -36
  138. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/data_type_ops/test_parity_binary_ops.py +0 -42
  139. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/data_type_ops/test_parity_boolean_ops.py +0 -47
  140. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/data_type_ops/test_parity_categorical_ops.py +0 -55
  141. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/data_type_ops/test_parity_complex_ops.py +0 -40
  142. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/data_type_ops/test_parity_date_ops.py +0 -47
  143. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/data_type_ops/test_parity_datetime_ops.py +0 -47
  144. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/data_type_ops/test_parity_null_ops.py +0 -42
  145. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/data_type_ops/test_parity_num_arithmetic.py +0 -43
  146. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/data_type_ops/test_parity_num_ops.py +0 -47
  147. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/data_type_ops/test_parity_num_reverse.py +0 -43
  148. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/data_type_ops/test_parity_string_ops.py +0 -47
  149. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/data_type_ops/test_parity_timedelta_ops.py +0 -47
  150. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/data_type_ops/test_parity_udt_ops.py +0 -40
  151. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/data_type_ops/testing_utils.py +0 -226
  152. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/diff_frames_ops/__init__.py +0 -16
  153. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/diff_frames_ops/test_parity_align.py +0 -39
  154. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/diff_frames_ops/test_parity_basic_slow.py +0 -55
  155. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/diff_frames_ops/test_parity_cov_corrwith.py +0 -39
  156. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/diff_frames_ops/test_parity_dot_frame.py +0 -39
  157. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/diff_frames_ops/test_parity_dot_series.py +0 -39
  158. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/diff_frames_ops/test_parity_index.py +0 -39
  159. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/diff_frames_ops/test_parity_series.py +0 -39
  160. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/diff_frames_ops/test_parity_setitem_frame.py +0 -43
  161. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/diff_frames_ops/test_parity_setitem_series.py +0 -43
  162. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/frame/__init__.py +0 -16
  163. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/frame/test_parity_attrs.py +0 -40
  164. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/frame/test_parity_constructor.py +0 -39
  165. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/frame/test_parity_conversion.py +0 -42
  166. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/frame/test_parity_reindexing.py +0 -42
  167. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/frame/test_parity_reshaping.py +0 -37
  168. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/frame/test_parity_spark.py +0 -40
  169. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/frame/test_parity_take.py +0 -42
  170. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/frame/test_parity_time_series.py +0 -48
  171. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/frame/test_parity_truncate.py +0 -40
  172. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/groupby/__init__.py +0 -16
  173. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/groupby/test_parity_aggregate.py +0 -40
  174. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/groupby/test_parity_apply_func.py +0 -41
  175. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/groupby/test_parity_cumulative.py +0 -67
  176. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/groupby/test_parity_describe.py +0 -40
  177. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/groupby/test_parity_groupby.py +0 -55
  178. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/groupby/test_parity_head_tail.py +0 -40
  179. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/groupby/test_parity_index.py +0 -38
  180. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/groupby/test_parity_missing_data.py +0 -55
  181. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/groupby/test_parity_split_apply.py +0 -39
  182. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/groupby/test_parity_stat.py +0 -38
  183. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/indexes/__init__.py +0 -16
  184. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/indexes/test_parity_align.py +0 -40
  185. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/indexes/test_parity_base.py +0 -50
  186. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/indexes/test_parity_category.py +0 -73
  187. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/indexes/test_parity_datetime.py +0 -39
  188. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/indexes/test_parity_indexing.py +0 -40
  189. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/indexes/test_parity_reindex.py +0 -40
  190. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/indexes/test_parity_rename.py +0 -40
  191. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/indexes/test_parity_reset_index.py +0 -48
  192. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/indexes/test_parity_timedelta.py +0 -39
  193. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/io/__init__.py +0 -16
  194. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/io/test_parity_io.py +0 -40
  195. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/plot/__init__.py +0 -16
  196. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/plot/test_parity_frame_plot.py +0 -45
  197. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/plot/test_parity_frame_plot_matplotlib.py +0 -45
  198. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/plot/test_parity_frame_plot_plotly.py +0 -49
  199. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/plot/test_parity_series_plot.py +0 -37
  200. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/plot/test_parity_series_plot_matplotlib.py +0 -53
  201. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/plot/test_parity_series_plot_plotly.py +0 -45
  202. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/series/__init__.py +0 -16
  203. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/series/test_parity_all_any.py +0 -38
  204. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/series/test_parity_arg_ops.py +0 -37
  205. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/series/test_parity_as_of.py +0 -37
  206. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/series/test_parity_as_type.py +0 -38
  207. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/series/test_parity_compute.py +0 -37
  208. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/series/test_parity_conversion.py +0 -40
  209. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/series/test_parity_cumulative.py +0 -40
  210. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/series/test_parity_index.py +0 -38
  211. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/series/test_parity_missing_data.py +0 -40
  212. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/series/test_parity_series.py +0 -37
  213. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/series/test_parity_sort.py +0 -38
  214. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/series/test_parity_stat.py +0 -38
  215. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_categorical.py +0 -66
  216. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_config.py +0 -37
  217. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_csv.py +0 -37
  218. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_dataframe_conversion.py +0 -42
  219. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_dataframe_spark_io.py +0 -39
  220. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_default_index.py +0 -49
  221. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_ewm.py +0 -37
  222. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_expanding.py +0 -39
  223. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_extension.py +0 -49
  224. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_frame_spark.py +0 -53
  225. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_generic_functions.py +0 -43
  226. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_indexing.py +0 -49
  227. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_indexops_spark.py +0 -39
  228. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_internal.py +0 -41
  229. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_namespace.py +0 -39
  230. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_numpy_compat.py +0 -60
  231. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_ops_on_diff_frames.py +0 -48
  232. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_ops_on_diff_frames_groupby.py +0 -39
  233. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_ops_on_diff_frames_groupby_expanding.py +0 -44
  234. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_ops_on_diff_frames_groupby_rolling.py +0 -84
  235. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_repr.py +0 -37
  236. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_resample.py +0 -45
  237. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_reshape.py +0 -39
  238. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_rolling.py +0 -39
  239. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_scalars.py +0 -37
  240. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_series_conversion.py +0 -39
  241. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_series_datetime.py +0 -39
  242. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_series_string.py +0 -39
  243. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_spark_functions.py +0 -39
  244. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_sql.py +0 -43
  245. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_stats.py +0 -37
  246. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_typedef.py +0 -36
  247. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_utils.py +0 -37
  248. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_window.py +0 -39
  249. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/data_type_ops/__init__.py +0 -16
  250. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/data_type_ops/test_base.py +0 -107
  251. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/data_type_ops/test_binary_ops.py +0 -224
  252. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/data_type_ops/test_boolean_ops.py +0 -825
  253. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/data_type_ops/test_categorical_ops.py +0 -562
  254. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/data_type_ops/test_complex_ops.py +0 -368
  255. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/data_type_ops/test_date_ops.py +0 -257
  256. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/data_type_ops/test_datetime_ops.py +0 -260
  257. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/data_type_ops/test_null_ops.py +0 -178
  258. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/data_type_ops/test_num_arithmetic.py +0 -184
  259. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/data_type_ops/test_num_ops.py +0 -497
  260. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/data_type_ops/test_num_reverse.py +0 -140
  261. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/data_type_ops/test_string_ops.py +0 -354
  262. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/data_type_ops/test_timedelta_ops.py +0 -219
  263. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/data_type_ops/test_udt_ops.py +0 -192
  264. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/data_type_ops/testing_utils.py +0 -228
  265. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/diff_frames_ops/__init__.py +0 -16
  266. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/diff_frames_ops/test_align.py +0 -118
  267. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/diff_frames_ops/test_basic_slow.py +0 -198
  268. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/diff_frames_ops/test_cov_corrwith.py +0 -181
  269. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/diff_frames_ops/test_dot_frame.py +0 -103
  270. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/diff_frames_ops/test_dot_series.py +0 -141
  271. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/diff_frames_ops/test_index.py +0 -109
  272. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/diff_frames_ops/test_series.py +0 -136
  273. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/diff_frames_ops/test_setitem_frame.py +0 -125
  274. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/diff_frames_ops/test_setitem_series.py +0 -217
  275. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/frame/__init__.py +0 -16
  276. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/frame/test_attrs.py +0 -384
  277. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/frame/test_constructor.py +0 -598
  278. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/frame/test_conversion.py +0 -73
  279. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/frame/test_reindexing.py +0 -869
  280. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/frame/test_reshaping.py +0 -487
  281. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/frame/test_spark.py +0 -309
  282. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/frame/test_take.py +0 -156
  283. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/frame/test_time_series.py +0 -149
  284. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/frame/test_truncate.py +0 -163
  285. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/groupby/__init__.py +0 -16
  286. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/groupby/test_aggregate.py +0 -311
  287. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/groupby/test_apply_func.py +0 -524
  288. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/groupby/test_cumulative.py +0 -419
  289. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/groupby/test_describe.py +0 -144
  290. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/groupby/test_groupby.py +0 -979
  291. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/groupby/test_head_tail.py +0 -234
  292. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/groupby/test_index.py +0 -206
  293. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/groupby/test_missing_data.py +0 -421
  294. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/groupby/test_split_apply.py +0 -187
  295. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/groupby/test_stat.py +0 -397
  296. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/indexes/__init__.py +0 -16
  297. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/indexes/test_align.py +0 -100
  298. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/indexes/test_base.py +0 -2743
  299. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/indexes/test_category.py +0 -484
  300. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/indexes/test_datetime.py +0 -276
  301. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/indexes/test_indexing.py +0 -432
  302. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/indexes/test_reindex.py +0 -310
  303. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/indexes/test_rename.py +0 -257
  304. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/indexes/test_reset_index.py +0 -160
  305. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/indexes/test_timedelta.py +0 -128
  306. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/io/__init__.py +0 -16
  307. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/io/test_io.py +0 -137
  308. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/plot/__init__.py +0 -16
  309. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/plot/test_frame_plot.py +0 -170
  310. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/plot/test_frame_plot_matplotlib.py +0 -547
  311. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/plot/test_frame_plot_plotly.py +0 -285
  312. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/plot/test_series_plot.py +0 -106
  313. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/plot/test_series_plot_matplotlib.py +0 -409
  314. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/plot/test_series_plot_plotly.py +0 -247
  315. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/series/__init__.py +0 -16
  316. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/series/test_all_any.py +0 -105
  317. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/series/test_arg_ops.py +0 -197
  318. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/series/test_as_of.py +0 -137
  319. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/series/test_as_type.py +0 -227
  320. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/series/test_compute.py +0 -634
  321. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/series/test_conversion.py +0 -88
  322. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/series/test_cumulative.py +0 -139
  323. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/series/test_index.py +0 -475
  324. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/series/test_missing_data.py +0 -265
  325. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/series/test_series.py +0 -818
  326. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/series/test_sort.py +0 -162
  327. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/series/test_stat.py +0 -780
  328. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_categorical.py +0 -741
  329. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_config.py +0 -160
  330. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_csv.py +0 -453
  331. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_dataframe_conversion.py +0 -281
  332. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_dataframe_spark_io.py +0 -487
  333. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_default_index.py +0 -109
  334. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_ewm.py +0 -434
  335. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_expanding.py +0 -253
  336. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_extension.py +0 -152
  337. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_frame_spark.py +0 -162
  338. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_generic_functions.py +0 -234
  339. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_indexing.py +0 -1339
  340. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_indexops_spark.py +0 -82
  341. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_internal.py +0 -124
  342. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_namespace.py +0 -638
  343. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_numpy_compat.py +0 -200
  344. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_ops_on_diff_frames.py +0 -1355
  345. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_ops_on_diff_frames_groupby.py +0 -655
  346. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_ops_on_diff_frames_groupby_expanding.py +0 -113
  347. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_ops_on_diff_frames_groupby_rolling.py +0 -118
  348. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_repr.py +0 -192
  349. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_resample.py +0 -346
  350. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_reshape.py +0 -495
  351. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_rolling.py +0 -263
  352. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_scalars.py +0 -59
  353. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_series_conversion.py +0 -85
  354. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_series_datetime.py +0 -364
  355. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_series_string.py +0 -362
  356. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_spark_functions.py +0 -46
  357. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_sql.py +0 -123
  358. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_stats.py +0 -581
  359. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_typedef.py +0 -447
  360. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_utils.py +0 -301
  361. snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_window.py +0 -465
  362. snowflake/snowpark_connect/includes/python/pyspark/resource/tests/__init__.py +0 -16
  363. snowflake/snowpark_connect/includes/python/pyspark/resource/tests/test_resources.py +0 -83
  364. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/__init__.py +0 -16
  365. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/__init__.py +0 -16
  366. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/client/__init__.py +0 -16
  367. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/client/test_artifact.py +0 -420
  368. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/client/test_client.py +0 -358
  369. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/streaming/__init__.py +0 -16
  370. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/streaming/test_parity_foreach.py +0 -36
  371. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/streaming/test_parity_foreach_batch.py +0 -44
  372. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/streaming/test_parity_listener.py +0 -116
  373. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/streaming/test_parity_streaming.py +0 -35
  374. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_connect_basic.py +0 -3612
  375. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_connect_column.py +0 -1042
  376. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_connect_function.py +0 -2381
  377. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_connect_plan.py +0 -1060
  378. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_arrow.py +0 -163
  379. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_arrow_map.py +0 -38
  380. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_arrow_python_udf.py +0 -48
  381. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_catalog.py +0 -36
  382. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_column.py +0 -55
  383. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_conf.py +0 -36
  384. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_dataframe.py +0 -96
  385. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_datasources.py +0 -44
  386. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_errors.py +0 -36
  387. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_functions.py +0 -59
  388. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_group.py +0 -36
  389. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_pandas_cogrouped_map.py +0 -59
  390. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_pandas_grouped_map.py +0 -74
  391. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_pandas_grouped_map_with_state.py +0 -62
  392. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_pandas_map.py +0 -58
  393. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_pandas_udf.py +0 -70
  394. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_pandas_udf_grouped_agg.py +0 -50
  395. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_pandas_udf_scalar.py +0 -68
  396. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_pandas_udf_window.py +0 -40
  397. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_readwriter.py +0 -46
  398. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_serde.py +0 -44
  399. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_types.py +0 -100
  400. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_udf.py +0 -100
  401. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_udtf.py +0 -163
  402. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_session.py +0 -181
  403. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_utils.py +0 -42
  404. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/pandas/__init__.py +0 -16
  405. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/pandas/test_pandas_cogrouped_map.py +0 -623
  406. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/pandas/test_pandas_grouped_map.py +0 -869
  407. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/pandas/test_pandas_grouped_map_with_state.py +0 -342
  408. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/pandas/test_pandas_map.py +0 -436
  409. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/pandas/test_pandas_udf.py +0 -363
  410. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/pandas/test_pandas_udf_grouped_agg.py +0 -592
  411. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/pandas/test_pandas_udf_scalar.py +0 -1503
  412. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/pandas/test_pandas_udf_typehints.py +0 -392
  413. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/pandas/test_pandas_udf_typehints_with_future_annotations.py +0 -375
  414. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/pandas/test_pandas_udf_window.py +0 -411
  415. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/streaming/__init__.py +0 -16
  416. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/streaming/test_streaming.py +0 -401
  417. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/streaming/test_streaming_foreach.py +0 -295
  418. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/streaming/test_streaming_foreach_batch.py +0 -106
  419. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/streaming/test_streaming_listener.py +0 -558
  420. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/test_arrow.py +0 -1346
  421. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/test_arrow_map.py +0 -182
  422. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/test_arrow_python_udf.py +0 -202
  423. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/test_catalog.py +0 -503
  424. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/test_column.py +0 -225
  425. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/test_conf.py +0 -83
  426. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/test_context.py +0 -201
  427. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/test_dataframe.py +0 -1931
  428. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/test_datasources.py +0 -256
  429. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/test_errors.py +0 -69
  430. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/test_functions.py +0 -1349
  431. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/test_group.py +0 -53
  432. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/test_pandas_sqlmetrics.py +0 -68
  433. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/test_readwriter.py +0 -283
  434. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/test_serde.py +0 -155
  435. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/test_session.py +0 -412
  436. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/test_types.py +0 -1581
  437. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/test_udf.py +0 -961
  438. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/test_udf_profiler.py +0 -165
  439. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/test_udtf.py +0 -1456
  440. snowflake/snowpark_connect/includes/python/pyspark/sql/tests/test_utils.py +0 -1686
  441. snowflake/snowpark_connect/includes/python/pyspark/streaming/tests/__init__.py +0 -16
  442. snowflake/snowpark_connect/includes/python/pyspark/streaming/tests/test_context.py +0 -184
  443. snowflake/snowpark_connect/includes/python/pyspark/streaming/tests/test_dstream.py +0 -706
  444. snowflake/snowpark_connect/includes/python/pyspark/streaming/tests/test_kinesis.py +0 -118
  445. snowflake/snowpark_connect/includes/python/pyspark/streaming/tests/test_listener.py +0 -160
  446. snowflake/snowpark_connect/includes/python/pyspark/tests/__init__.py +0 -16
  447. snowflake/snowpark_connect/includes/python/pyspark/tests/test_appsubmit.py +0 -306
  448. snowflake/snowpark_connect/includes/python/pyspark/tests/test_broadcast.py +0 -196
  449. snowflake/snowpark_connect/includes/python/pyspark/tests/test_conf.py +0 -44
  450. snowflake/snowpark_connect/includes/python/pyspark/tests/test_context.py +0 -346
  451. snowflake/snowpark_connect/includes/python/pyspark/tests/test_daemon.py +0 -89
  452. snowflake/snowpark_connect/includes/python/pyspark/tests/test_install_spark.py +0 -124
  453. snowflake/snowpark_connect/includes/python/pyspark/tests/test_join.py +0 -69
  454. snowflake/snowpark_connect/includes/python/pyspark/tests/test_memory_profiler.py +0 -167
  455. snowflake/snowpark_connect/includes/python/pyspark/tests/test_pin_thread.py +0 -194
  456. snowflake/snowpark_connect/includes/python/pyspark/tests/test_profiler.py +0 -168
  457. snowflake/snowpark_connect/includes/python/pyspark/tests/test_rdd.py +0 -939
  458. snowflake/snowpark_connect/includes/python/pyspark/tests/test_rddbarrier.py +0 -52
  459. snowflake/snowpark_connect/includes/python/pyspark/tests/test_rddsampler.py +0 -66
  460. snowflake/snowpark_connect/includes/python/pyspark/tests/test_readwrite.py +0 -368
  461. snowflake/snowpark_connect/includes/python/pyspark/tests/test_serializers.py +0 -257
  462. snowflake/snowpark_connect/includes/python/pyspark/tests/test_shuffle.py +0 -267
  463. snowflake/snowpark_connect/includes/python/pyspark/tests/test_stage_sched.py +0 -153
  464. snowflake/snowpark_connect/includes/python/pyspark/tests/test_statcounter.py +0 -130
  465. snowflake/snowpark_connect/includes/python/pyspark/tests/test_taskcontext.py +0 -350
  466. snowflake/snowpark_connect/includes/python/pyspark/tests/test_util.py +0 -97
  467. snowflake/snowpark_connect/includes/python/pyspark/tests/test_worker.py +0 -271
  468. snowpark_connect-0.23.0.dist-info/RECORD +0 -893
  469. {snowpark_connect-0.23.0.data → snowpark_connect-0.25.0.data}/scripts/snowpark-connect +0 -0
  470. {snowpark_connect-0.23.0.data → snowpark_connect-0.25.0.data}/scripts/snowpark-session +0 -0
  471. {snowpark_connect-0.23.0.data → snowpark_connect-0.25.0.data}/scripts/snowpark-submit +0 -0
  472. {snowpark_connect-0.23.0.dist-info → snowpark_connect-0.25.0.dist-info}/WHEEL +0 -0
  473. {snowpark_connect-0.23.0.dist-info → snowpark_connect-0.25.0.dist-info}/licenses/LICENSE-binary +0 -0
  474. {snowpark_connect-0.23.0.dist-info → snowpark_connect-0.25.0.dist-info}/licenses/LICENSE.txt +0 -0
  475. {snowpark_connect-0.23.0.dist-info → snowpark_connect-0.25.0.dist-info}/licenses/NOTICE-binary +0 -0
  476. {snowpark_connect-0.23.0.dist-info → snowpark_connect-0.25.0.dist-info}/top_level.txt +0 -0
@@ -1,1456 +0,0 @@
1
- #
2
- # Licensed to the Apache Software Foundation (ASF) under one or more
3
- # contributor license agreements. See the NOTICE file distributed with
4
- # this work for additional information regarding copyright ownership.
5
- # The ASF licenses this file to You under the Apache License, Version 2.0
6
- # (the "License"); you may not use this file except in compliance with
7
- # the License. You may obtain a copy of the License at
8
- #
9
- # http://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
- import os
18
- import tempfile
19
- import unittest
20
- from typing import Iterator
21
-
22
- from py4j.protocol import Py4JJavaError
23
-
24
- from pyspark.errors import (
25
- PySparkAttributeError,
26
- PythonException,
27
- PySparkTypeError,
28
- AnalysisException,
29
- PySparkRuntimeError,
30
- )
31
- from pyspark.rdd import PythonEvalType
32
- from pyspark.sql.functions import lit, udf, udtf
33
- from pyspark.sql.types import IntegerType, MapType, Row, StringType, StructType
34
- from pyspark.testing import assertDataFrameEqual
35
- from pyspark.testing.sqlutils import (
36
- have_pandas,
37
- have_pyarrow,
38
- pandas_requirement_message,
39
- pyarrow_requirement_message,
40
- ReusedSQLTestCase,
41
- )
42
-
43
-
44
- class BaseUDTFTestsMixin:
45
- def test_simple_udtf(self):
46
- class TestUDTF:
47
- def eval(self):
48
- yield "hello", "world"
49
-
50
- func = udtf(TestUDTF, returnType="c1: string, c2: string")
51
- rows = func().collect()
52
- self.assertEqual(rows, [Row(c1="hello", c2="world")])
53
-
54
- def test_udtf_yield_single_row_col(self):
55
- class TestUDTF:
56
- def eval(self, a: int):
57
- yield a,
58
-
59
- func = udtf(TestUDTF, returnType="a: int")
60
- rows = func(lit(1)).collect()
61
- self.assertEqual(rows, [Row(a=1)])
62
-
63
- def test_udtf_yield_multi_cols(self):
64
- class TestUDTF:
65
- def eval(self, a: int):
66
- yield a, a + 1
67
-
68
- func = udtf(TestUDTF, returnType="a: int, b: int")
69
- rows = func(lit(1)).collect()
70
- self.assertEqual(rows, [Row(a=1, b=2)])
71
-
72
- def test_udtf_yield_multi_rows(self):
73
- class TestUDTF:
74
- def eval(self, a: int):
75
- yield a,
76
- yield a + 1,
77
-
78
- func = udtf(TestUDTF, returnType="a: int")
79
- rows = func(lit(1)).collect()
80
- self.assertEqual(rows, [Row(a=1), Row(a=2)])
81
-
82
- def test_udtf_yield_multi_row_col(self):
83
- class TestUDTF:
84
- def eval(self, a: int, b: int):
85
- yield a, b, a + b
86
- yield a, b, a - b
87
- yield a, b, b - a
88
-
89
- func = udtf(TestUDTF, returnType="a: int, b: int, c: int")
90
- rows = func(lit(1), lit(2)).collect()
91
- self.assertEqual(rows, [Row(a=1, b=2, c=3), Row(a=1, b=2, c=-1), Row(a=1, b=2, c=1)])
92
-
93
- def test_udtf_decorator(self):
94
- @udtf(returnType="a: int, b: int")
95
- class TestUDTF:
96
- def eval(self, a: int):
97
- yield a, a + 1
98
-
99
- rows = TestUDTF(lit(1)).collect()
100
- self.assertEqual(rows, [Row(a=1, b=2)])
101
-
102
- def test_udtf_registration(self):
103
- class TestUDTF:
104
- def eval(self, a: int, b: int):
105
- yield a, b, a + b
106
- yield a, b, a - b
107
- yield a, b, b - a
108
-
109
- func = udtf(TestUDTF, returnType="a: int, b: int, c: int")
110
- self.spark.udtf.register("testUDTF", func)
111
- df = self.spark.sql("SELECT * FROM testUDTF(1, 2)")
112
- self.assertEqual(
113
- df.collect(), [Row(a=1, b=2, c=3), Row(a=1, b=2, c=-1), Row(a=1, b=2, c=1)]
114
- )
115
-
116
- def test_udtf_with_lateral_join(self):
117
- class TestUDTF:
118
- def eval(self, a: int, b: int) -> Iterator:
119
- yield a, b, a + b
120
- yield a, b, a - b
121
-
122
- func = udtf(TestUDTF, returnType="a: int, b: int, c: int")
123
- self.spark.udtf.register("testUDTF", func)
124
- df = self.spark.sql(
125
- "SELECT f.* FROM values (0, 1), (1, 2) t(a, b), LATERAL testUDTF(a, b) f"
126
- )
127
- expected = self.spark.createDataFrame(
128
- [(0, 1, 1), (0, 1, -1), (1, 2, 3), (1, 2, -1)], schema=["a", "b", "c"]
129
- )
130
- self.assertEqual(df.collect(), expected.collect())
131
-
132
- def test_udtf_eval_with_return_stmt(self):
133
- class TestUDTF:
134
- def eval(self, a: int, b: int):
135
- return [(a, a + 1), (b, b + 1)]
136
-
137
- func = udtf(TestUDTF, returnType="a: int, b: int")
138
- rows = func(lit(1), lit(2)).collect()
139
- self.assertEqual(rows, [Row(a=1, b=2), Row(a=2, b=3)])
140
-
141
- def test_udtf_eval_returning_non_tuple(self):
142
- @udtf(returnType="a: int")
143
- class TestUDTF:
144
- def eval(self, a: int):
145
- yield a
146
-
147
- with self.assertRaisesRegex(PythonException, "UDTF_INVALID_OUTPUT_ROW_TYPE"):
148
- TestUDTF(lit(1)).collect()
149
-
150
- @udtf(returnType="a: int")
151
- class TestUDTF:
152
- def eval(self, a: int):
153
- return (a,)
154
-
155
- with self.assertRaisesRegex(PythonException, "UDTF_INVALID_OUTPUT_ROW_TYPE"):
156
- TestUDTF(lit(1)).collect()
157
-
158
- def test_udtf_with_invalid_return_value(self):
159
- @udtf(returnType="x: int")
160
- class TestUDTF:
161
- def eval(self, a):
162
- return a
163
-
164
- with self.assertRaisesRegex(PythonException, "UDTF_RETURN_NOT_ITERABLE"):
165
- TestUDTF(lit(1)).collect()
166
-
167
- def test_udtf_with_zero_arg_and_invalid_return_value(self):
168
- @udtf(returnType="x: int")
169
- class TestUDTF:
170
- def eval(self):
171
- return 1
172
-
173
- with self.assertRaisesRegex(PythonException, "UDTF_RETURN_NOT_ITERABLE"):
174
- TestUDTF().collect()
175
-
176
- def test_udtf_with_invalid_return_value_in_terminate(self):
177
- @udtf(returnType="x: int")
178
- class TestUDTF:
179
- def eval(self, a):
180
- ...
181
-
182
- def terminate(self):
183
- return 1
184
-
185
- with self.assertRaisesRegex(PythonException, "UDTF_RETURN_NOT_ITERABLE"):
186
- TestUDTF(lit(1)).collect()
187
-
188
- def test_udtf_eval_with_no_return(self):
189
- @udtf(returnType="a: int")
190
- class TestUDTF:
191
- def eval(self, a: int):
192
- ...
193
-
194
- self.assertEqual(TestUDTF(lit(1)).collect(), [])
195
-
196
- @udtf(returnType="a: int")
197
- class TestUDTF:
198
- def eval(self, a: int):
199
- return
200
-
201
- self.assertEqual(TestUDTF(lit(1)).collect(), [])
202
-
203
- def test_udtf_with_conditional_return(self):
204
- class TestUDTF:
205
- def eval(self, a: int):
206
- if a > 5:
207
- yield a,
208
-
209
- func = udtf(TestUDTF, returnType="a: int")
210
- self.spark.udtf.register("test_udtf", func)
211
- self.assertEqual(
212
- self.spark.sql("SELECT * FROM range(0, 8) JOIN LATERAL test_udtf(id)").collect(),
213
- [Row(id=6, a=6), Row(id=7, a=7)],
214
- )
215
-
216
- def test_udtf_with_empty_yield(self):
217
- @udtf(returnType="a: int")
218
- class TestUDTF:
219
- def eval(self, a: int):
220
- yield
221
-
222
- assertDataFrameEqual(TestUDTF(lit(1)), [Row(a=None)])
223
-
224
- def test_udtf_with_none_output(self):
225
- @udtf(returnType="a: int")
226
- class TestUDTF:
227
- def eval(self, a: int):
228
- yield a,
229
- yield None,
230
-
231
- self.assertEqual(TestUDTF(lit(1)).collect(), [Row(a=1), Row(a=None)])
232
- df = self.spark.createDataFrame([(0, 1), (1, 2)], schema=["a", "b"])
233
- self.assertEqual(TestUDTF(lit(1)).join(df, "a", "inner").collect(), [Row(a=1, b=2)])
234
- assertDataFrameEqual(
235
- TestUDTF(lit(1)).join(df, "a", "left"), [Row(a=None, b=None), Row(a=1, b=2)]
236
- )
237
-
238
- def test_udtf_with_none_input(self):
239
- @udtf(returnType="a: int")
240
- class TestUDTF:
241
- def eval(self, a: int):
242
- yield a,
243
-
244
- self.assertEqual(TestUDTF(lit(None)).collect(), [Row(a=None)])
245
- self.spark.udtf.register("testUDTF", TestUDTF)
246
- df = self.spark.sql("SELECT * FROM testUDTF(null)")
247
- self.assertEqual(df.collect(), [Row(a=None)])
248
-
249
- def test_udtf_with_wrong_num_input(self):
250
- @udtf(returnType="a: int, b: int")
251
- class TestUDTF:
252
- def eval(self, a: int):
253
- yield a, a + 1
254
-
255
- with self.assertRaisesRegex(
256
- PythonException, r"eval\(\) missing 1 required positional argument: 'a'"
257
- ):
258
- TestUDTF().collect()
259
-
260
- with self.assertRaisesRegex(
261
- PythonException, r"eval\(\) takes 2 positional arguments but 3 were given"
262
- ):
263
- TestUDTF(lit(1), lit(2)).collect()
264
-
265
- def test_udtf_init_with_additional_args(self):
266
- @udtf(returnType="x int")
267
- class TestUDTF:
268
- def __init__(self, a: int):
269
- ...
270
-
271
- def eval(self, a: int):
272
- yield a,
273
-
274
- with self.assertRaisesRegex(
275
- PythonException, r"__init__\(\) missing 1 required positional argument: 'a'"
276
- ):
277
- TestUDTF(lit(1)).show()
278
-
279
- def test_udtf_terminate_with_additional_args(self):
280
- @udtf(returnType="x int")
281
- class TestUDTF:
282
- def eval(self, a: int):
283
- yield a,
284
-
285
- def terminate(self, a: int):
286
- ...
287
-
288
- with self.assertRaisesRegex(
289
- PythonException, r"terminate\(\) missing 1 required positional argument: 'a'"
290
- ):
291
- TestUDTF(lit(1)).show()
292
-
293
- def test_udtf_with_wrong_num_output(self):
294
- err_msg = (
295
- r"\[UDTF_RETURN_SCHEMA_MISMATCH\] The number of columns in the "
296
- "result does not match the specified schema."
297
- )
298
-
299
- # Output less columns than specified return schema
300
- @udtf(returnType="a: int, b: int")
301
- class TestUDTF:
302
- def eval(self, a: int):
303
- yield a,
304
-
305
- with self.assertRaisesRegex(PythonException, err_msg):
306
- TestUDTF(lit(1)).collect()
307
-
308
- # Output more columns than specified return schema
309
- @udtf(returnType="a: int")
310
- class TestUDTF:
311
- def eval(self, a: int):
312
- yield a, a + 1
313
-
314
- with self.assertRaisesRegex(PythonException, err_msg):
315
- TestUDTF(lit(1)).collect()
316
-
317
- def test_udtf_with_empty_output_schema_and_non_empty_output(self):
318
- @udtf(returnType=StructType())
319
- class TestUDTF:
320
- def eval(self):
321
- yield 1,
322
-
323
- with self.assertRaisesRegex(PythonException, "UDTF_RETURN_SCHEMA_MISMATCH"):
324
- TestUDTF().collect()
325
-
326
- def test_udtf_with_non_empty_output_schema_and_empty_output(self):
327
- @udtf(returnType="a: int")
328
- class TestUDTF:
329
- def eval(self):
330
- yield tuple()
331
-
332
- with self.assertRaisesRegex(PythonException, "UDTF_RETURN_SCHEMA_MISMATCH"):
333
- TestUDTF().collect()
334
-
335
- def test_udtf_init(self):
336
- @udtf(returnType="a: int, b: int, c: string")
337
- class TestUDTF:
338
- def __init__(self):
339
- self.key = "test"
340
-
341
- def eval(self, a: int):
342
- yield a, a + 1, self.key
343
-
344
- rows = TestUDTF(lit(1)).collect()
345
- self.assertEqual(rows, [Row(a=1, b=2, c="test")])
346
-
347
- def test_udtf_terminate(self):
348
- @udtf(returnType="key: string, value: float")
349
- class TestUDTF:
350
- def __init__(self):
351
- self._count = 0
352
- self._sum = 0
353
-
354
- def eval(self, x: int):
355
- self._count += 1
356
- self._sum += x
357
- yield "input", float(x)
358
-
359
- def terminate(self):
360
- yield "count", float(self._count)
361
- yield "avg", self._sum / self._count
362
-
363
- self.assertEqual(
364
- TestUDTF(lit(1)).collect(),
365
- [Row(key="input", value=1), Row(key="count", value=1.0), Row(key="avg", value=1.0)],
366
- )
367
-
368
- self.spark.udtf.register("test_udtf", TestUDTF)
369
- df = self.spark.sql(
370
- "SELECT id, key, value FROM range(0, 10, 1, 2), "
371
- "LATERAL test_udtf(id) WHERE key != 'input'"
372
- )
373
- self.assertEqual(
374
- df.collect(),
375
- [
376
- Row(id=4, key="count", value=5.0),
377
- Row(id=4, key="avg", value=2.0),
378
- Row(id=9, key="count", value=5.0),
379
- Row(id=9, key="avg", value=7.0),
380
- ],
381
- )
382
-
383
- def test_init_with_exception(self):
384
- @udtf(returnType="x: int")
385
- class TestUDTF:
386
- def __init__(self):
387
- raise Exception("error")
388
-
389
- def eval(self):
390
- yield 1,
391
-
392
- with self.assertRaisesRegex(
393
- PythonException,
394
- r"\[UDTF_EXEC_ERROR\] User defined table function encountered an error "
395
- r"in the '__init__' method: error",
396
- ):
397
- TestUDTF().show()
398
-
399
- def test_eval_with_exception(self):
400
- @udtf(returnType="x: int")
401
- class TestUDTF:
402
- def eval(self):
403
- raise Exception("error")
404
-
405
- with self.assertRaisesRegex(
406
- PythonException,
407
- r"\[UDTF_EXEC_ERROR\] User defined table function encountered an error "
408
- r"in the 'eval' method: error",
409
- ):
410
- TestUDTF().show()
411
-
412
- def test_terminate_with_exceptions(self):
413
- @udtf(returnType="a: int, b: int")
414
- class TestUDTF:
415
- def eval(self, a: int):
416
- yield a, a + 1
417
-
418
- def terminate(self):
419
- raise ValueError("terminate error")
420
-
421
- with self.assertRaisesRegex(
422
- PythonException,
423
- r"\[UDTF_EXEC_ERROR\] User defined table function encountered an error "
424
- r"in the 'terminate' method: terminate error",
425
- ):
426
- TestUDTF(lit(1)).collect()
427
-
428
- def test_udtf_terminate_with_wrong_num_output(self):
429
- err_msg = (
430
- r"\[UDTF_RETURN_SCHEMA_MISMATCH\] The number of columns in the result "
431
- "does not match the specified schema."
432
- )
433
-
434
- @udtf(returnType="a: int, b: int")
435
- class TestUDTF:
436
- def eval(self, a: int):
437
- yield a, a + 1
438
-
439
- def terminate(self):
440
- yield 1, 2, 3
441
-
442
- with self.assertRaisesRegex(PythonException, err_msg):
443
- TestUDTF(lit(1)).show()
444
-
445
- @udtf(returnType="a: int, b: int")
446
- class TestUDTF:
447
- def eval(self, a: int):
448
- yield a, a + 1
449
-
450
- def terminate(self):
451
- yield 1,
452
-
453
- with self.assertRaisesRegex(PythonException, err_msg):
454
- TestUDTF(lit(1)).show()
455
-
456
- def test_udtf_determinism(self):
457
- class TestUDTF:
458
- def eval(self, a: int):
459
- yield a,
460
-
461
- func = udtf(TestUDTF, returnType="x: int")
462
- # The UDTF is marked as non-deterministic by default.
463
- self.assertFalse(func.deterministic)
464
- func = func.asDeterministic()
465
- self.assertTrue(func.deterministic)
466
-
467
- def test_nondeterministic_udtf(self):
468
- import random
469
-
470
- class RandomUDTF:
471
- def eval(self, a: int):
472
- yield a + int(random.random()),
473
-
474
- random_udtf = udtf(RandomUDTF, returnType="x: int")
475
- assertDataFrameEqual(random_udtf(lit(1)), [Row(x=1)])
476
- self.spark.udtf.register("random_udtf", random_udtf)
477
- assertDataFrameEqual(self.spark.sql("select * from random_udtf(1)"), [Row(x=1)])
478
-
479
- def test_udtf_with_nondeterministic_input(self):
480
- from pyspark.sql.functions import rand
481
-
482
- @udtf(returnType="x: int")
483
- class TestUDTF:
484
- def eval(self, a: int):
485
- yield 1 if a > 100 else 0,
486
-
487
- assertDataFrameEqual(TestUDTF(rand(0) * 100), [Row(x=0)])
488
-
489
- def test_udtf_with_invalid_return_type(self):
490
- @udtf(returnType="int")
491
- class TestUDTF:
492
- def eval(self, a: int):
493
- yield a + 1,
494
-
495
- with self.assertRaises(PySparkTypeError) as e:
496
- TestUDTF(lit(1)).collect()
497
-
498
- self.check_error(
499
- exception=e.exception,
500
- error_class="UDTF_RETURN_TYPE_MISMATCH",
501
- message_parameters={"name": "TestUDTF", "return_type": "IntegerType()"},
502
- )
503
-
504
- @udtf(returnType=MapType(StringType(), IntegerType()))
505
- class TestUDTF:
506
- def eval(self, a: int):
507
- yield a + 1,
508
-
509
- with self.assertRaises(PySparkTypeError) as e:
510
- TestUDTF(lit(1)).collect()
511
-
512
- self.check_error(
513
- exception=e.exception,
514
- error_class="UDTF_RETURN_TYPE_MISMATCH",
515
- message_parameters={
516
- "name": "TestUDTF",
517
- "return_type": "MapType(StringType(), IntegerType(), True)",
518
- },
519
- )
520
-
521
- def test_udtf_with_struct_input_type(self):
522
- @udtf(returnType="x: string")
523
- class TestUDTF:
524
- def eval(self, person):
525
- yield f"{person.name}: {person.age}",
526
-
527
- self.spark.udtf.register("test_udtf", TestUDTF)
528
- self.assertEqual(
529
- self.spark.sql(
530
- "select * from test_udtf(named_struct('name', 'Alice', 'age', 1))"
531
- ).collect(),
532
- [Row(x="Alice: 1")],
533
- )
534
-
535
- def test_udtf_with_array_input_type(self):
536
- @udtf(returnType="x: string")
537
- class TestUDTF:
538
- def eval(self, args):
539
- yield str(args),
540
-
541
- self.spark.udtf.register("test_udtf", TestUDTF)
542
- self.assertEqual(
543
- self.spark.sql("select * from test_udtf(array(1, 2, 3))").collect(),
544
- [Row(x="[1, 2, 3]")],
545
- )
546
-
547
- def test_udtf_with_map_input_type(self):
548
- @udtf(returnType="x: string")
549
- class TestUDTF:
550
- def eval(self, m):
551
- yield str(m),
552
-
553
- self.spark.udtf.register("test_udtf", TestUDTF)
554
- self.assertEqual(
555
- self.spark.sql("select * from test_udtf(map('key', 'value'))").collect(),
556
- [Row(x="{'key': 'value'}")],
557
- )
558
-
559
- def test_udtf_with_struct_output_types(self):
560
- @udtf(returnType="x: struct<a:int,b:int>")
561
- class TestUDTF:
562
- def eval(self, x: int):
563
- yield {"a": x, "b": x + 1},
564
-
565
- self.assertEqual(TestUDTF(lit(1)).collect(), [Row(x=Row(a=1, b=2))])
566
-
567
- def test_udtf_with_array_output_types(self):
568
- @udtf(returnType="x: array<int>")
569
- class TestUDTF:
570
- def eval(self, x: int):
571
- yield [x, x + 1, x + 2],
572
-
573
- self.assertEqual(TestUDTF(lit(1)).collect(), [Row(x=[1, 2, 3])])
574
-
575
- def test_udtf_with_map_output_types(self):
576
- @udtf(returnType="x: map<int,string>")
577
- class TestUDTF:
578
- def eval(self, x: int):
579
- yield {x: str(x)},
580
-
581
- self.assertEqual(TestUDTF(lit(1)).collect(), [Row(x={1: "1"})])
582
-
583
- def test_udtf_with_empty_output_types(self):
584
- @udtf(returnType=StructType())
585
- class TestUDTF:
586
- def eval(self):
587
- yield tuple()
588
-
589
- assertDataFrameEqual(TestUDTF(), [Row()])
590
-
591
- def _check_result_or_exception(
592
- self, func_handler, ret_type, expected, *, err_type=PythonException
593
- ):
594
- func = udtf(func_handler, returnType=ret_type)
595
- if not isinstance(expected, str):
596
- assertDataFrameEqual(func(), expected)
597
- else:
598
- with self.assertRaisesRegex(err_type, expected):
599
- func().collect()
600
-
601
- def test_numeric_output_type_casting(self):
602
- class TestUDTF:
603
- def eval(self):
604
- yield 1,
605
-
606
- for i, (ret_type, expected) in enumerate(
607
- [
608
- ("x: boolean", [Row(x=None)]),
609
- ("x: tinyint", [Row(x=1)]),
610
- ("x: smallint", [Row(x=1)]),
611
- ("x: int", [Row(x=1)]),
612
- ("x: bigint", [Row(x=1)]),
613
- ("x: string", [Row(x="1")]), # int to string is ok, but string to int is None
614
- (
615
- "x: date",
616
- "AttributeError",
617
- ), # AttributeError: 'int' object has no attribute 'toordinal'
618
- (
619
- "x: timestamp",
620
- "AttributeError",
621
- ), # AttributeError: 'int' object has no attribute 'tzinfo'
622
- ("x: byte", [Row(x=1)]),
623
- ("x: binary", [Row(x=None)]),
624
- ("x: float", [Row(x=None)]),
625
- ("x: double", [Row(x=None)]),
626
- ("x: decimal(10, 0)", [Row(x=None)]),
627
- ("x: array<int>", [Row(x=None)]),
628
- ("x: map<string,int>", [Row(x=None)]),
629
- ("x: struct<a:int>", "UNEXPECTED_TUPLE_WITH_STRUCT"),
630
- ]
631
- ):
632
- with self.subTest(ret_type=ret_type):
633
- self._check_result_or_exception(TestUDTF, ret_type, expected)
634
-
635
- def test_numeric_string_output_type_casting(self):
636
- class TestUDTF:
637
- def eval(self):
638
- yield "1",
639
-
640
- for ret_type, expected in [
641
- ("x: boolean", [Row(x=None)]),
642
- ("x: tinyint", [Row(x=None)]),
643
- ("x: smallint", [Row(x=None)]),
644
- ("x: int", [Row(x=None)]),
645
- ("x: bigint", [Row(x=None)]),
646
- ("x: string", [Row(x="1")]),
647
- ("x: date", "AttributeError"),
648
- ("x: timestamp", "AttributeError"),
649
- ("x: byte", [Row(x=None)]),
650
- ("x: binary", [Row(x=bytearray(b"1"))]),
651
- ("x: float", [Row(x=None)]),
652
- ("x: double", [Row(x=None)]),
653
- ("x: decimal(10, 0)", [Row(x=None)]),
654
- ("x: array<int>", [Row(x=None)]),
655
- ("x: map<string,int>", [Row(x=None)]),
656
- ("x: struct<a:int>", "UNEXPECTED_TUPLE_WITH_STRUCT"),
657
- ]:
658
- with self.subTest(ret_type=ret_type):
659
- self._check_result_or_exception(TestUDTF, ret_type, expected)
660
-
661
- def test_string_output_type_casting(self):
662
- class TestUDTF:
663
- def eval(self):
664
- yield "hello",
665
-
666
- for ret_type, expected in [
667
- ("x: boolean", [Row(x=None)]),
668
- ("x: tinyint", [Row(x=None)]),
669
- ("x: smallint", [Row(x=None)]),
670
- ("x: int", [Row(x=None)]),
671
- ("x: bigint", [Row(x=None)]),
672
- ("x: string", [Row(x="hello")]),
673
- ("x: date", "AttributeError"),
674
- ("x: timestamp", "AttributeError"),
675
- ("x: byte", [Row(x=None)]),
676
- ("x: binary", [Row(x=bytearray(b"hello"))]),
677
- ("x: float", [Row(x=None)]),
678
- ("x: double", [Row(x=None)]),
679
- ("x: decimal(10, 0)", [Row(x=None)]),
680
- ("x: array<int>", [Row(x=None)]),
681
- ("x: map<string,int>", [Row(x=None)]),
682
- ("x: struct<a:int>", "UNEXPECTED_TUPLE_WITH_STRUCT"),
683
- ]:
684
- with self.subTest(ret_type=ret_type):
685
- self._check_result_or_exception(TestUDTF, ret_type, expected)
686
-
687
- def test_array_output_type_casting(self):
688
- class TestUDTF:
689
- def eval(self):
690
- yield [0, 1.1, 2],
691
-
692
- for ret_type, expected in [
693
- ("x: boolean", [Row(x=None)]),
694
- ("x: tinyint", [Row(x=None)]),
695
- ("x: smallint", [Row(x=None)]),
696
- ("x: int", [Row(x=None)]),
697
- ("x: bigint", [Row(x=None)]),
698
- ("x: string", [Row(x="[0, 1.1, 2]")]),
699
- ("x: date", "AttributeError"),
700
- ("x: timestamp", "AttributeError"),
701
- ("x: byte", [Row(x=None)]),
702
- ("x: binary", [Row(x=None)]),
703
- ("x: float", [Row(x=None)]),
704
- ("x: double", [Row(x=None)]),
705
- ("x: decimal(10, 0)", [Row(x=None)]),
706
- ("x: array<int>", [Row(x=[0, None, 2])]),
707
- ("x: array<double>", [Row(x=[None, 1.1, None])]),
708
- ("x: array<string>", [Row(x=["0", "1.1", "2"])]),
709
- ("x: array<boolean>", [Row(x=[None, None, None])]),
710
- ("x: array<array<int>>", [Row(x=[None, None, None])]),
711
- ("x: map<string,int>", [Row(x=None)]),
712
- ("x: struct<a:int,b:int,c:int>", [Row(x=Row(a=0, b=None, c=2))]),
713
- ]:
714
- with self.subTest(ret_type=ret_type):
715
- self._check_result_or_exception(TestUDTF, ret_type, expected)
716
-
717
- def test_map_output_type_casting(self):
718
- class TestUDTF:
719
- def eval(self):
720
- yield {"a": 0, "b": 1.1, "c": 2},
721
-
722
- for ret_type, expected in [
723
- ("x: boolean", [Row(x=None)]),
724
- ("x: tinyint", [Row(x=None)]),
725
- ("x: smallint", [Row(x=None)]),
726
- ("x: int", [Row(x=None)]),
727
- ("x: bigint", [Row(x=None)]),
728
- ("x: string", [Row(x="{a=0, b=1.1, c=2}")]),
729
- ("x: date", "AttributeError"),
730
- ("x: timestamp", "AttributeError"),
731
- ("x: byte", [Row(x=None)]),
732
- ("x: binary", [Row(x=None)]),
733
- ("x: float", [Row(x=None)]),
734
- ("x: double", [Row(x=None)]),
735
- ("x: decimal(10, 0)", [Row(x=None)]),
736
- ("x: array<string>", [Row(x=None)]),
737
- ("x: map<string,string>", [Row(x={"a": "0", "b": "1.1", "c": "2"})]),
738
- ("x: map<string,boolean>", [Row(x={"a": None, "b": None, "c": None})]),
739
- ("x: map<string,int>", [Row(x={"a": 0, "b": None, "c": 2})]),
740
- ("x: map<string,float>", [Row(x={"a": None, "b": 1.1, "c": None})]),
741
- ("x: map<string,map<string,int>>", [Row(x={"a": None, "b": None, "c": None})]),
742
- ("x: struct<a:int>", [Row(x=Row(a=0))]),
743
- ]:
744
- with self.subTest(ret_type=ret_type):
745
- self._check_result_or_exception(TestUDTF, ret_type, expected)
746
-
747
- def test_struct_output_type_casting_dict(self):
748
- class TestUDTF:
749
- def eval(self):
750
- yield {"a": 0, "b": 1.1, "c": 2},
751
-
752
- for ret_type, expected in [
753
- ("x: boolean", [Row(x=None)]),
754
- ("x: tinyint", [Row(x=None)]),
755
- ("x: smallint", [Row(x=None)]),
756
- ("x: int", [Row(x=None)]),
757
- ("x: bigint", [Row(x=None)]),
758
- ("x: string", [Row(x="{a=0, b=1.1, c=2}")]),
759
- ("x: date", "AttributeError"),
760
- ("x: timestamp", "AttributeError"),
761
- ("x: byte", [Row(x=None)]),
762
- ("x: binary", [Row(x=None)]),
763
- ("x: float", [Row(x=None)]),
764
- ("x: double", [Row(x=None)]),
765
- ("x: decimal(10, 0)", [Row(x=None)]),
766
- ("x: array<string>", [Row(x=None)]),
767
- ("x: map<string,string>", [Row(x={"a": "0", "b": "1.1", "c": "2"})]),
768
- ("x: struct<a:string,b:string,c:string>", [Row(Row(a="0", b="1.1", c="2"))]),
769
- ("x: struct<a:int,b:int,c:int>", [Row(Row(a=0, b=None, c=2))]),
770
- ("x: struct<a:float,b:float,c:float>", [Row(Row(a=None, b=1.1, c=None))]),
771
- ]:
772
- with self.subTest(ret_type=ret_type):
773
- self._check_result_or_exception(TestUDTF, ret_type, expected)
774
-
775
- def test_struct_output_type_casting_row(self):
776
- self.check_struct_output_type_casting_row(Py4JJavaError)
777
-
778
- def check_struct_output_type_casting_row(self, error_type):
779
- class TestUDTF:
780
- def eval(self):
781
- yield Row(a=0, b=1.1, c=2),
782
-
783
- err = ("PickleException", error_type)
784
-
785
- for ret_type, expected in [
786
- ("x: boolean", err),
787
- ("x: tinyint", err),
788
- ("x: smallint", err),
789
- ("x: int", err),
790
- ("x: bigint", err),
791
- ("x: string", err),
792
- ("x: date", "ValueError"),
793
- ("x: timestamp", "ValueError"),
794
- ("x: byte", err),
795
- ("x: binary", err),
796
- ("x: float", err),
797
- ("x: double", err),
798
- ("x: decimal(10, 0)", err),
799
- ("x: array<string>", err),
800
- ("x: map<string,string>", err),
801
- ("x: struct<a:string,b:string,c:string>", [Row(Row(a="0", b="1.1", c="2"))]),
802
- ("x: struct<a:int,b:int,c:int>", [Row(Row(a=0, b=None, c=2))]),
803
- ("x: struct<a:float,b:float,c:float>", [Row(Row(a=None, b=1.1, c=None))]),
804
- ]:
805
- with self.subTest(ret_type=ret_type):
806
- if isinstance(expected, tuple):
807
- self._check_result_or_exception(
808
- TestUDTF, ret_type, expected[0], err_type=expected[1]
809
- )
810
- else:
811
- self._check_result_or_exception(TestUDTF, ret_type, expected)
812
-
813
- def test_inconsistent_output_types(self):
814
- class TestUDTF:
815
- def eval(self):
816
- yield 1,
817
- yield [1, 2],
818
-
819
- for ret_type, expected in [
820
- ("x: int", [Row(x=1), Row(x=None)]),
821
- ("x: array<int>", [Row(x=None), Row(x=[1, 2])]),
822
- ]:
823
- with self.subTest(ret_type=ret_type):
824
- assertDataFrameEqual(udtf(TestUDTF, returnType=ret_type)(), expected)
825
-
826
- @unittest.skipIf(not have_pandas, pandas_requirement_message)
827
- def test_udtf_with_pandas_input_type(self):
828
- import pandas as pd
829
-
830
- @udtf(returnType="corr: double")
831
- class TestUDTF:
832
- def eval(self, s1: pd.Series, s2: pd.Series):
833
- yield s1.corr(s2)
834
-
835
- self.spark.udtf.register("test_udtf", TestUDTF)
836
- # TODO(SPARK-43968): check during compile time instead of runtime
837
- with self.assertRaisesRegex(
838
- PythonException, "AttributeError: 'int' object has no attribute 'corr'"
839
- ):
840
- self.spark.sql(
841
- "select * from values (1, 2), (2, 3) t(a, b), lateral test_udtf(a, b)"
842
- ).collect()
843
-
844
- def test_udtf_register_error(self):
845
- @udf
846
- def upper(s: str):
847
- return s.upper()
848
-
849
- with self.assertRaises(PySparkTypeError) as e:
850
- self.spark.udtf.register("test_udf", upper)
851
-
852
- self.check_error(
853
- exception=e.exception,
854
- error_class="INVALID_UDTF_EVAL_TYPE",
855
- message_parameters={
856
- "name": "test_udf",
857
- "eval_type": "SQL_TABLE_UDF, SQL_ARROW_TABLE_UDF",
858
- },
859
- )
860
-
861
- def test_udtf_pickle_error(self):
862
- with tempfile.TemporaryDirectory() as d:
863
- file = os.path.join(d, "file.txt")
864
- file_obj = open(file, "w")
865
-
866
- @udtf(returnType="x: int")
867
- class TestUDTF:
868
- def eval(self):
869
- file_obj
870
- yield 1,
871
-
872
- with self.assertRaisesRegex(PySparkRuntimeError, "UDTF_SERIALIZATION_ERROR"):
873
- TestUDTF().collect()
874
-
875
- def test_udtf_access_spark_session(self):
876
- df = self.spark.range(10)
877
-
878
- @udtf(returnType="x: int")
879
- class TestUDTF:
880
- def eval(self):
881
- df.collect()
882
- yield 1,
883
-
884
- with self.assertRaisesRegex(PySparkRuntimeError, "UDTF_SERIALIZATION_ERROR"):
885
- TestUDTF().collect()
886
-
887
- def test_udtf_no_eval(self):
888
- with self.assertRaises(PySparkAttributeError) as e:
889
-
890
- @udtf(returnType="a: int, b: int")
891
- class TestUDTF:
892
- def run(self, a: int):
893
- yield a, a + 1
894
-
895
- self.check_error(
896
- exception=e.exception,
897
- error_class="INVALID_UDTF_NO_EVAL",
898
- message_parameters={"name": "TestUDTF"},
899
- )
900
-
901
- def test_udtf_with_no_handler_class(self):
902
- with self.assertRaises(PySparkTypeError) as e:
903
-
904
- @udtf(returnType="a: int")
905
- def test_udtf(a: int):
906
- yield a,
907
-
908
- self.check_error(
909
- exception=e.exception,
910
- error_class="INVALID_UDTF_HANDLER_TYPE",
911
- message_parameters={"type": "function"},
912
- )
913
-
914
- with self.assertRaises(PySparkTypeError) as e:
915
- udtf(1, returnType="a: int")
916
-
917
- self.check_error(
918
- exception=e.exception,
919
- error_class="INVALID_UDTF_HANDLER_TYPE",
920
- message_parameters={"type": "int"},
921
- )
922
-
923
- def test_udtf_with_table_argument_query(self):
924
- class TestUDTF:
925
- def eval(self, row: Row):
926
- if row["id"] > 5:
927
- yield row["id"],
928
-
929
- func = udtf(TestUDTF, returnType="a: int")
930
- self.spark.udtf.register("test_udtf", func)
931
- self.assertEqual(
932
- self.spark.sql("SELECT * FROM test_udtf(TABLE (SELECT id FROM range(0, 8)))").collect(),
933
- [Row(a=6), Row(a=7)],
934
- )
935
-
936
- def test_udtf_with_int_and_table_argument_query(self):
937
- class TestUDTF:
938
- def eval(self, i: int, row: Row):
939
- if row["id"] > i:
940
- yield row["id"],
941
-
942
- func = udtf(TestUDTF, returnType="a: int")
943
- self.spark.udtf.register("test_udtf", func)
944
- self.assertEqual(
945
- self.spark.sql(
946
- "SELECT * FROM test_udtf(5, TABLE (SELECT id FROM range(0, 8)))"
947
- ).collect(),
948
- [Row(a=6), Row(a=7)],
949
- )
950
-
951
- def test_udtf_with_table_argument_identifier(self):
952
- class TestUDTF:
953
- def eval(self, row: Row):
954
- if row["id"] > 5:
955
- yield row["id"],
956
-
957
- func = udtf(TestUDTF, returnType="a: int")
958
- self.spark.udtf.register("test_udtf", func)
959
-
960
- with self.tempView("v"):
961
- self.spark.sql("CREATE OR REPLACE TEMPORARY VIEW v as SELECT id FROM range(0, 8)")
962
- self.assertEqual(
963
- self.spark.sql("SELECT * FROM test_udtf(TABLE (v))").collect(),
964
- [Row(a=6), Row(a=7)],
965
- )
966
-
967
- def test_udtf_with_int_and_table_argument_identifier(self):
968
- class TestUDTF:
969
- def eval(self, i: int, row: Row):
970
- if row["id"] > i:
971
- yield row["id"],
972
-
973
- func = udtf(TestUDTF, returnType="a: int")
974
- self.spark.udtf.register("test_udtf", func)
975
-
976
- with self.tempView("v"):
977
- self.spark.sql("CREATE OR REPLACE TEMPORARY VIEW v as SELECT id FROM range(0, 8)")
978
- self.assertEqual(
979
- self.spark.sql("SELECT * FROM test_udtf(5, TABLE (v))").collect(),
980
- [Row(a=6), Row(a=7)],
981
- )
982
-
983
- def test_udtf_with_table_argument_unknown_identifier(self):
984
- class TestUDTF:
985
- def eval(self, row: Row):
986
- if row["id"] > 5:
987
- yield row["id"],
988
-
989
- func = udtf(TestUDTF, returnType="a: int")
990
- self.spark.udtf.register("test_udtf", func)
991
-
992
- with self.assertRaisesRegex(AnalysisException, "TABLE_OR_VIEW_NOT_FOUND"):
993
- self.spark.sql("SELECT * FROM test_udtf(TABLE (v))").collect()
994
-
995
- def test_udtf_with_table_argument_malformed_query(self):
996
- class TestUDTF:
997
- def eval(self, row: Row):
998
- if row["id"] > 5:
999
- yield row["id"],
1000
-
1001
- func = udtf(TestUDTF, returnType="a: int")
1002
- self.spark.udtf.register("test_udtf", func)
1003
-
1004
- with self.assertRaisesRegex(AnalysisException, "TABLE_OR_VIEW_NOT_FOUND"):
1005
- self.spark.sql("SELECT * FROM test_udtf(TABLE (SELECT * FROM v))").collect()
1006
-
1007
- def test_udtf_with_table_argument_cte_inside(self):
1008
- class TestUDTF:
1009
- def eval(self, row: Row):
1010
- if row["id"] > 5:
1011
- yield row["id"],
1012
-
1013
- func = udtf(TestUDTF, returnType="a: int")
1014
- self.spark.udtf.register("test_udtf", func)
1015
- self.assertEqual(
1016
- self.spark.sql(
1017
- """
1018
- SELECT * FROM test_udtf(TABLE (
1019
- WITH t AS (
1020
- SELECT id FROM range(0, 8)
1021
- )
1022
- SELECT * FROM t
1023
- ))
1024
- """
1025
- ).collect(),
1026
- [Row(a=6), Row(a=7)],
1027
- )
1028
-
1029
- def test_udtf_with_table_argument_cte_outside(self):
1030
- class TestUDTF:
1031
- def eval(self, row: Row):
1032
- if row["id"] > 5:
1033
- yield row["id"],
1034
-
1035
- func = udtf(TestUDTF, returnType="a: int")
1036
- self.spark.udtf.register("test_udtf", func)
1037
- self.assertEqual(
1038
- self.spark.sql(
1039
- """
1040
- WITH t AS (
1041
- SELECT id FROM range(0, 8)
1042
- )
1043
- SELECT * FROM test_udtf(TABLE (SELECT id FROM t))
1044
- """
1045
- ).collect(),
1046
- [Row(a=6), Row(a=7)],
1047
- )
1048
-
1049
- self.assertEqual(
1050
- self.spark.sql(
1051
- """
1052
- WITH t AS (
1053
- SELECT id FROM range(0, 8)
1054
- )
1055
- SELECT * FROM test_udtf(TABLE (t))
1056
- """
1057
- ).collect(),
1058
- [Row(a=6), Row(a=7)],
1059
- )
1060
-
1061
- # TODO(SPARK-44233): Fix the subquery resolution.
1062
- @unittest.skip("Fails to resolve the subquery.")
1063
- def test_udtf_with_table_argument_lateral_join(self):
1064
- class TestUDTF:
1065
- def eval(self, row: Row):
1066
- if row["id"] > 5:
1067
- yield row["id"],
1068
-
1069
- func = udtf(TestUDTF, returnType="a: int")
1070
- self.spark.udtf.register("test_udtf", func)
1071
- self.assertEqual(
1072
- self.spark.sql(
1073
- """
1074
- SELECT * FROM
1075
- range(0, 8) AS t,
1076
- LATERAL test_udtf(TABLE (t))
1077
- """
1078
- ).collect(),
1079
- [Row(a=6), Row(a=7)],
1080
- )
1081
-
1082
- def test_udtf_with_table_argument_multiple(self):
1083
- class TestUDTF:
1084
- def eval(self, a: Row, b: Row):
1085
- yield a[0], b[0]
1086
-
1087
- func = udtf(TestUDTF, returnType="a: int, b: int")
1088
- self.spark.udtf.register("test_udtf", func)
1089
-
1090
- query = """
1091
- SELECT * FROM test_udtf(
1092
- TABLE (SELECT id FROM range(0, 2)),
1093
- TABLE (SELECT id FROM range(0, 3)))
1094
- """
1095
-
1096
- with self.sql_conf({"spark.sql.tvf.allowMultipleTableArguments.enabled": False}):
1097
- with self.assertRaisesRegex(
1098
- AnalysisException, "TABLE_VALUED_FUNCTION_TOO_MANY_TABLE_ARGUMENTS"
1099
- ):
1100
- self.spark.sql(query).collect()
1101
-
1102
- with self.sql_conf({"spark.sql.tvf.allowMultipleTableArguments.enabled": True}):
1103
- self.assertEqual(
1104
- self.spark.sql(query).collect(),
1105
- [
1106
- Row(a=0, b=0),
1107
- Row(a=1, b=0),
1108
- Row(a=0, b=1),
1109
- Row(a=1, b=1),
1110
- Row(a=0, b=2),
1111
- Row(a=1, b=2),
1112
- ],
1113
- )
1114
-
1115
- def test_docstring(self):
1116
- class TestUDTF:
1117
- """A UDTF for test."""
1118
-
1119
- def __init__(self):
1120
- """Initialize the UDTF"""
1121
- ...
1122
-
1123
- def eval(self, x: int):
1124
- """Evaluate the input row."""
1125
- yield x + 1,
1126
-
1127
- def terminate(self):
1128
- """Terminate the UDTF."""
1129
- ...
1130
-
1131
- cls = udtf(TestUDTF, returnType="y: int").func
1132
- self.assertIn("A UDTF for test", cls.__doc__)
1133
- self.assertIn("Initialize the UDTF", cls.__init__.__doc__)
1134
- self.assertIn("Evaluate the input row", cls.eval.__doc__)
1135
- self.assertIn("Terminate the UDTF", cls.terminate.__doc__)
1136
-
1137
-
1138
- class UDTFTests(BaseUDTFTestsMixin, ReusedSQLTestCase):
1139
- @classmethod
1140
- def setUpClass(cls):
1141
- super(UDTFTests, cls).setUpClass()
1142
- cls.spark.conf.set("spark.sql.execution.pythonUDTF.arrow.enabled", "false")
1143
-
1144
- @classmethod
1145
- def tearDownClass(cls):
1146
- try:
1147
- cls.spark.conf.unset("spark.sql.execution.pythonUDTF.arrow.enabled")
1148
- finally:
1149
- super(UDTFTests, cls).tearDownClass()
1150
-
1151
-
1152
- @unittest.skipIf(
1153
- not have_pandas or not have_pyarrow, pandas_requirement_message or pyarrow_requirement_message
1154
- )
1155
- class UDTFArrowTestsMixin(BaseUDTFTestsMixin):
1156
- def test_eval_type(self):
1157
- def upper(x: str):
1158
- return upper(x)
1159
-
1160
- class TestUDTF:
1161
- def eval(self, x: str):
1162
- return upper(x)
1163
-
1164
- self.assertEqual(
1165
- udtf(TestUDTF, returnType="x: string", useArrow=False).evalType,
1166
- PythonEvalType.SQL_TABLE_UDF,
1167
- )
1168
-
1169
- self.assertEqual(
1170
- udtf(TestUDTF, returnType="x: string", useArrow=True).evalType,
1171
- PythonEvalType.SQL_ARROW_TABLE_UDF,
1172
- )
1173
-
1174
- def test_udtf_arrow_sql_conf(self):
1175
- class TestUDTF:
1176
- def eval(self):
1177
- yield 1,
1178
-
1179
- # We do not use `self.sql_conf` here to test the SQL SET command
1180
- # instead of using PySpark's `spark.conf.set`.
1181
- old_value = self.spark.conf.get("spark.sql.execution.pythonUDTF.arrow.enabled")
1182
- self.spark.sql("SET spark.sql.execution.pythonUDTF.arrow.enabled=False")
1183
- self.assertEqual(udtf(TestUDTF, returnType="x: int").evalType, PythonEvalType.SQL_TABLE_UDF)
1184
- self.spark.sql("SET spark.sql.execution.pythonUDTF.arrow.enabled=True")
1185
- self.assertEqual(
1186
- udtf(TestUDTF, returnType="x: int").evalType, PythonEvalType.SQL_ARROW_TABLE_UDF
1187
- )
1188
- self.spark.conf.set("spark.sql.execution.pythonUDTF.arrow.enabled", old_value)
1189
-
1190
- def test_udtf_eval_returning_non_tuple(self):
1191
- @udtf(returnType="a: int")
1192
- class TestUDTF:
1193
- def eval(self, a: int):
1194
- yield a
1195
-
1196
- # When arrow is enabled, it can handle non-tuple return value.
1197
- assertDataFrameEqual(TestUDTF(lit(1)), [Row(a=1)])
1198
-
1199
- @udtf(returnType="a: int")
1200
- class TestUDTF:
1201
- def eval(self, a: int):
1202
- return [a]
1203
-
1204
- assertDataFrameEqual(TestUDTF(lit(1)), [Row(a=1)])
1205
-
1206
- def test_numeric_output_type_casting(self):
1207
- class TestUDTF:
1208
- def eval(self):
1209
- yield 1,
1210
-
1211
- err = "UDTF_ARROW_TYPE_CAST_ERROR"
1212
-
1213
- for ret_type, expected in [
1214
- ("x: boolean", [Row(x=True)]),
1215
- ("x: tinyint", [Row(x=1)]),
1216
- ("x: smallint", [Row(x=1)]),
1217
- ("x: int", [Row(x=1)]),
1218
- ("x: bigint", [Row(x=1)]),
1219
- ("x: string", [Row(x="1")]), # require arrow.cast
1220
- ("x: date", err),
1221
- ("x: byte", [Row(x=1)]),
1222
- ("x: binary", [Row(x=bytearray(b"\x01"))]),
1223
- ("x: float", [Row(x=1.0)]),
1224
- ("x: double", [Row(x=1.0)]),
1225
- ("x: decimal(10, 0)", err),
1226
- ("x: array<int>", err),
1227
- ("x: map<string,int>", err),
1228
- ("x: struct<a:int>", err),
1229
- ]:
1230
- with self.subTest(ret_type=ret_type):
1231
- self._check_result_or_exception(TestUDTF, ret_type, expected)
1232
-
1233
- def test_numeric_string_output_type_casting(self):
1234
- class TestUDTF:
1235
- def eval(self):
1236
- yield "1",
1237
-
1238
- err = "UDTF_ARROW_TYPE_CAST_ERROR"
1239
-
1240
- for ret_type, expected in [
1241
- ("x: boolean", [Row(x=True)]),
1242
- ("x: tinyint", [Row(x=1)]),
1243
- ("x: smallint", [Row(x=1)]),
1244
- ("x: int", [Row(x=1)]),
1245
- ("x: bigint", [Row(x=1)]),
1246
- ("x: string", [Row(x="1")]),
1247
- ("x: date", err),
1248
- ("x: timestamp", err),
1249
- ("x: byte", [Row(x=1)]),
1250
- ("x: binary", [Row(x=bytearray(b"1"))]),
1251
- ("x: float", [Row(x=1.0)]),
1252
- ("x: double", [Row(x=1.0)]),
1253
- ("x: decimal(10, 0)", [Row(x=1)]),
1254
- ("x: array<string>", [Row(x=["1"])]),
1255
- ("x: array<int>", [Row(x=[1])]),
1256
- ("x: map<string,int>", err),
1257
- ("x: struct<a:int>", err),
1258
- ]:
1259
- with self.subTest(ret_type=ret_type):
1260
- self._check_result_or_exception(TestUDTF, ret_type, expected)
1261
-
1262
- def test_string_output_type_casting(self):
1263
- class TestUDTF:
1264
- def eval(self):
1265
- yield "hello",
1266
-
1267
- err = "UDTF_ARROW_TYPE_CAST_ERROR"
1268
-
1269
- for ret_type, expected in [
1270
- ("x: boolean", err),
1271
- ("x: tinyint", err),
1272
- ("x: smallint", err),
1273
- ("x: int", err),
1274
- ("x: bigint", err),
1275
- ("x: string", [Row(x="hello")]),
1276
- ("x: date", err),
1277
- ("x: timestamp", err),
1278
- ("x: byte", err),
1279
- ("x: binary", [Row(x=bytearray(b"hello"))]),
1280
- ("x: float", err),
1281
- ("x: double", err),
1282
- ("x: decimal(10, 0)", err),
1283
- ("x: array<string>", [Row(x=["h", "e", "l", "l", "o"])]),
1284
- ("x: array<int>", err),
1285
- ("x: map<string,int>", err),
1286
- ("x: struct<a:int>", err),
1287
- ]:
1288
- with self.subTest(ret_type=ret_type):
1289
- self._check_result_or_exception(TestUDTF, ret_type, expected)
1290
-
1291
- def test_array_output_type_casting(self):
1292
- class TestUDTF:
1293
- def eval(self):
1294
- yield [0, 1.1, 2],
1295
-
1296
- err = "UDTF_ARROW_TYPE_CAST_ERROR"
1297
-
1298
- for ret_type, expected in [
1299
- ("x: boolean", err),
1300
- ("x: tinyint", err),
1301
- ("x: smallint", err),
1302
- ("x: int", err),
1303
- ("x: bigint", err),
1304
- ("x: string", err),
1305
- ("x: date", err),
1306
- ("x: timestamp", err),
1307
- ("x: byte", err),
1308
- ("x: binary", err),
1309
- ("x: float", err),
1310
- ("x: double", err),
1311
- ("x: decimal(10, 0)", err),
1312
- ("x: array<string>", [Row(x=["0", "1.1", "2"])]),
1313
- ("x: array<boolean>", [Row(x=[False, True, True])]),
1314
- ("x: array<int>", [Row(x=[0, 1, 2])]),
1315
- ("x: array<float>", [Row(x=[0, 1.1, 2])]),
1316
- ("x: array<array<int>>", err),
1317
- ("x: map<string,int>", err),
1318
- ("x: struct<a:int>", err),
1319
- ("x: struct<a:int,b:int,c:int>", err),
1320
- ]:
1321
- with self.subTest(ret_type=ret_type):
1322
- self._check_result_or_exception(TestUDTF, ret_type, expected)
1323
-
1324
- def test_map_output_type_casting(self):
1325
- class TestUDTF:
1326
- def eval(self):
1327
- yield {"a": 0, "b": 1.1, "c": 2},
1328
-
1329
- err = "UDTF_ARROW_TYPE_CAST_ERROR"
1330
-
1331
- for ret_type, expected in [
1332
- ("x: boolean", err),
1333
- ("x: tinyint", err),
1334
- ("x: smallint", err),
1335
- ("x: int", err),
1336
- ("x: bigint", err),
1337
- ("x: string", err),
1338
- ("x: date", err),
1339
- ("x: timestamp", err),
1340
- ("x: byte", err),
1341
- ("x: binary", err),
1342
- ("x: float", err),
1343
- ("x: double", err),
1344
- ("x: decimal(10, 0)", err),
1345
- ("x: array<string>", [Row(x=["a", "b", "c"])]),
1346
- ("x: map<string,string>", err),
1347
- ("x: map<string,boolean>", err),
1348
- ("x: map<string,int>", [Row(x={"a": 0, "b": 1, "c": 2})]),
1349
- ("x: map<string,float>", [Row(x={"a": 0, "b": 1.1, "c": 2})]),
1350
- ("x: map<string,map<string,int>>", err),
1351
- ("x: struct<a:int>", [Row(x=Row(a=0))]),
1352
- ]:
1353
- with self.subTest(ret_type=ret_type):
1354
- self._check_result_or_exception(TestUDTF, ret_type, expected)
1355
-
1356
- def test_struct_output_type_casting_dict(self):
1357
- class TestUDTF:
1358
- def eval(self):
1359
- yield {"a": 0, "b": 1.1, "c": 2},
1360
-
1361
- err = "UDTF_ARROW_TYPE_CAST_ERROR"
1362
-
1363
- for ret_type, expected in [
1364
- ("x: boolean", err),
1365
- ("x: tinyint", err),
1366
- ("x: smallint", err),
1367
- ("x: int", err),
1368
- ("x: bigint", err),
1369
- ("x: string", err),
1370
- ("x: date", err),
1371
- ("x: timestamp", err),
1372
- ("x: byte", err),
1373
- ("x: binary", err),
1374
- ("x: float", err),
1375
- ("x: double", err),
1376
- ("x: decimal(10, 0)", err),
1377
- ("x: array<string>", [Row(x=["a", "b", "c"])]),
1378
- ("x: map<string,string>", err),
1379
- ("x: struct<a:string,b:string,c:string>", [Row(Row(a="0", b="1.1", c="2"))]),
1380
- ("x: struct<a:int,b:int,c:int>", [Row(Row(a=0, b=1, c=2))]),
1381
- ("x: struct<a:float,b:float,c:float>", [Row(Row(a=0, b=1.1, c=2))]),
1382
- ("x: struct<a:struct<>,b:struct<>,c:struct<>>", err),
1383
- ]:
1384
- with self.subTest(ret_type=ret_type):
1385
- self._check_result_or_exception(TestUDTF, ret_type, expected)
1386
-
1387
- def test_struct_output_type_casting_row(self):
1388
- class TestUDTF:
1389
- def eval(self):
1390
- yield Row(a=0, b=1.1, c=2),
1391
-
1392
- err = "UDTF_ARROW_TYPE_CAST_ERROR"
1393
-
1394
- for ret_type, expected in [
1395
- ("x: boolean", err),
1396
- ("x: tinyint", err),
1397
- ("x: smallint", err),
1398
- ("x: int", err),
1399
- ("x: bigint", err),
1400
- ("x: string", err),
1401
- ("x: date", err),
1402
- ("x: timestamp", err),
1403
- ("x: byte", err),
1404
- ("x: binary", err),
1405
- ("x: float", err),
1406
- ("x: double", err),
1407
- ("x: decimal(10, 0)", err),
1408
- ("x: array<string>", [Row(x=["0", "1.1", "2"])]),
1409
- ("x: map<string,string>", err),
1410
- ("x: struct<a:string,b:string,c:string>", [Row(Row(a="0", b="1.1", c="2"))]),
1411
- ("x: struct<a:int,b:int,c:int>", [Row(Row(a=0, b=1, c=2))]),
1412
- ("x: struct<a:float,b:float,c:float>", [Row(Row(a=0, b=1.1, c=2))]),
1413
- ("x: struct<a:struct<>,b:struct<>,c:struct<>>", err),
1414
- ]:
1415
- with self.subTest(ret_type=ret_type):
1416
- self._check_result_or_exception(TestUDTF, ret_type, expected)
1417
-
1418
- def test_inconsistent_output_types(self):
1419
- class TestUDTF:
1420
- def eval(self):
1421
- yield 1,
1422
- yield [1, 2],
1423
-
1424
- for ret_type in [
1425
- "x: int",
1426
- "x: array<int>",
1427
- ]:
1428
- with self.subTest(ret_type=ret_type):
1429
- with self.assertRaisesRegex(PythonException, "UDTF_ARROW_TYPE_CAST_ERROR"):
1430
- udtf(TestUDTF, returnType=ret_type)().collect()
1431
-
1432
-
1433
- class UDTFArrowTests(UDTFArrowTestsMixin, ReusedSQLTestCase):
1434
- @classmethod
1435
- def setUpClass(cls):
1436
- super(UDTFArrowTests, cls).setUpClass()
1437
- cls.spark.conf.set("spark.sql.execution.pythonUDTF.arrow.enabled", "true")
1438
-
1439
- @classmethod
1440
- def tearDownClass(cls):
1441
- try:
1442
- cls.spark.conf.unset("spark.sql.execution.pythonUDTF.arrow.enabled")
1443
- finally:
1444
- super(UDTFArrowTests, cls).tearDownClass()
1445
-
1446
-
1447
- if __name__ == "__main__":
1448
- from pyspark.sql.tests.test_udtf import * # noqa: F401
1449
-
1450
- try:
1451
- import xmlrunner # type: ignore
1452
-
1453
- testRunner = xmlrunner.XMLTestRunner(output="target/test-reports", verbosity=2)
1454
- except ImportError:
1455
- testRunner = None
1456
- unittest.main(testRunner=testRunner, verbosity=2)