snowpark-connect 0.20.2__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.
- snowflake/snowpark_connect/__init__.py +23 -0
- snowflake/snowpark_connect/analyze_plan/__init__.py +3 -0
- snowflake/snowpark_connect/analyze_plan/map_tree_string.py +38 -0
- snowflake/snowpark_connect/column_name_handler.py +735 -0
- snowflake/snowpark_connect/config.py +576 -0
- snowflake/snowpark_connect/constants.py +47 -0
- snowflake/snowpark_connect/control_server.py +52 -0
- snowflake/snowpark_connect/dataframe_name_handler.py +54 -0
- snowflake/snowpark_connect/date_time_format_mapping.py +399 -0
- snowflake/snowpark_connect/empty_dataframe.py +18 -0
- snowflake/snowpark_connect/error/__init__.py +11 -0
- snowflake/snowpark_connect/error/error_mapping.py +6174 -0
- snowflake/snowpark_connect/error/error_utils.py +321 -0
- snowflake/snowpark_connect/error/exceptions.py +24 -0
- snowflake/snowpark_connect/execute_plan/__init__.py +3 -0
- snowflake/snowpark_connect/execute_plan/map_execution_command.py +204 -0
- snowflake/snowpark_connect/execute_plan/map_execution_root.py +173 -0
- snowflake/snowpark_connect/execute_plan/utils.py +183 -0
- snowflake/snowpark_connect/expression/__init__.py +3 -0
- snowflake/snowpark_connect/expression/literal.py +90 -0
- snowflake/snowpark_connect/expression/map_cast.py +343 -0
- snowflake/snowpark_connect/expression/map_expression.py +293 -0
- snowflake/snowpark_connect/expression/map_extension.py +104 -0
- snowflake/snowpark_connect/expression/map_sql_expression.py +633 -0
- snowflake/snowpark_connect/expression/map_udf.py +142 -0
- snowflake/snowpark_connect/expression/map_unresolved_attribute.py +241 -0
- snowflake/snowpark_connect/expression/map_unresolved_extract_value.py +85 -0
- snowflake/snowpark_connect/expression/map_unresolved_function.py +9450 -0
- snowflake/snowpark_connect/expression/map_unresolved_star.py +218 -0
- snowflake/snowpark_connect/expression/map_update_fields.py +164 -0
- snowflake/snowpark_connect/expression/map_window_function.py +258 -0
- snowflake/snowpark_connect/expression/typer.py +125 -0
- snowflake/snowpark_connect/includes/__init__.py +0 -0
- snowflake/snowpark_connect/includes/jars/antlr4-runtime-4.9.3.jar +0 -0
- snowflake/snowpark_connect/includes/jars/commons-cli-1.5.0.jar +0 -0
- snowflake/snowpark_connect/includes/jars/commons-codec-1.16.1.jar +0 -0
- snowflake/snowpark_connect/includes/jars/commons-collections-3.2.2.jar +0 -0
- snowflake/snowpark_connect/includes/jars/commons-collections4-4.4.jar +0 -0
- snowflake/snowpark_connect/includes/jars/commons-compiler-3.1.9.jar +0 -0
- snowflake/snowpark_connect/includes/jars/commons-compress-1.26.0.jar +0 -0
- snowflake/snowpark_connect/includes/jars/commons-crypto-1.1.0.jar +0 -0
- snowflake/snowpark_connect/includes/jars/commons-dbcp-1.4.jar +0 -0
- snowflake/snowpark_connect/includes/jars/commons-io-2.16.1.jar +0 -0
- snowflake/snowpark_connect/includes/jars/commons-lang-2.6.jar +0 -0
- snowflake/snowpark_connect/includes/jars/commons-lang3-3.12.0.jar +0 -0
- snowflake/snowpark_connect/includes/jars/commons-logging-1.1.3.jar +0 -0
- snowflake/snowpark_connect/includes/jars/commons-math3-3.6.1.jar +0 -0
- snowflake/snowpark_connect/includes/jars/commons-pool-1.5.4.jar +0 -0
- snowflake/snowpark_connect/includes/jars/commons-text-1.10.0.jar +0 -0
- snowflake/snowpark_connect/includes/jars/hadoop-client-api-3.3.4.jar +0 -0
- snowflake/snowpark_connect/includes/jars/jackson-annotations-2.15.2.jar +0 -0
- snowflake/snowpark_connect/includes/jars/jackson-core-2.15.2.jar +0 -0
- snowflake/snowpark_connect/includes/jars/jackson-core-asl-1.9.13.jar +0 -0
- snowflake/snowpark_connect/includes/jars/jackson-databind-2.15.2.jar +0 -0
- snowflake/snowpark_connect/includes/jars/jackson-dataformat-yaml-2.15.2.jar +0 -0
- snowflake/snowpark_connect/includes/jars/jackson-datatype-jsr310-2.15.2.jar +0 -0
- snowflake/snowpark_connect/includes/jars/jackson-mapper-asl-1.9.13.jar +0 -0
- snowflake/snowpark_connect/includes/jars/jackson-module-scala_2.12-2.15.2.jar +0 -0
- snowflake/snowpark_connect/includes/jars/json4s-ast_2.12-3.7.0-M11.jar +0 -0
- snowflake/snowpark_connect/includes/jars/json4s-core_2.12-3.7.0-M11.jar +0 -0
- snowflake/snowpark_connect/includes/jars/json4s-jackson_2.12-3.7.0-M11.jar +0 -0
- snowflake/snowpark_connect/includes/jars/json4s-scalap_2.12-3.7.0-M11.jar +0 -0
- snowflake/snowpark_connect/includes/jars/kryo-shaded-4.0.2.jar +0 -0
- snowflake/snowpark_connect/includes/jars/log4j-1.2-api-2.20.0.jar +0 -0
- snowflake/snowpark_connect/includes/jars/log4j-api-2.20.0.jar +0 -0
- snowflake/snowpark_connect/includes/jars/log4j-core-2.20.0.jar +0 -0
- snowflake/snowpark_connect/includes/jars/log4j-slf4j2-impl-2.20.0.jar +0 -0
- snowflake/snowpark_connect/includes/jars/paranamer-2.8.jar +0 -0
- snowflake/snowpark_connect/includes/jars/scala-collection-compat_2.12-2.7.0.jar +0 -0
- snowflake/snowpark_connect/includes/jars/scala-compiler-2.12.18.jar +0 -0
- snowflake/snowpark_connect/includes/jars/scala-library-2.12.18.jar +0 -0
- snowflake/snowpark_connect/includes/jars/scala-parser-combinators_2.12-2.3.0.jar +0 -0
- snowflake/snowpark_connect/includes/jars/scala-reflect-2.12.18.jar +0 -0
- snowflake/snowpark_connect/includes/jars/scala-xml_2.12-2.1.0.jar +0 -0
- snowflake/snowpark_connect/includes/jars/slf4j-api-2.0.7.jar +0 -0
- snowflake/snowpark_connect/includes/jars/spark-catalyst_2.12-3.5.6.jar +0 -0
- snowflake/snowpark_connect/includes/jars/spark-common-utils_2.12-3.5.6.jar +0 -0
- snowflake/snowpark_connect/includes/jars/spark-core_2.12-3.5.6.jar +0 -0
- snowflake/snowpark_connect/includes/jars/spark-graphx_2.12-3.5.6.jar +0 -0
- snowflake/snowpark_connect/includes/jars/spark-hive-thriftserver_2.12-3.5.6.jar +0 -0
- snowflake/snowpark_connect/includes/jars/spark-hive_2.12-3.5.6.jar +0 -0
- snowflake/snowpark_connect/includes/jars/spark-kubernetes_2.12-3.5.6.jar +0 -0
- snowflake/snowpark_connect/includes/jars/spark-kvstore_2.12-3.5.6.jar +0 -0
- snowflake/snowpark_connect/includes/jars/spark-launcher_2.12-3.5.6.jar +0 -0
- snowflake/snowpark_connect/includes/jars/spark-mesos_2.12-3.5.6.jar +0 -0
- snowflake/snowpark_connect/includes/jars/spark-mllib-local_2.12-3.5.6.jar +0 -0
- snowflake/snowpark_connect/includes/jars/spark-mllib_2.12-3.5.6.jar +0 -0
- snowflake/snowpark_connect/includes/jars/spark-network-common_2.12-3.5.6.jar +0 -0
- snowflake/snowpark_connect/includes/jars/spark-network-shuffle_2.12-3.5.6.jar +0 -0
- snowflake/snowpark_connect/includes/jars/spark-repl_2.12-3.5.6.jar +0 -0
- snowflake/snowpark_connect/includes/jars/spark-sketch_2.12-3.5.6.jar +0 -0
- snowflake/snowpark_connect/includes/jars/spark-sql-api_2.12-3.5.6.jar +0 -0
- snowflake/snowpark_connect/includes/jars/spark-sql_2.12-3.5.6.jar +0 -0
- snowflake/snowpark_connect/includes/jars/spark-streaming_2.12-3.5.6.jar +0 -0
- snowflake/snowpark_connect/includes/jars/spark-tags_2.12-3.5.6.jar +0 -0
- snowflake/snowpark_connect/includes/jars/spark-unsafe_2.12-3.5.6.jar +0 -0
- snowflake/snowpark_connect/includes/jars/spark-yarn_2.12-3.5.6.jar +0 -0
- snowflake/snowpark_connect/includes/python/__init__.py +21 -0
- snowflake/snowpark_connect/includes/python/pyspark/__init__.py +173 -0
- snowflake/snowpark_connect/includes/python/pyspark/_globals.py +71 -0
- snowflake/snowpark_connect/includes/python/pyspark/_typing.pyi +43 -0
- snowflake/snowpark_connect/includes/python/pyspark/accumulators.py +341 -0
- snowflake/snowpark_connect/includes/python/pyspark/broadcast.py +383 -0
- snowflake/snowpark_connect/includes/python/pyspark/cloudpickle/__init__.py +8 -0
- snowflake/snowpark_connect/includes/python/pyspark/cloudpickle/cloudpickle.py +948 -0
- snowflake/snowpark_connect/includes/python/pyspark/cloudpickle/cloudpickle_fast.py +844 -0
- snowflake/snowpark_connect/includes/python/pyspark/cloudpickle/compat.py +18 -0
- snowflake/snowpark_connect/includes/python/pyspark/conf.py +276 -0
- snowflake/snowpark_connect/includes/python/pyspark/context.py +2601 -0
- snowflake/snowpark_connect/includes/python/pyspark/daemon.py +218 -0
- snowflake/snowpark_connect/includes/python/pyspark/errors/__init__.py +70 -0
- snowflake/snowpark_connect/includes/python/pyspark/errors/error_classes.py +889 -0
- snowflake/snowpark_connect/includes/python/pyspark/errors/exceptions/__init__.py +16 -0
- snowflake/snowpark_connect/includes/python/pyspark/errors/exceptions/base.py +228 -0
- snowflake/snowpark_connect/includes/python/pyspark/errors/exceptions/captured.py +307 -0
- snowflake/snowpark_connect/includes/python/pyspark/errors/exceptions/connect.py +190 -0
- snowflake/snowpark_connect/includes/python/pyspark/errors/tests/__init__.py +16 -0
- snowflake/snowpark_connect/includes/python/pyspark/errors/tests/test_errors.py +60 -0
- snowflake/snowpark_connect/includes/python/pyspark/errors/utils.py +116 -0
- snowflake/snowpark_connect/includes/python/pyspark/files.py +165 -0
- snowflake/snowpark_connect/includes/python/pyspark/find_spark_home.py +95 -0
- snowflake/snowpark_connect/includes/python/pyspark/install.py +203 -0
- snowflake/snowpark_connect/includes/python/pyspark/instrumentation_utils.py +190 -0
- snowflake/snowpark_connect/includes/python/pyspark/java_gateway.py +248 -0
- snowflake/snowpark_connect/includes/python/pyspark/join.py +118 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/__init__.py +71 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/_typing.pyi +84 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/base.py +414 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/classification.py +4332 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/clustering.py +2188 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/common.py +146 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/connect/__init__.py +44 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/connect/base.py +346 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/connect/classification.py +382 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/connect/evaluation.py +291 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/connect/feature.py +258 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/connect/functions.py +77 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/connect/io_utils.py +335 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/connect/pipeline.py +262 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/connect/summarizer.py +120 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/connect/tuning.py +579 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/connect/util.py +173 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/deepspeed/__init__.py +16 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/deepspeed/deepspeed_distributor.py +165 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/deepspeed/tests/test_deepspeed_distributor.py +306 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/dl_util.py +150 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/evaluation.py +1166 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/feature.py +7474 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/fpm.py +543 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/functions.py +842 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/image.py +271 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/linalg/__init__.py +1382 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/model_cache.py +55 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/param/__init__.py +602 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/param/_shared_params_code_gen.py +368 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/param/shared.py +878 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/pipeline.py +451 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/recommendation.py +748 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/regression.py +3335 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/stat.py +523 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/tests/__init__.py +16 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/tests/connect/test_connect_classification.py +53 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/tests/connect/test_connect_evaluation.py +50 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/tests/connect/test_connect_feature.py +43 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/tests/connect/test_connect_function.py +114 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/tests/connect/test_connect_pipeline.py +47 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/tests/connect/test_connect_summarizer.py +43 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/tests/connect/test_connect_tuning.py +46 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/tests/connect/test_legacy_mode_classification.py +238 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/tests/connect/test_legacy_mode_evaluation.py +194 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/tests/connect/test_legacy_mode_feature.py +156 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/tests/connect/test_legacy_mode_pipeline.py +184 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/tests/connect/test_legacy_mode_summarizer.py +78 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/tests/connect/test_legacy_mode_tuning.py +292 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/tests/connect/test_parity_torch_data_loader.py +50 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/tests/connect/test_parity_torch_distributor.py +152 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/tests/test_algorithms.py +456 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/tests/test_base.py +96 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/tests/test_dl_util.py +186 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/tests/test_evaluation.py +77 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/tests/test_feature.py +401 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/tests/test_functions.py +528 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/tests/test_image.py +82 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/tests/test_linalg.py +409 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/tests/test_model_cache.py +55 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/tests/test_param.py +441 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/tests/test_persistence.py +546 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/tests/test_pipeline.py +71 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/tests/test_stat.py +52 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/tests/test_training_summary.py +494 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/tests/test_util.py +85 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/tests/test_wrapper.py +138 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/tests/tuning/__init__.py +16 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/tests/tuning/test_cv_io_basic.py +151 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/tests/tuning/test_cv_io_nested.py +97 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/tests/tuning/test_cv_io_pipeline.py +143 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/tests/tuning/test_tuning.py +551 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/tests/tuning/test_tvs_io_basic.py +137 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/tests/tuning/test_tvs_io_nested.py +96 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/tests/tuning/test_tvs_io_pipeline.py +142 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/torch/__init__.py +16 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/torch/data.py +100 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/torch/distributor.py +1133 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/torch/log_communication.py +198 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/torch/tests/__init__.py +16 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/torch/tests/test_data_loader.py +137 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/torch/tests/test_distributor.py +561 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/torch/tests/test_log_communication.py +172 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/torch/torch_run_process_wrapper.py +83 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/tree.py +434 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/tuning.py +1741 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/util.py +749 -0
- snowflake/snowpark_connect/includes/python/pyspark/ml/wrapper.py +465 -0
- snowflake/snowpark_connect/includes/python/pyspark/mllib/__init__.py +44 -0
- snowflake/snowpark_connect/includes/python/pyspark/mllib/_typing.pyi +33 -0
- snowflake/snowpark_connect/includes/python/pyspark/mllib/classification.py +989 -0
- snowflake/snowpark_connect/includes/python/pyspark/mllib/clustering.py +1318 -0
- snowflake/snowpark_connect/includes/python/pyspark/mllib/common.py +174 -0
- snowflake/snowpark_connect/includes/python/pyspark/mllib/evaluation.py +691 -0
- snowflake/snowpark_connect/includes/python/pyspark/mllib/feature.py +1085 -0
- snowflake/snowpark_connect/includes/python/pyspark/mllib/fpm.py +233 -0
- snowflake/snowpark_connect/includes/python/pyspark/mllib/linalg/__init__.py +1653 -0
- snowflake/snowpark_connect/includes/python/pyspark/mllib/linalg/distributed.py +1662 -0
- snowflake/snowpark_connect/includes/python/pyspark/mllib/random.py +698 -0
- snowflake/snowpark_connect/includes/python/pyspark/mllib/recommendation.py +389 -0
- snowflake/snowpark_connect/includes/python/pyspark/mllib/regression.py +1067 -0
- snowflake/snowpark_connect/includes/python/pyspark/mllib/stat/KernelDensity.py +59 -0
- snowflake/snowpark_connect/includes/python/pyspark/mllib/stat/__init__.py +34 -0
- snowflake/snowpark_connect/includes/python/pyspark/mllib/stat/_statistics.py +409 -0
- snowflake/snowpark_connect/includes/python/pyspark/mllib/stat/distribution.py +39 -0
- snowflake/snowpark_connect/includes/python/pyspark/mllib/stat/test.py +86 -0
- snowflake/snowpark_connect/includes/python/pyspark/mllib/tests/__init__.py +16 -0
- snowflake/snowpark_connect/includes/python/pyspark/mllib/tests/test_algorithms.py +353 -0
- snowflake/snowpark_connect/includes/python/pyspark/mllib/tests/test_feature.py +192 -0
- snowflake/snowpark_connect/includes/python/pyspark/mllib/tests/test_linalg.py +680 -0
- snowflake/snowpark_connect/includes/python/pyspark/mllib/tests/test_stat.py +206 -0
- snowflake/snowpark_connect/includes/python/pyspark/mllib/tests/test_streaming_algorithms.py +471 -0
- snowflake/snowpark_connect/includes/python/pyspark/mllib/tests/test_util.py +108 -0
- snowflake/snowpark_connect/includes/python/pyspark/mllib/tree.py +888 -0
- snowflake/snowpark_connect/includes/python/pyspark/mllib/util.py +659 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/__init__.py +165 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/_typing.py +52 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/accessors.py +989 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/base.py +1804 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/categorical.py +822 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/config.py +539 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/correlation.py +262 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/data_type_ops/__init__.py +16 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/data_type_ops/base.py +519 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/data_type_ops/binary_ops.py +98 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/data_type_ops/boolean_ops.py +426 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/data_type_ops/categorical_ops.py +141 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/data_type_ops/complex_ops.py +145 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/data_type_ops/date_ops.py +127 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/data_type_ops/datetime_ops.py +171 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/data_type_ops/null_ops.py +83 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/data_type_ops/num_ops.py +588 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/data_type_ops/string_ops.py +154 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/data_type_ops/timedelta_ops.py +101 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/data_type_ops/udt_ops.py +29 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/datetimes.py +891 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/exceptions.py +150 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/extensions.py +388 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/frame.py +13738 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/generic.py +3560 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/groupby.py +4448 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/indexes/__init__.py +21 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/indexes/base.py +2783 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/indexes/category.py +773 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/indexes/datetimes.py +843 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/indexes/multi.py +1323 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/indexes/numeric.py +210 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/indexes/timedelta.py +197 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/indexing.py +1862 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/internal.py +1680 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/missing/__init__.py +48 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/missing/common.py +76 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/missing/frame.py +63 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/missing/general_functions.py +43 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/missing/groupby.py +93 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/missing/indexes.py +184 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/missing/resample.py +101 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/missing/scalars.py +29 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/missing/series.py +69 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/missing/window.py +168 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/mlflow.py +238 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/namespace.py +3807 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/numpy_compat.py +260 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/plot/__init__.py +17 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/plot/core.py +1213 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/plot/matplotlib.py +928 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/plot/plotly.py +261 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/resample.py +816 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/series.py +7440 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/sql_formatter.py +308 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/sql_processor.py +394 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/strings.py +2371 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/supported_api_gen.py +378 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/__init__.py +16 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/computation/__init__.py +16 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/computation/test_any_all.py +177 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/computation/test_apply_func.py +575 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/computation/test_binary_ops.py +235 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/computation/test_combine.py +653 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/computation/test_compute.py +463 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/computation/test_corrwith.py +86 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/computation/test_cov.py +151 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/computation/test_cumulative.py +139 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/computation/test_describe.py +458 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/computation/test_eval.py +86 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/computation/test_melt.py +202 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/computation/test_missing_data.py +520 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/computation/test_pivot.py +361 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/__init__.py +16 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/computation/__init__.py +16 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/computation/test_parity_any_all.py +40 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/computation/test_parity_apply_func.py +42 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/computation/test_parity_binary_ops.py +40 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/computation/test_parity_combine.py +37 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/computation/test_parity_compute.py +60 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/computation/test_parity_corrwith.py +40 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/computation/test_parity_cov.py +40 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/computation/test_parity_cumulative.py +90 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/computation/test_parity_describe.py +40 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/computation/test_parity_eval.py +40 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/computation/test_parity_melt.py +40 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/computation/test_parity_missing_data.py +42 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/computation/test_parity_pivot.py +37 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/data_type_ops/__init__.py +16 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/data_type_ops/test_parity_base.py +36 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/data_type_ops/test_parity_binary_ops.py +42 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/data_type_ops/test_parity_boolean_ops.py +47 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/data_type_ops/test_parity_categorical_ops.py +55 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/data_type_ops/test_parity_complex_ops.py +40 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/data_type_ops/test_parity_date_ops.py +47 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/data_type_ops/test_parity_datetime_ops.py +47 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/data_type_ops/test_parity_null_ops.py +42 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/data_type_ops/test_parity_num_arithmetic.py +43 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/data_type_ops/test_parity_num_ops.py +47 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/data_type_ops/test_parity_num_reverse.py +43 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/data_type_ops/test_parity_string_ops.py +47 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/data_type_ops/test_parity_timedelta_ops.py +47 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/data_type_ops/test_parity_udt_ops.py +40 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/data_type_ops/testing_utils.py +226 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/diff_frames_ops/__init__.py +16 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/diff_frames_ops/test_parity_align.py +39 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/diff_frames_ops/test_parity_basic_slow.py +55 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/diff_frames_ops/test_parity_cov_corrwith.py +39 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/diff_frames_ops/test_parity_dot_frame.py +39 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/diff_frames_ops/test_parity_dot_series.py +39 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/diff_frames_ops/test_parity_index.py +39 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/diff_frames_ops/test_parity_series.py +39 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/diff_frames_ops/test_parity_setitem_frame.py +43 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/diff_frames_ops/test_parity_setitem_series.py +43 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/frame/__init__.py +16 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/frame/test_parity_attrs.py +40 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/frame/test_parity_constructor.py +39 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/frame/test_parity_conversion.py +42 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/frame/test_parity_reindexing.py +42 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/frame/test_parity_reshaping.py +37 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/frame/test_parity_spark.py +40 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/frame/test_parity_take.py +42 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/frame/test_parity_time_series.py +48 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/frame/test_parity_truncate.py +40 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/groupby/__init__.py +16 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/groupby/test_parity_aggregate.py +40 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/groupby/test_parity_apply_func.py +41 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/groupby/test_parity_cumulative.py +67 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/groupby/test_parity_describe.py +40 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/groupby/test_parity_groupby.py +55 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/groupby/test_parity_head_tail.py +40 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/groupby/test_parity_index.py +38 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/groupby/test_parity_missing_data.py +55 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/groupby/test_parity_split_apply.py +39 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/groupby/test_parity_stat.py +38 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/indexes/__init__.py +16 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/indexes/test_parity_align.py +40 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/indexes/test_parity_base.py +50 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/indexes/test_parity_category.py +73 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/indexes/test_parity_datetime.py +39 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/indexes/test_parity_indexing.py +40 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/indexes/test_parity_reindex.py +40 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/indexes/test_parity_rename.py +40 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/indexes/test_parity_reset_index.py +48 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/indexes/test_parity_timedelta.py +39 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/io/__init__.py +16 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/io/test_parity_io.py +40 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/plot/__init__.py +16 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/plot/test_parity_frame_plot.py +45 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/plot/test_parity_frame_plot_matplotlib.py +45 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/plot/test_parity_frame_plot_plotly.py +49 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/plot/test_parity_series_plot.py +37 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/plot/test_parity_series_plot_matplotlib.py +53 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/plot/test_parity_series_plot_plotly.py +45 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/series/__init__.py +16 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/series/test_parity_all_any.py +38 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/series/test_parity_arg_ops.py +37 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/series/test_parity_as_of.py +37 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/series/test_parity_as_type.py +38 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/series/test_parity_compute.py +37 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/series/test_parity_conversion.py +40 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/series/test_parity_cumulative.py +40 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/series/test_parity_index.py +38 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/series/test_parity_missing_data.py +40 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/series/test_parity_series.py +37 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/series/test_parity_sort.py +38 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/series/test_parity_stat.py +38 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_categorical.py +66 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_config.py +37 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_csv.py +37 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_dataframe_conversion.py +42 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_dataframe_spark_io.py +39 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_default_index.py +49 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_ewm.py +37 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_expanding.py +39 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_extension.py +49 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_frame_spark.py +53 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_generic_functions.py +43 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_indexing.py +49 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_indexops_spark.py +39 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_internal.py +41 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_namespace.py +39 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_numpy_compat.py +60 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_ops_on_diff_frames.py +48 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_ops_on_diff_frames_groupby.py +39 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_ops_on_diff_frames_groupby_expanding.py +44 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_ops_on_diff_frames_groupby_rolling.py +84 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_repr.py +37 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_resample.py +45 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_reshape.py +39 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_rolling.py +39 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_scalars.py +37 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_series_conversion.py +39 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_series_datetime.py +39 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_series_string.py +39 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_spark_functions.py +39 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_sql.py +43 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_stats.py +37 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_typedef.py +36 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_utils.py +37 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/connect/test_parity_window.py +39 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/data_type_ops/__init__.py +16 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/data_type_ops/test_base.py +107 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/data_type_ops/test_binary_ops.py +224 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/data_type_ops/test_boolean_ops.py +825 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/data_type_ops/test_categorical_ops.py +562 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/data_type_ops/test_complex_ops.py +368 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/data_type_ops/test_date_ops.py +257 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/data_type_ops/test_datetime_ops.py +260 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/data_type_ops/test_null_ops.py +178 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/data_type_ops/test_num_arithmetic.py +184 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/data_type_ops/test_num_ops.py +497 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/data_type_ops/test_num_reverse.py +140 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/data_type_ops/test_string_ops.py +354 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/data_type_ops/test_timedelta_ops.py +219 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/data_type_ops/test_udt_ops.py +192 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/data_type_ops/testing_utils.py +228 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/diff_frames_ops/__init__.py +16 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/diff_frames_ops/test_align.py +118 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/diff_frames_ops/test_basic_slow.py +198 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/diff_frames_ops/test_cov_corrwith.py +181 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/diff_frames_ops/test_dot_frame.py +103 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/diff_frames_ops/test_dot_series.py +141 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/diff_frames_ops/test_index.py +109 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/diff_frames_ops/test_series.py +136 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/diff_frames_ops/test_setitem_frame.py +125 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/diff_frames_ops/test_setitem_series.py +217 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/frame/__init__.py +16 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/frame/test_attrs.py +384 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/frame/test_constructor.py +598 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/frame/test_conversion.py +73 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/frame/test_reindexing.py +869 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/frame/test_reshaping.py +487 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/frame/test_spark.py +309 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/frame/test_take.py +156 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/frame/test_time_series.py +149 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/frame/test_truncate.py +163 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/groupby/__init__.py +16 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/groupby/test_aggregate.py +311 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/groupby/test_apply_func.py +524 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/groupby/test_cumulative.py +419 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/groupby/test_describe.py +144 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/groupby/test_groupby.py +979 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/groupby/test_head_tail.py +234 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/groupby/test_index.py +206 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/groupby/test_missing_data.py +421 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/groupby/test_split_apply.py +187 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/groupby/test_stat.py +397 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/indexes/__init__.py +16 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/indexes/test_align.py +100 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/indexes/test_base.py +2743 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/indexes/test_category.py +484 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/indexes/test_datetime.py +276 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/indexes/test_indexing.py +432 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/indexes/test_reindex.py +310 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/indexes/test_rename.py +257 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/indexes/test_reset_index.py +160 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/indexes/test_timedelta.py +128 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/io/__init__.py +16 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/io/test_io.py +137 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/plot/__init__.py +16 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/plot/test_frame_plot.py +170 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/plot/test_frame_plot_matplotlib.py +547 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/plot/test_frame_plot_plotly.py +285 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/plot/test_series_plot.py +106 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/plot/test_series_plot_matplotlib.py +409 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/plot/test_series_plot_plotly.py +247 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/series/__init__.py +16 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/series/test_all_any.py +105 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/series/test_arg_ops.py +197 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/series/test_as_of.py +137 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/series/test_as_type.py +227 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/series/test_compute.py +634 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/series/test_conversion.py +88 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/series/test_cumulative.py +139 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/series/test_index.py +475 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/series/test_missing_data.py +265 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/series/test_series.py +818 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/series/test_sort.py +162 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/series/test_stat.py +780 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_categorical.py +741 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_config.py +160 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_csv.py +453 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_dataframe_conversion.py +281 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_dataframe_spark_io.py +487 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_default_index.py +109 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_ewm.py +434 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_expanding.py +253 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_extension.py +152 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_frame_spark.py +162 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_generic_functions.py +234 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_indexing.py +1339 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_indexops_spark.py +82 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_internal.py +124 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_namespace.py +638 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_numpy_compat.py +200 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_ops_on_diff_frames.py +1355 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_ops_on_diff_frames_groupby.py +655 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_ops_on_diff_frames_groupby_expanding.py +113 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_ops_on_diff_frames_groupby_rolling.py +118 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_repr.py +192 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_resample.py +346 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_reshape.py +495 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_rolling.py +263 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_scalars.py +59 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_series_conversion.py +85 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_series_datetime.py +364 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_series_string.py +362 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_spark_functions.py +46 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_sql.py +123 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_stats.py +581 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_typedef.py +447 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_utils.py +301 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/tests/test_window.py +465 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/typedef/__init__.py +18 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/typedef/typehints.py +874 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/usage_logging/__init__.py +143 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/usage_logging/usage_logger.py +132 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/utils.py +1063 -0
- snowflake/snowpark_connect/includes/python/pyspark/pandas/window.py +2702 -0
- snowflake/snowpark_connect/includes/python/pyspark/profiler.py +489 -0
- snowflake/snowpark_connect/includes/python/pyspark/py.typed +1 -0
- snowflake/snowpark_connect/includes/python/pyspark/python/pyspark/shell.py +123 -0
- snowflake/snowpark_connect/includes/python/pyspark/rdd.py +5518 -0
- snowflake/snowpark_connect/includes/python/pyspark/rddsampler.py +115 -0
- snowflake/snowpark_connect/includes/python/pyspark/resource/__init__.py +38 -0
- snowflake/snowpark_connect/includes/python/pyspark/resource/information.py +69 -0
- snowflake/snowpark_connect/includes/python/pyspark/resource/profile.py +317 -0
- snowflake/snowpark_connect/includes/python/pyspark/resource/requests.py +539 -0
- snowflake/snowpark_connect/includes/python/pyspark/resource/tests/__init__.py +16 -0
- snowflake/snowpark_connect/includes/python/pyspark/resource/tests/test_resources.py +83 -0
- snowflake/snowpark_connect/includes/python/pyspark/resultiterable.py +45 -0
- snowflake/snowpark_connect/includes/python/pyspark/serializers.py +681 -0
- snowflake/snowpark_connect/includes/python/pyspark/shell.py +123 -0
- snowflake/snowpark_connect/includes/python/pyspark/shuffle.py +854 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/__init__.py +75 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/_typing.pyi +80 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/avro/__init__.py +18 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/avro/functions.py +188 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/catalog.py +1270 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/column.py +1431 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/conf.py +99 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/__init__.py +18 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/_typing.py +90 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/avro/__init__.py +18 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/avro/functions.py +107 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/catalog.py +356 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/client/__init__.py +22 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/client/artifact.py +412 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/client/core.py +1689 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/client/reattach.py +340 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/column.py +514 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/conf.py +128 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/conversion.py +490 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/dataframe.py +2172 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/expressions.py +1056 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/functions.py +3937 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/group.py +418 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/plan.py +2289 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/proto/__init__.py +25 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/proto/base_pb2.py +203 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/proto/base_pb2.pyi +2718 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/proto/base_pb2_grpc.py +423 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/proto/catalog_pb2.py +109 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/proto/catalog_pb2.pyi +1130 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/proto/commands_pb2.py +141 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/proto/commands_pb2.pyi +1766 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/proto/common_pb2.py +47 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/proto/common_pb2.pyi +123 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/proto/example_plugins_pb2.py +53 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/proto/example_plugins_pb2.pyi +112 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/proto/expressions_pb2.py +107 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/proto/expressions_pb2.pyi +1507 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/proto/relations_pb2.py +195 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/proto/relations_pb2.pyi +3613 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/proto/types_pb2.py +95 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/proto/types_pb2.pyi +980 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/protobuf/__init__.py +18 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/protobuf/functions.py +166 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/readwriter.py +861 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/session.py +952 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/streaming/__init__.py +22 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/streaming/query.py +295 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/streaming/readwriter.py +618 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/streaming/worker/__init__.py +18 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/streaming/worker/foreach_batch_worker.py +87 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/streaming/worker/listener_worker.py +100 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/types.py +301 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/udf.py +296 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/udtf.py +200 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/utils.py +58 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/connect/window.py +266 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/context.py +818 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/dataframe.py +5973 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/functions.py +15889 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/group.py +547 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/observation.py +152 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/pandas/__init__.py +21 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/pandas/_typing/__init__.pyi +344 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/pandas/_typing/protocols/__init__.pyi +17 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/pandas/_typing/protocols/frame.pyi +20 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/pandas/_typing/protocols/series.pyi +20 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/pandas/conversion.py +671 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/pandas/functions.py +480 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/pandas/functions.pyi +132 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/pandas/group_ops.py +523 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/pandas/map_ops.py +216 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/pandas/serializers.py +1019 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/pandas/typehints.py +172 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/pandas/types.py +972 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/pandas/utils.py +86 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/protobuf/__init__.py +18 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/protobuf/functions.py +334 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/readwriter.py +2159 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/session.py +2088 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/sql_formatter.py +84 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/streaming/__init__.py +21 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/streaming/listener.py +1050 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/streaming/query.py +746 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/streaming/readwriter.py +1652 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/streaming/state.py +288 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/__init__.py +16 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/__init__.py +16 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/client/__init__.py +16 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/client/test_artifact.py +420 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/client/test_client.py +358 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/streaming/__init__.py +16 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/streaming/test_parity_foreach.py +36 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/streaming/test_parity_foreach_batch.py +44 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/streaming/test_parity_listener.py +116 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/streaming/test_parity_streaming.py +35 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_connect_basic.py +3612 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_connect_column.py +1042 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_connect_function.py +2381 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_connect_plan.py +1060 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_arrow.py +163 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_arrow_map.py +38 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_arrow_python_udf.py +48 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_catalog.py +36 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_column.py +55 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_conf.py +36 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_dataframe.py +96 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_datasources.py +44 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_errors.py +36 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_functions.py +59 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_group.py +36 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_pandas_cogrouped_map.py +59 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_pandas_grouped_map.py +74 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_pandas_grouped_map_with_state.py +62 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_pandas_map.py +58 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_pandas_udf.py +70 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_pandas_udf_grouped_agg.py +50 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_pandas_udf_scalar.py +68 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_pandas_udf_window.py +40 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_readwriter.py +46 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_serde.py +44 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_types.py +100 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_udf.py +100 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_parity_udtf.py +163 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_session.py +181 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/connect/test_utils.py +42 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/pandas/__init__.py +16 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/pandas/test_pandas_cogrouped_map.py +623 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/pandas/test_pandas_grouped_map.py +869 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/pandas/test_pandas_grouped_map_with_state.py +342 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/pandas/test_pandas_map.py +436 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/pandas/test_pandas_udf.py +363 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/pandas/test_pandas_udf_grouped_agg.py +592 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/pandas/test_pandas_udf_scalar.py +1503 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/pandas/test_pandas_udf_typehints.py +392 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/pandas/test_pandas_udf_typehints_with_future_annotations.py +375 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/pandas/test_pandas_udf_window.py +411 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/streaming/__init__.py +16 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/streaming/test_streaming.py +401 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/streaming/test_streaming_foreach.py +295 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/streaming/test_streaming_foreach_batch.py +106 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/streaming/test_streaming_listener.py +558 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/test_arrow.py +1346 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/test_arrow_map.py +182 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/test_arrow_python_udf.py +202 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/test_catalog.py +503 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/test_column.py +225 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/test_conf.py +83 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/test_context.py +201 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/test_dataframe.py +1931 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/test_datasources.py +256 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/test_errors.py +69 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/test_functions.py +1349 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/test_group.py +53 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/test_pandas_sqlmetrics.py +68 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/test_readwriter.py +283 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/test_serde.py +155 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/test_session.py +412 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/test_types.py +1581 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/test_udf.py +961 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/test_udf_profiler.py +165 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/test_udtf.py +1456 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/tests/test_utils.py +1686 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/types.py +2558 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/udf.py +714 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/udtf.py +325 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/utils.py +339 -0
- snowflake/snowpark_connect/includes/python/pyspark/sql/window.py +492 -0
- snowflake/snowpark_connect/includes/python/pyspark/statcounter.py +165 -0
- snowflake/snowpark_connect/includes/python/pyspark/status.py +112 -0
- snowflake/snowpark_connect/includes/python/pyspark/storagelevel.py +97 -0
- snowflake/snowpark_connect/includes/python/pyspark/streaming/__init__.py +22 -0
- snowflake/snowpark_connect/includes/python/pyspark/streaming/context.py +471 -0
- snowflake/snowpark_connect/includes/python/pyspark/streaming/dstream.py +933 -0
- snowflake/snowpark_connect/includes/python/pyspark/streaming/kinesis.py +205 -0
- snowflake/snowpark_connect/includes/python/pyspark/streaming/listener.py +83 -0
- snowflake/snowpark_connect/includes/python/pyspark/streaming/tests/__init__.py +16 -0
- snowflake/snowpark_connect/includes/python/pyspark/streaming/tests/test_context.py +184 -0
- snowflake/snowpark_connect/includes/python/pyspark/streaming/tests/test_dstream.py +706 -0
- snowflake/snowpark_connect/includes/python/pyspark/streaming/tests/test_kinesis.py +118 -0
- snowflake/snowpark_connect/includes/python/pyspark/streaming/tests/test_listener.py +160 -0
- snowflake/snowpark_connect/includes/python/pyspark/streaming/util.py +168 -0
- snowflake/snowpark_connect/includes/python/pyspark/taskcontext.py +502 -0
- snowflake/snowpark_connect/includes/python/pyspark/testing/__init__.py +21 -0
- snowflake/snowpark_connect/includes/python/pyspark/testing/connectutils.py +199 -0
- snowflake/snowpark_connect/includes/python/pyspark/testing/mllibutils.py +30 -0
- snowflake/snowpark_connect/includes/python/pyspark/testing/mlutils.py +275 -0
- snowflake/snowpark_connect/includes/python/pyspark/testing/objects.py +121 -0
- snowflake/snowpark_connect/includes/python/pyspark/testing/pandasutils.py +714 -0
- snowflake/snowpark_connect/includes/python/pyspark/testing/sqlutils.py +168 -0
- snowflake/snowpark_connect/includes/python/pyspark/testing/streamingutils.py +178 -0
- snowflake/snowpark_connect/includes/python/pyspark/testing/utils.py +636 -0
- snowflake/snowpark_connect/includes/python/pyspark/tests/__init__.py +16 -0
- snowflake/snowpark_connect/includes/python/pyspark/tests/test_appsubmit.py +306 -0
- snowflake/snowpark_connect/includes/python/pyspark/tests/test_broadcast.py +196 -0
- snowflake/snowpark_connect/includes/python/pyspark/tests/test_conf.py +44 -0
- snowflake/snowpark_connect/includes/python/pyspark/tests/test_context.py +346 -0
- snowflake/snowpark_connect/includes/python/pyspark/tests/test_daemon.py +89 -0
- snowflake/snowpark_connect/includes/python/pyspark/tests/test_install_spark.py +124 -0
- snowflake/snowpark_connect/includes/python/pyspark/tests/test_join.py +69 -0
- snowflake/snowpark_connect/includes/python/pyspark/tests/test_memory_profiler.py +167 -0
- snowflake/snowpark_connect/includes/python/pyspark/tests/test_pin_thread.py +194 -0
- snowflake/snowpark_connect/includes/python/pyspark/tests/test_profiler.py +168 -0
- snowflake/snowpark_connect/includes/python/pyspark/tests/test_rdd.py +939 -0
- snowflake/snowpark_connect/includes/python/pyspark/tests/test_rddbarrier.py +52 -0
- snowflake/snowpark_connect/includes/python/pyspark/tests/test_rddsampler.py +66 -0
- snowflake/snowpark_connect/includes/python/pyspark/tests/test_readwrite.py +368 -0
- snowflake/snowpark_connect/includes/python/pyspark/tests/test_serializers.py +257 -0
- snowflake/snowpark_connect/includes/python/pyspark/tests/test_shuffle.py +267 -0
- snowflake/snowpark_connect/includes/python/pyspark/tests/test_stage_sched.py +153 -0
- snowflake/snowpark_connect/includes/python/pyspark/tests/test_statcounter.py +130 -0
- snowflake/snowpark_connect/includes/python/pyspark/tests/test_taskcontext.py +350 -0
- snowflake/snowpark_connect/includes/python/pyspark/tests/test_util.py +97 -0
- snowflake/snowpark_connect/includes/python/pyspark/tests/test_worker.py +271 -0
- snowflake/snowpark_connect/includes/python/pyspark/traceback_utils.py +81 -0
- snowflake/snowpark_connect/includes/python/pyspark/util.py +416 -0
- snowflake/snowpark_connect/includes/python/pyspark/version.py +19 -0
- snowflake/snowpark_connect/includes/python/pyspark/worker.py +1307 -0
- snowflake/snowpark_connect/includes/python/pyspark/worker_util.py +46 -0
- snowflake/snowpark_connect/proto/__init__.py +10 -0
- snowflake/snowpark_connect/proto/control_pb2.py +35 -0
- snowflake/snowpark_connect/proto/control_pb2.pyi +38 -0
- snowflake/snowpark_connect/proto/control_pb2_grpc.py +183 -0
- snowflake/snowpark_connect/proto/snowflake_expression_ext_pb2.py +35 -0
- snowflake/snowpark_connect/proto/snowflake_expression_ext_pb2.pyi +53 -0
- snowflake/snowpark_connect/proto/snowflake_rdd_pb2.pyi +39 -0
- snowflake/snowpark_connect/proto/snowflake_relation_ext_pb2.py +47 -0
- snowflake/snowpark_connect/proto/snowflake_relation_ext_pb2.pyi +111 -0
- snowflake/snowpark_connect/relation/__init__.py +3 -0
- snowflake/snowpark_connect/relation/catalogs/__init__.py +12 -0
- snowflake/snowpark_connect/relation/catalogs/abstract_spark_catalog.py +287 -0
- snowflake/snowpark_connect/relation/catalogs/snowflake_catalog.py +467 -0
- snowflake/snowpark_connect/relation/catalogs/utils.py +51 -0
- snowflake/snowpark_connect/relation/io_utils.py +76 -0
- snowflake/snowpark_connect/relation/map_aggregate.py +322 -0
- snowflake/snowpark_connect/relation/map_catalog.py +151 -0
- snowflake/snowpark_connect/relation/map_column_ops.py +1068 -0
- snowflake/snowpark_connect/relation/map_crosstab.py +48 -0
- snowflake/snowpark_connect/relation/map_extension.py +412 -0
- snowflake/snowpark_connect/relation/map_join.py +341 -0
- snowflake/snowpark_connect/relation/map_local_relation.py +326 -0
- snowflake/snowpark_connect/relation/map_map_partitions.py +146 -0
- snowflake/snowpark_connect/relation/map_relation.py +253 -0
- snowflake/snowpark_connect/relation/map_row_ops.py +716 -0
- snowflake/snowpark_connect/relation/map_sample_by.py +35 -0
- snowflake/snowpark_connect/relation/map_show_string.py +50 -0
- snowflake/snowpark_connect/relation/map_sql.py +1874 -0
- snowflake/snowpark_connect/relation/map_stats.py +324 -0
- snowflake/snowpark_connect/relation/map_subquery_alias.py +32 -0
- snowflake/snowpark_connect/relation/map_udtf.py +288 -0
- snowflake/snowpark_connect/relation/read/__init__.py +7 -0
- snowflake/snowpark_connect/relation/read/jdbc_read_dbapi.py +668 -0
- snowflake/snowpark_connect/relation/read/map_read.py +367 -0
- snowflake/snowpark_connect/relation/read/map_read_csv.py +142 -0
- snowflake/snowpark_connect/relation/read/map_read_jdbc.py +108 -0
- snowflake/snowpark_connect/relation/read/map_read_json.py +344 -0
- snowflake/snowpark_connect/relation/read/map_read_parquet.py +194 -0
- snowflake/snowpark_connect/relation/read/map_read_socket.py +59 -0
- snowflake/snowpark_connect/relation/read/map_read_table.py +109 -0
- snowflake/snowpark_connect/relation/read/map_read_text.py +106 -0
- snowflake/snowpark_connect/relation/read/reader_config.py +399 -0
- snowflake/snowpark_connect/relation/read/utils.py +155 -0
- snowflake/snowpark_connect/relation/stage_locator.py +161 -0
- snowflake/snowpark_connect/relation/utils.py +219 -0
- snowflake/snowpark_connect/relation/write/__init__.py +3 -0
- snowflake/snowpark_connect/relation/write/jdbc_write_dbapi.py +339 -0
- snowflake/snowpark_connect/relation/write/map_write.py +436 -0
- snowflake/snowpark_connect/relation/write/map_write_jdbc.py +48 -0
- snowflake/snowpark_connect/resources/java_udfs-1.0-SNAPSHOT.jar +0 -0
- snowflake/snowpark_connect/resources_initializer.py +75 -0
- snowflake/snowpark_connect/server.py +1136 -0
- snowflake/snowpark_connect/start_server.py +32 -0
- snowflake/snowpark_connect/tcm.py +8 -0
- snowflake/snowpark_connect/type_mapping.py +1003 -0
- snowflake/snowpark_connect/typed_column.py +94 -0
- snowflake/snowpark_connect/utils/__init__.py +3 -0
- snowflake/snowpark_connect/utils/artifacts.py +48 -0
- snowflake/snowpark_connect/utils/attribute_handling.py +72 -0
- snowflake/snowpark_connect/utils/cache.py +84 -0
- snowflake/snowpark_connect/utils/concurrent.py +124 -0
- snowflake/snowpark_connect/utils/context.py +390 -0
- snowflake/snowpark_connect/utils/describe_query_cache.py +231 -0
- snowflake/snowpark_connect/utils/interrupt.py +85 -0
- snowflake/snowpark_connect/utils/io_utils.py +35 -0
- snowflake/snowpark_connect/utils/pandas_udtf_utils.py +117 -0
- snowflake/snowpark_connect/utils/profiling.py +47 -0
- snowflake/snowpark_connect/utils/session.py +180 -0
- snowflake/snowpark_connect/utils/snowpark_connect_logging.py +38 -0
- snowflake/snowpark_connect/utils/telemetry.py +513 -0
- snowflake/snowpark_connect/utils/udf_cache.py +392 -0
- snowflake/snowpark_connect/utils/udf_helper.py +328 -0
- snowflake/snowpark_connect/utils/udf_utils.py +310 -0
- snowflake/snowpark_connect/utils/udtf_helper.py +420 -0
- snowflake/snowpark_connect/utils/udtf_utils.py +799 -0
- snowflake/snowpark_connect/utils/xxhash64.py +247 -0
- snowflake/snowpark_connect/version.py +6 -0
- snowpark_connect-0.20.2.data/scripts/snowpark-connect +71 -0
- snowpark_connect-0.20.2.data/scripts/snowpark-session +11 -0
- snowpark_connect-0.20.2.data/scripts/snowpark-submit +354 -0
- snowpark_connect-0.20.2.dist-info/METADATA +37 -0
- snowpark_connect-0.20.2.dist-info/RECORD +879 -0
- snowpark_connect-0.20.2.dist-info/WHEEL +5 -0
- snowpark_connect-0.20.2.dist-info/licenses/LICENSE.txt +202 -0
- snowpark_connect-0.20.2.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,961 @@
|
|
|
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
|
+
|
|
18
|
+
import functools
|
|
19
|
+
import pydoc
|
|
20
|
+
import shutil
|
|
21
|
+
import tempfile
|
|
22
|
+
import unittest
|
|
23
|
+
import datetime
|
|
24
|
+
|
|
25
|
+
from pyspark import SparkContext, SQLContext
|
|
26
|
+
from pyspark.sql import SparkSession, Column, Row
|
|
27
|
+
from pyspark.sql.functions import col, udf, assert_true, lit, rand
|
|
28
|
+
from pyspark.sql.udf import UserDefinedFunction
|
|
29
|
+
from pyspark.sql.types import (
|
|
30
|
+
StringType,
|
|
31
|
+
IntegerType,
|
|
32
|
+
BooleanType,
|
|
33
|
+
DoubleType,
|
|
34
|
+
LongType,
|
|
35
|
+
ArrayType,
|
|
36
|
+
StructType,
|
|
37
|
+
StructField,
|
|
38
|
+
TimestampNTZType,
|
|
39
|
+
DayTimeIntervalType,
|
|
40
|
+
)
|
|
41
|
+
from pyspark.errors import AnalysisException, PythonException, PySparkTypeError
|
|
42
|
+
from pyspark.testing.sqlutils import ReusedSQLTestCase, test_compiled, test_not_compiled_message
|
|
43
|
+
from pyspark.testing.utils import QuietTest, assertDataFrameEqual
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class BaseUDFTestsMixin(object):
|
|
47
|
+
def test_udf_with_callable(self):
|
|
48
|
+
data = self.spark.createDataFrame([(i, i**2) for i in range(10)], ["number", "squared"])
|
|
49
|
+
|
|
50
|
+
class PlusFour:
|
|
51
|
+
def __call__(self, col):
|
|
52
|
+
if col is not None:
|
|
53
|
+
return col + 4
|
|
54
|
+
|
|
55
|
+
call = PlusFour()
|
|
56
|
+
pudf = UserDefinedFunction(call, LongType())
|
|
57
|
+
res = data.select(pudf(data["number"]).alias("plus_four"))
|
|
58
|
+
self.assertEqual(res.agg({"plus_four": "sum"}).collect()[0][0], 85)
|
|
59
|
+
|
|
60
|
+
def test_udf_with_partial_function(self):
|
|
61
|
+
data = self.spark.createDataFrame([(i, i**2) for i in range(10)], ["number", "squared"])
|
|
62
|
+
|
|
63
|
+
def some_func(col, param):
|
|
64
|
+
if col is not None:
|
|
65
|
+
return col + param
|
|
66
|
+
|
|
67
|
+
pfunc = functools.partial(some_func, param=4)
|
|
68
|
+
pudf = UserDefinedFunction(pfunc, LongType())
|
|
69
|
+
res = data.select(pudf(data["number"]).alias("plus_four"))
|
|
70
|
+
self.assertEqual(res.agg({"plus_four": "sum"}).collect()[0][0], 85)
|
|
71
|
+
|
|
72
|
+
def test_udf(self):
|
|
73
|
+
self.spark.catalog.registerFunction("twoArgs", lambda x, y: len(x) + y, IntegerType())
|
|
74
|
+
[row] = self.spark.sql("SELECT twoArgs('test', 1)").collect()
|
|
75
|
+
self.assertEqual(row[0], 5)
|
|
76
|
+
|
|
77
|
+
def test_udf_on_sql_context(self):
|
|
78
|
+
# This is to check if a deprecated 'SQLContext.registerFunction' can call its alias.
|
|
79
|
+
sqlContext = SQLContext.getOrCreate(self.spark.sparkContext)
|
|
80
|
+
sqlContext.registerFunction("oneArg", lambda x: len(x), IntegerType())
|
|
81
|
+
[row] = sqlContext.sql("SELECT oneArg('test')").collect()
|
|
82
|
+
self.assertEqual(row[0], 4)
|
|
83
|
+
|
|
84
|
+
def test_udf2(self):
|
|
85
|
+
with self.tempView("test"):
|
|
86
|
+
self.spark.catalog.registerFunction("strlen", lambda string: len(string), IntegerType())
|
|
87
|
+
self.spark.createDataFrame([("test",)], ["a"]).createOrReplaceTempView("test")
|
|
88
|
+
[res] = self.spark.sql("SELECT strlen(a) FROM test WHERE strlen(a) > 1").collect()
|
|
89
|
+
self.assertEqual(4, res[0])
|
|
90
|
+
|
|
91
|
+
def test_udf3(self):
|
|
92
|
+
two_args = self.spark.catalog.registerFunction(
|
|
93
|
+
"twoArgs", UserDefinedFunction(lambda x, y: len(x) + y)
|
|
94
|
+
)
|
|
95
|
+
self.assertEqual(two_args.deterministic, True)
|
|
96
|
+
[row] = self.spark.sql("SELECT twoArgs('test', 1)").collect()
|
|
97
|
+
self.assertEqual(row[0], "5")
|
|
98
|
+
|
|
99
|
+
def test_udf_registration_return_type_none(self):
|
|
100
|
+
two_args = self.spark.catalog.registerFunction(
|
|
101
|
+
"twoArgs", UserDefinedFunction(lambda x, y: len(x) + y, "integer"), None
|
|
102
|
+
)
|
|
103
|
+
self.assertEqual(two_args.deterministic, True)
|
|
104
|
+
[row] = self.spark.sql("SELECT twoArgs('test', 1)").collect()
|
|
105
|
+
self.assertEqual(row[0], 5)
|
|
106
|
+
|
|
107
|
+
def test_udf_registration_return_type_not_none(self):
|
|
108
|
+
with QuietTest(self.sc):
|
|
109
|
+
self.check_udf_registration_return_type_not_none()
|
|
110
|
+
|
|
111
|
+
def check_udf_registration_return_type_not_none(self):
|
|
112
|
+
# negative test for incorrect type
|
|
113
|
+
with self.assertRaises(PySparkTypeError) as pe:
|
|
114
|
+
self.spark.catalog.registerFunction(
|
|
115
|
+
"f", UserDefinedFunction(lambda x, y: len(x) + y, StringType()), StringType()
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
self.check_error(
|
|
119
|
+
exception=pe.exception,
|
|
120
|
+
error_class="CANNOT_SPECIFY_RETURN_TYPE_FOR_UDF",
|
|
121
|
+
message_parameters={"arg_name": "f", "return_type": "StringType()"},
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
def test_nondeterministic_udf(self):
|
|
125
|
+
# Test that nondeterministic UDFs are evaluated only once in chained UDF evaluations
|
|
126
|
+
import random
|
|
127
|
+
|
|
128
|
+
udf_random_col = udf(lambda: int(100 * random.random()), IntegerType()).asNondeterministic()
|
|
129
|
+
self.assertEqual(udf_random_col.deterministic, False)
|
|
130
|
+
df = self.spark.createDataFrame([Row(1)]).select(udf_random_col().alias("RAND"))
|
|
131
|
+
udf_add_ten = udf(lambda rand: rand + 10, IntegerType())
|
|
132
|
+
[row] = df.withColumn("RAND_PLUS_TEN", udf_add_ten("RAND")).collect()
|
|
133
|
+
self.assertEqual(row[0] + 10, row[1])
|
|
134
|
+
|
|
135
|
+
def test_nondeterministic_udf2(self):
|
|
136
|
+
import random
|
|
137
|
+
|
|
138
|
+
random_udf = udf(lambda: random.randint(6, 6), IntegerType()).asNondeterministic()
|
|
139
|
+
self.assertEqual(random_udf.deterministic, False)
|
|
140
|
+
random_udf1 = self.spark.catalog.registerFunction("randInt", random_udf)
|
|
141
|
+
self.assertEqual(random_udf1.deterministic, False)
|
|
142
|
+
[row] = self.spark.sql("SELECT randInt()").collect()
|
|
143
|
+
self.assertEqual(row[0], 6)
|
|
144
|
+
[row] = self.spark.range(1).select(random_udf1()).collect()
|
|
145
|
+
self.assertEqual(row[0], 6)
|
|
146
|
+
[row] = self.spark.range(1).select(random_udf()).collect()
|
|
147
|
+
self.assertEqual(row[0], 6)
|
|
148
|
+
# render_doc() reproduces the help() exception without printing output
|
|
149
|
+
pydoc.render_doc(udf(lambda: random.randint(6, 6), IntegerType()))
|
|
150
|
+
pydoc.render_doc(random_udf)
|
|
151
|
+
pydoc.render_doc(random_udf1)
|
|
152
|
+
pydoc.render_doc(udf(lambda x: x).asNondeterministic)
|
|
153
|
+
|
|
154
|
+
def test_nondeterministic_udf3(self):
|
|
155
|
+
# regression test for SPARK-23233
|
|
156
|
+
f = udf(lambda x: x)
|
|
157
|
+
# Here we cache the JVM UDF instance.
|
|
158
|
+
self.spark.range(1).select(f("id"))
|
|
159
|
+
# This should reset the cache to set the deterministic status correctly.
|
|
160
|
+
f = f.asNondeterministic()
|
|
161
|
+
# Check the deterministic status of udf.
|
|
162
|
+
df = self.spark.range(1).select(f("id"))
|
|
163
|
+
deterministic = df._jdf.logicalPlan().projectList().head().deterministic()
|
|
164
|
+
self.assertFalse(deterministic)
|
|
165
|
+
|
|
166
|
+
def test_nondeterministic_udf_in_aggregate(self):
|
|
167
|
+
with QuietTest(self.sc):
|
|
168
|
+
self.check_nondeterministic_udf_in_aggregate()
|
|
169
|
+
|
|
170
|
+
def check_nondeterministic_udf_in_aggregate(self):
|
|
171
|
+
from pyspark.sql.functions import sum
|
|
172
|
+
import random
|
|
173
|
+
|
|
174
|
+
udf_random_col = udf(lambda: int(100 * random.random()), "int").asNondeterministic()
|
|
175
|
+
df = self.spark.range(10)
|
|
176
|
+
|
|
177
|
+
with self.assertRaisesRegex(AnalysisException, "Non-deterministic"):
|
|
178
|
+
df.groupby("id").agg(sum(udf_random_col())).collect()
|
|
179
|
+
with self.assertRaisesRegex(AnalysisException, "Non-deterministic"):
|
|
180
|
+
df.agg(sum(udf_random_col())).collect()
|
|
181
|
+
|
|
182
|
+
def test_chained_udf(self):
|
|
183
|
+
self.spark.catalog.registerFunction("double", lambda x: x + x, IntegerType())
|
|
184
|
+
[row] = self.spark.sql("SELECT double(1)").collect()
|
|
185
|
+
self.assertEqual(row[0], 2)
|
|
186
|
+
[row] = self.spark.sql("SELECT double(double(1))").collect()
|
|
187
|
+
self.assertEqual(row[0], 4)
|
|
188
|
+
[row] = self.spark.sql("SELECT double(double(1) + 1)").collect()
|
|
189
|
+
self.assertEqual(row[0], 6)
|
|
190
|
+
|
|
191
|
+
def test_single_udf_with_repeated_argument(self):
|
|
192
|
+
# regression test for SPARK-20685
|
|
193
|
+
self.spark.catalog.registerFunction("add", lambda x, y: x + y, IntegerType())
|
|
194
|
+
row = self.spark.sql("SELECT add(1, 1)").first()
|
|
195
|
+
self.assertEqual(tuple(row), (2,))
|
|
196
|
+
|
|
197
|
+
def test_multiple_udfs(self):
|
|
198
|
+
self.spark.catalog.registerFunction("double", lambda x: x * 2, IntegerType())
|
|
199
|
+
[row] = self.spark.sql("SELECT double(1), double(2)").collect()
|
|
200
|
+
self.assertEqual(tuple(row), (2, 4))
|
|
201
|
+
[row] = self.spark.sql("SELECT double(double(1)), double(double(2) + 2)").collect()
|
|
202
|
+
self.assertEqual(tuple(row), (4, 12))
|
|
203
|
+
self.spark.catalog.registerFunction("add", lambda x, y: x + y, IntegerType())
|
|
204
|
+
[row] = self.spark.sql("SELECT double(add(1, 2)), add(double(2), 1)").collect()
|
|
205
|
+
self.assertEqual(tuple(row), (6, 5))
|
|
206
|
+
|
|
207
|
+
def test_udf_in_filter_on_top_of_outer_join(self):
|
|
208
|
+
left = self.spark.createDataFrame([Row(a=1)])
|
|
209
|
+
right = self.spark.createDataFrame([Row(a=1)])
|
|
210
|
+
df = left.join(right, on="a", how="left_outer")
|
|
211
|
+
df = df.withColumn("b", udf(lambda x: "x")(df.a))
|
|
212
|
+
self.assertEqual(df.filter('b = "x"').collect(), [Row(a=1, b="x")])
|
|
213
|
+
|
|
214
|
+
def test_udf_in_filter_on_top_of_join(self):
|
|
215
|
+
# regression test for SPARK-18589
|
|
216
|
+
left = self.spark.createDataFrame([Row(a=1)])
|
|
217
|
+
right = self.spark.createDataFrame([Row(b=1)])
|
|
218
|
+
f = udf(lambda a, b: a == b, BooleanType())
|
|
219
|
+
df = left.crossJoin(right).filter(f("a", "b"))
|
|
220
|
+
self.assertEqual(df.collect(), [Row(a=1, b=1)])
|
|
221
|
+
|
|
222
|
+
def test_udf_in_join_condition(self):
|
|
223
|
+
# regression test for SPARK-25314
|
|
224
|
+
left = self.spark.createDataFrame([Row(a=1)])
|
|
225
|
+
right = self.spark.createDataFrame([Row(b=1)])
|
|
226
|
+
f = udf(lambda a, b: a == b, BooleanType())
|
|
227
|
+
# The udf uses attributes from both sides of join, so it is pulled out as Filter +
|
|
228
|
+
# Cross join.
|
|
229
|
+
df = left.join(right, f("a", "b"))
|
|
230
|
+
with self.sql_conf({"spark.sql.crossJoin.enabled": False}):
|
|
231
|
+
with self.assertRaisesRegex(AnalysisException, "Detected implicit cartesian product"):
|
|
232
|
+
df.collect()
|
|
233
|
+
with self.sql_conf({"spark.sql.crossJoin.enabled": True}):
|
|
234
|
+
self.assertEqual(df.collect(), [Row(a=1, b=1)])
|
|
235
|
+
|
|
236
|
+
def test_udf_in_left_outer_join_condition(self):
|
|
237
|
+
# regression test for SPARK-26147
|
|
238
|
+
from pyspark.sql.functions import col
|
|
239
|
+
|
|
240
|
+
left = self.spark.createDataFrame([Row(a=1)])
|
|
241
|
+
right = self.spark.createDataFrame([Row(b=1)])
|
|
242
|
+
f = udf(lambda a: str(a), StringType())
|
|
243
|
+
# The join condition can't be pushed down, as it refers to attributes from both sides.
|
|
244
|
+
# The Python UDF only refer to attributes from one side, so it's evaluable.
|
|
245
|
+
df = left.join(right, f("a") == col("b").cast("string"), how="left_outer")
|
|
246
|
+
with self.sql_conf({"spark.sql.crossJoin.enabled": True}):
|
|
247
|
+
self.assertEqual(df.collect(), [Row(a=1, b=1)])
|
|
248
|
+
|
|
249
|
+
def test_udf_and_common_filter_in_join_condition(self):
|
|
250
|
+
# regression test for SPARK-25314
|
|
251
|
+
# test the complex scenario with both udf and common filter
|
|
252
|
+
left = self.spark.createDataFrame([Row(a=1, a1=1, a2=1), Row(a=2, a1=2, a2=2)])
|
|
253
|
+
right = self.spark.createDataFrame([Row(b=1, b1=1, b2=1), Row(b=1, b1=3, b2=1)])
|
|
254
|
+
f = udf(lambda a, b: a == b, BooleanType())
|
|
255
|
+
df = left.join(right, [f("a", "b"), left.a1 == right.b1])
|
|
256
|
+
# do not need spark.sql.crossJoin.enabled=true for udf is not the only join condition.
|
|
257
|
+
self.assertEqual(df.collect(), [Row(a=1, a1=1, a2=1, b=1, b1=1, b2=1)])
|
|
258
|
+
|
|
259
|
+
def test_udf_not_supported_in_join_condition(self):
|
|
260
|
+
# regression test for SPARK-25314
|
|
261
|
+
# test python udf is not supported in join type except inner join.
|
|
262
|
+
left = self.spark.createDataFrame([Row(a=1, a1=1, a2=1), Row(a=2, a1=2, a2=2)])
|
|
263
|
+
right = self.spark.createDataFrame([Row(b=1, b1=1, b2=1), Row(b=1, b1=3, b2=1)])
|
|
264
|
+
f = udf(lambda a, b: a == b, BooleanType())
|
|
265
|
+
|
|
266
|
+
def runWithJoinType(join_type, type_string):
|
|
267
|
+
with self.assertRaisesRegex(
|
|
268
|
+
AnalysisException,
|
|
269
|
+
"""Python UDF in the ON clause of a %s JOIN.""" % type_string,
|
|
270
|
+
):
|
|
271
|
+
left.join(right, [f("a", "b"), left.a1 == right.b1], join_type).collect()
|
|
272
|
+
|
|
273
|
+
runWithJoinType("full", "FULL OUTER")
|
|
274
|
+
runWithJoinType("left", "LEFT OUTER")
|
|
275
|
+
runWithJoinType("right", "RIGHT OUTER")
|
|
276
|
+
runWithJoinType("leftanti", "LEFT ANTI")
|
|
277
|
+
runWithJoinType("leftsemi", "LEFT SEMI")
|
|
278
|
+
|
|
279
|
+
def test_udf_as_join_condition(self):
|
|
280
|
+
left = self.spark.createDataFrame([Row(a=1, a1=1, a2=1), Row(a=2, a1=2, a2=2)])
|
|
281
|
+
right = self.spark.createDataFrame([Row(b=1, b1=1, b2=1), Row(b=1, b1=3, b2=1)])
|
|
282
|
+
f = udf(lambda a: a, IntegerType())
|
|
283
|
+
|
|
284
|
+
df = left.join(right, [f("a") == f("b"), left.a1 == right.b1])
|
|
285
|
+
self.assertEqual(df.collect(), [Row(a=1, a1=1, a2=1, b=1, b1=1, b2=1)])
|
|
286
|
+
|
|
287
|
+
def test_udf_without_arguments(self):
|
|
288
|
+
self.spark.catalog.registerFunction("foo", lambda: "bar")
|
|
289
|
+
[row] = self.spark.sql("SELECT foo()").collect()
|
|
290
|
+
self.assertEqual(row[0], "bar")
|
|
291
|
+
|
|
292
|
+
def test_udf_with_array_type(self):
|
|
293
|
+
with self.tempView("test"):
|
|
294
|
+
self.spark.createDataFrame(
|
|
295
|
+
[
|
|
296
|
+
([0, 1, 2], {"key": [0, 1, 2, 3, 4]}),
|
|
297
|
+
],
|
|
298
|
+
["l", "d"],
|
|
299
|
+
).createOrReplaceTempView("test")
|
|
300
|
+
self.spark.catalog.registerFunction(
|
|
301
|
+
"copylist", lambda l: list(l), ArrayType(IntegerType())
|
|
302
|
+
)
|
|
303
|
+
self.spark.catalog.registerFunction("maplen", lambda d: len(d), IntegerType())
|
|
304
|
+
[(l1, l2)] = self.spark.sql("select copylist(l), maplen(d) from test").collect()
|
|
305
|
+
self.assertEqual(list(range(3)), l1)
|
|
306
|
+
self.assertEqual(1, l2)
|
|
307
|
+
|
|
308
|
+
def test_broadcast_in_udf(self):
|
|
309
|
+
bar = {"a": "aa", "b": "bb", "c": "abc"}
|
|
310
|
+
foo = self.sc.broadcast(bar)
|
|
311
|
+
self.spark.catalog.registerFunction("MYUDF", lambda x: foo.value[x] if x else "")
|
|
312
|
+
[res] = self.spark.sql("SELECT MYUDF('c')").collect()
|
|
313
|
+
self.assertEqual("abc", res[0])
|
|
314
|
+
[res] = self.spark.sql("SELECT MYUDF('')").collect()
|
|
315
|
+
self.assertEqual("", res[0])
|
|
316
|
+
|
|
317
|
+
def test_udf_with_filter_function(self):
|
|
318
|
+
df = self.spark.createDataFrame([(1, "1"), (2, "2"), (1, "2"), (1, "2")], ["key", "value"])
|
|
319
|
+
from pyspark.sql.functions import col
|
|
320
|
+
|
|
321
|
+
my_filter = udf(lambda a: a < 2, BooleanType())
|
|
322
|
+
sel = df.select(col("key"), col("value")).filter((my_filter(col("key"))) & (df.value < "2"))
|
|
323
|
+
self.assertEqual(sel.collect(), [Row(key=1, value="1")])
|
|
324
|
+
|
|
325
|
+
def test_udf_with_aggregate_function(self):
|
|
326
|
+
df = self.spark.createDataFrame([(1, "1"), (2, "2"), (1, "2"), (1, "2")], ["key", "value"])
|
|
327
|
+
from pyspark.sql.functions import col, sum
|
|
328
|
+
|
|
329
|
+
my_filter = udf(lambda a: a == 1, BooleanType())
|
|
330
|
+
sel = df.select(col("key")).distinct().filter(my_filter(col("key")))
|
|
331
|
+
self.assertEqual(sel.collect(), [Row(key=1)])
|
|
332
|
+
|
|
333
|
+
my_copy = udf(lambda x: x, IntegerType())
|
|
334
|
+
my_add = udf(lambda a, b: int(a + b), IntegerType())
|
|
335
|
+
my_strlen = udf(lambda x: len(x), IntegerType())
|
|
336
|
+
sel = (
|
|
337
|
+
df.groupBy(my_copy(col("key")).alias("k"))
|
|
338
|
+
.agg(sum(my_strlen(col("value"))).alias("s"))
|
|
339
|
+
.select(my_add(col("k"), col("s")).alias("t"))
|
|
340
|
+
)
|
|
341
|
+
self.assertEqual(sel.collect(), [Row(t=4), Row(t=3)])
|
|
342
|
+
|
|
343
|
+
def test_udf_in_generate(self):
|
|
344
|
+
from pyspark.sql.functions import explode
|
|
345
|
+
|
|
346
|
+
df = self.spark.range(5)
|
|
347
|
+
f = udf(lambda x: list(range(x)), ArrayType(LongType()))
|
|
348
|
+
row = df.select(explode(f(*df))).groupBy().sum().first()
|
|
349
|
+
self.assertEqual(row[0], 10)
|
|
350
|
+
|
|
351
|
+
df = self.spark.range(3)
|
|
352
|
+
res = df.select("id", explode(f(df.id))).collect()
|
|
353
|
+
self.assertEqual(res[0][0], 1)
|
|
354
|
+
self.assertEqual(res[0][1], 0)
|
|
355
|
+
self.assertEqual(res[1][0], 2)
|
|
356
|
+
self.assertEqual(res[1][1], 0)
|
|
357
|
+
self.assertEqual(res[2][0], 2)
|
|
358
|
+
self.assertEqual(res[2][1], 1)
|
|
359
|
+
|
|
360
|
+
range_udf = udf(lambda value: list(range(value - 1, value + 1)), ArrayType(IntegerType()))
|
|
361
|
+
res = df.select("id", explode(range_udf(df.id))).collect()
|
|
362
|
+
self.assertEqual(res[0][0], 0)
|
|
363
|
+
self.assertEqual(res[0][1], -1)
|
|
364
|
+
self.assertEqual(res[1][0], 0)
|
|
365
|
+
self.assertEqual(res[1][1], 0)
|
|
366
|
+
self.assertEqual(res[2][0], 1)
|
|
367
|
+
self.assertEqual(res[2][1], 0)
|
|
368
|
+
self.assertEqual(res[3][0], 1)
|
|
369
|
+
self.assertEqual(res[3][1], 1)
|
|
370
|
+
|
|
371
|
+
def test_udf_with_order_by_and_limit(self):
|
|
372
|
+
my_copy = udf(lambda x: x, IntegerType())
|
|
373
|
+
df = self.spark.range(10).orderBy("id")
|
|
374
|
+
res = df.select(df.id, my_copy(df.id).alias("copy")).limit(1)
|
|
375
|
+
self.assertEqual(res.collect(), [Row(id=0, copy=0)])
|
|
376
|
+
|
|
377
|
+
def test_udf_registration_returns_udf(self):
|
|
378
|
+
df = self.spark.range(10)
|
|
379
|
+
add_three = self.spark.udf.register("add_three", lambda x: x + 3, IntegerType())
|
|
380
|
+
|
|
381
|
+
self.assertListEqual(
|
|
382
|
+
df.selectExpr("add_three(id) AS plus_three").collect(),
|
|
383
|
+
df.select(add_three("id").alias("plus_three")).collect(),
|
|
384
|
+
)
|
|
385
|
+
|
|
386
|
+
def test_udf_registration_returns_udf_on_sql_context(self):
|
|
387
|
+
df = self.spark.range(10)
|
|
388
|
+
|
|
389
|
+
# This is to check if a 'SQLContext.udf' can call its alias.
|
|
390
|
+
sqlContext = SQLContext.getOrCreate(self.spark.sparkContext)
|
|
391
|
+
add_four = sqlContext.udf.register("add_four", lambda x: x + 4, IntegerType())
|
|
392
|
+
|
|
393
|
+
self.assertListEqual(
|
|
394
|
+
df.selectExpr("add_four(id) AS plus_four").collect(),
|
|
395
|
+
df.select(add_four("id").alias("plus_four")).collect(),
|
|
396
|
+
)
|
|
397
|
+
|
|
398
|
+
@unittest.skipIf(not test_compiled, test_not_compiled_message) # type: ignore
|
|
399
|
+
def test_register_java_function(self):
|
|
400
|
+
self.spark.udf.registerJavaFunction(
|
|
401
|
+
"javaStringLength", "test.org.apache.spark.sql.JavaStringLength", IntegerType()
|
|
402
|
+
)
|
|
403
|
+
[value] = self.spark.sql("SELECT javaStringLength('test')").first()
|
|
404
|
+
self.assertEqual(value, 4)
|
|
405
|
+
|
|
406
|
+
self.spark.udf.registerJavaFunction(
|
|
407
|
+
"javaStringLength2", "test.org.apache.spark.sql.JavaStringLength"
|
|
408
|
+
)
|
|
409
|
+
[value] = self.spark.sql("SELECT javaStringLength2('test')").first()
|
|
410
|
+
self.assertEqual(value, 4)
|
|
411
|
+
|
|
412
|
+
self.spark.udf.registerJavaFunction(
|
|
413
|
+
"javaStringLength3", "test.org.apache.spark.sql.JavaStringLength", "integer"
|
|
414
|
+
)
|
|
415
|
+
[value] = self.spark.sql("SELECT javaStringLength3('test')").first()
|
|
416
|
+
self.assertEqual(value, 4)
|
|
417
|
+
|
|
418
|
+
@unittest.skipIf(not test_compiled, test_not_compiled_message) # type: ignore
|
|
419
|
+
def test_register_java_udaf(self):
|
|
420
|
+
self.spark.udf.registerJavaUDAF("javaUDAF", "test.org.apache.spark.sql.MyDoubleAvg")
|
|
421
|
+
df = self.spark.createDataFrame([(1, "a"), (2, "b"), (3, "a")], ["id", "name"])
|
|
422
|
+
df.createOrReplaceTempView("df")
|
|
423
|
+
row = self.spark.sql(
|
|
424
|
+
"SELECT name, javaUDAF(id) as avg from df group by name order by name desc"
|
|
425
|
+
).first()
|
|
426
|
+
self.assertEqual(row.asDict(), Row(name="b", avg=102.0).asDict())
|
|
427
|
+
|
|
428
|
+
def test_non_existed_udf(self):
|
|
429
|
+
spark = self.spark
|
|
430
|
+
self.assertRaisesRegex(
|
|
431
|
+
AnalysisException,
|
|
432
|
+
"Can not load class non_existed_udf",
|
|
433
|
+
lambda: spark.udf.registerJavaFunction("udf1", "non_existed_udf"),
|
|
434
|
+
)
|
|
435
|
+
|
|
436
|
+
def test_non_existed_udf_with_sql_context(self):
|
|
437
|
+
# This is to check if a deprecated 'SQLContext.registerJavaFunction' can call its alias.
|
|
438
|
+
sqlContext = SQLContext.getOrCreate(self.spark.sparkContext)
|
|
439
|
+
self.assertRaisesRegex(
|
|
440
|
+
AnalysisException,
|
|
441
|
+
"Can not load class non_existed_udf",
|
|
442
|
+
lambda: sqlContext.registerJavaFunction("udf1", "non_existed_udf"),
|
|
443
|
+
)
|
|
444
|
+
|
|
445
|
+
def test_non_existed_udaf(self):
|
|
446
|
+
spark = self.spark
|
|
447
|
+
self.assertRaisesRegex(
|
|
448
|
+
AnalysisException,
|
|
449
|
+
"Can not load class non_existed_udaf",
|
|
450
|
+
lambda: spark.udf.registerJavaUDAF("udaf1", "non_existed_udaf"),
|
|
451
|
+
)
|
|
452
|
+
|
|
453
|
+
def test_udf_with_input_file_name(self):
|
|
454
|
+
from pyspark.sql.functions import input_file_name
|
|
455
|
+
|
|
456
|
+
sourceFile = udf(lambda path: path, StringType())
|
|
457
|
+
filePath = "python/test_support/sql/people1.json"
|
|
458
|
+
row = self.spark.read.json(filePath).select(sourceFile(input_file_name())).first()
|
|
459
|
+
self.assertTrue(row[0].find("people1.json") != -1)
|
|
460
|
+
|
|
461
|
+
def test_udf_with_input_file_name_for_hadooprdd(self):
|
|
462
|
+
from pyspark.sql.functions import input_file_name
|
|
463
|
+
|
|
464
|
+
def filename(path):
|
|
465
|
+
return path
|
|
466
|
+
|
|
467
|
+
sameText = udf(filename, StringType())
|
|
468
|
+
|
|
469
|
+
rdd = self.sc.textFile("python/test_support/sql/people.json")
|
|
470
|
+
df = self.spark.read.json(rdd).select(input_file_name().alias("file"))
|
|
471
|
+
row = df.select(sameText(df["file"])).first()
|
|
472
|
+
self.assertTrue(row[0].find("people.json") != -1)
|
|
473
|
+
|
|
474
|
+
rdd2 = self.sc.newAPIHadoopFile(
|
|
475
|
+
"python/test_support/sql/people.json",
|
|
476
|
+
"org.apache.hadoop.mapreduce.lib.input.TextInputFormat",
|
|
477
|
+
"org.apache.hadoop.io.LongWritable",
|
|
478
|
+
"org.apache.hadoop.io.Text",
|
|
479
|
+
)
|
|
480
|
+
|
|
481
|
+
df2 = self.spark.read.json(rdd2).select(input_file_name().alias("file"))
|
|
482
|
+
row2 = df2.select(sameText(df2["file"])).first()
|
|
483
|
+
self.assertTrue(row2[0].find("people.json") != -1)
|
|
484
|
+
|
|
485
|
+
def test_udf_defers_judf_initialization(self):
|
|
486
|
+
# This is separate of UDFInitializationTests
|
|
487
|
+
# to avoid context initialization
|
|
488
|
+
# when udf is called
|
|
489
|
+
f = UserDefinedFunction(lambda x: x, StringType())
|
|
490
|
+
|
|
491
|
+
self.assertIsNone(
|
|
492
|
+
f._judf_placeholder, "judf should not be initialized before the first call."
|
|
493
|
+
)
|
|
494
|
+
|
|
495
|
+
self.assertIsInstance(f("foo"), Column, "UDF call should return a Column.")
|
|
496
|
+
|
|
497
|
+
self.assertIsNotNone(
|
|
498
|
+
f._judf_placeholder, "judf should be initialized after UDF has been called."
|
|
499
|
+
)
|
|
500
|
+
|
|
501
|
+
def test_udf_with_string_return_type(self):
|
|
502
|
+
add_one = UserDefinedFunction(lambda x: x + 1, "integer")
|
|
503
|
+
make_pair = UserDefinedFunction(lambda x: (-x, x), "struct<x:integer,y:integer>")
|
|
504
|
+
make_array = UserDefinedFunction(
|
|
505
|
+
lambda x: [float(x) for x in range(x, x + 3)], "array<double>"
|
|
506
|
+
)
|
|
507
|
+
|
|
508
|
+
expected = (2, Row(x=-1, y=1), [1.0, 2.0, 3.0])
|
|
509
|
+
actual = (
|
|
510
|
+
self.spark.range(1, 2)
|
|
511
|
+
.toDF("x")
|
|
512
|
+
.select(add_one("x"), make_pair("x"), make_array("x"))
|
|
513
|
+
.first()
|
|
514
|
+
)
|
|
515
|
+
|
|
516
|
+
self.assertTupleEqual(expected, actual)
|
|
517
|
+
|
|
518
|
+
def test_udf_should_not_accept_noncallable_object(self):
|
|
519
|
+
non_callable = None
|
|
520
|
+
self.assertRaises(TypeError, UserDefinedFunction, non_callable, StringType())
|
|
521
|
+
|
|
522
|
+
def test_udf_with_decorator(self):
|
|
523
|
+
from pyspark.sql.functions import lit
|
|
524
|
+
|
|
525
|
+
@udf(IntegerType())
|
|
526
|
+
def add_one(x):
|
|
527
|
+
if x is not None:
|
|
528
|
+
return x + 1
|
|
529
|
+
|
|
530
|
+
@udf(returnType=DoubleType())
|
|
531
|
+
def add_two(x):
|
|
532
|
+
if x is not None:
|
|
533
|
+
return float(x + 2)
|
|
534
|
+
|
|
535
|
+
@udf
|
|
536
|
+
def to_upper(x):
|
|
537
|
+
if x is not None:
|
|
538
|
+
return x.upper()
|
|
539
|
+
|
|
540
|
+
@udf()
|
|
541
|
+
def to_lower(x):
|
|
542
|
+
if x is not None:
|
|
543
|
+
return x.lower()
|
|
544
|
+
|
|
545
|
+
@udf
|
|
546
|
+
def substr(x, start, end):
|
|
547
|
+
if x is not None:
|
|
548
|
+
return x[start:end]
|
|
549
|
+
|
|
550
|
+
@udf("long")
|
|
551
|
+
def trunc(x):
|
|
552
|
+
return int(x)
|
|
553
|
+
|
|
554
|
+
@udf(returnType="double")
|
|
555
|
+
def as_double(x):
|
|
556
|
+
return float(x)
|
|
557
|
+
|
|
558
|
+
df = self.spark.createDataFrame(
|
|
559
|
+
[(1, "Foo", "foobar", 3.0)], ("one", "Foo", "foobar", "float")
|
|
560
|
+
).select(
|
|
561
|
+
add_one("one"),
|
|
562
|
+
add_two("one"),
|
|
563
|
+
to_upper("Foo"),
|
|
564
|
+
to_lower("Foo"),
|
|
565
|
+
substr("foobar", lit(0), lit(3)),
|
|
566
|
+
trunc("float"),
|
|
567
|
+
as_double("one"),
|
|
568
|
+
)
|
|
569
|
+
|
|
570
|
+
self.assertListEqual(
|
|
571
|
+
[tpe for _, tpe in df.dtypes],
|
|
572
|
+
["int", "double", "string", "string", "string", "bigint", "double"],
|
|
573
|
+
)
|
|
574
|
+
|
|
575
|
+
self.assertListEqual(list(df.first()), [2, 3.0, "FOO", "foo", "foo", 3, 1.0])
|
|
576
|
+
|
|
577
|
+
def test_udf_wrapper(self):
|
|
578
|
+
def f(x):
|
|
579
|
+
"""Identity"""
|
|
580
|
+
return x
|
|
581
|
+
|
|
582
|
+
return_type = IntegerType()
|
|
583
|
+
f_ = udf(f, return_type)
|
|
584
|
+
|
|
585
|
+
self.assertTrue(f.__doc__ in f_.__doc__)
|
|
586
|
+
self.assertEqual(f, f_.func)
|
|
587
|
+
self.assertEqual(return_type, f_.returnType)
|
|
588
|
+
|
|
589
|
+
class F:
|
|
590
|
+
"""Identity"""
|
|
591
|
+
|
|
592
|
+
def __call__(self, x):
|
|
593
|
+
return x
|
|
594
|
+
|
|
595
|
+
f = F()
|
|
596
|
+
return_type = IntegerType()
|
|
597
|
+
f_ = udf(f, return_type)
|
|
598
|
+
|
|
599
|
+
self.assertTrue(f.__doc__ in f_.__doc__)
|
|
600
|
+
self.assertEqual(f, f_.func)
|
|
601
|
+
self.assertEqual(return_type, f_.returnType)
|
|
602
|
+
|
|
603
|
+
f = functools.partial(f, x=1)
|
|
604
|
+
return_type = IntegerType()
|
|
605
|
+
f_ = udf(f, return_type)
|
|
606
|
+
|
|
607
|
+
self.assertTrue(f.__doc__ in f_.__doc__)
|
|
608
|
+
self.assertEqual(f, f_.func)
|
|
609
|
+
self.assertEqual(return_type, f_.returnType)
|
|
610
|
+
|
|
611
|
+
def test_udf_timestamp_ntz(self):
|
|
612
|
+
# SPARK-36626: Test TimestampNTZ in Python UDF
|
|
613
|
+
@udf(TimestampNTZType())
|
|
614
|
+
def noop(x):
|
|
615
|
+
assert x == datetime.datetime(1970, 1, 1, 0, 0)
|
|
616
|
+
return x
|
|
617
|
+
|
|
618
|
+
with self.sql_conf({"spark.sql.session.timeZone": "Pacific/Honolulu"}):
|
|
619
|
+
df = self.spark.createDataFrame(
|
|
620
|
+
[(datetime.datetime(1970, 1, 1, 0, 0),)], schema="dt timestamp_ntz"
|
|
621
|
+
).select(noop("dt").alias("dt"))
|
|
622
|
+
|
|
623
|
+
df.selectExpr("assert_true('1970-01-01 00:00:00' == CAST(dt AS STRING))").collect()
|
|
624
|
+
self.assertEqual(df.schema[0].dataType.typeName(), "timestamp_ntz")
|
|
625
|
+
self.assertEqual(df.first()[0], datetime.datetime(1970, 1, 1, 0, 0))
|
|
626
|
+
|
|
627
|
+
def test_udf_daytime_interval(self):
|
|
628
|
+
# SPARK-37277: Support DayTimeIntervalType in Python UDF
|
|
629
|
+
@udf(DayTimeIntervalType(DayTimeIntervalType.DAY, DayTimeIntervalType.SECOND))
|
|
630
|
+
def noop(x):
|
|
631
|
+
assert x == datetime.timedelta(microseconds=123)
|
|
632
|
+
return x
|
|
633
|
+
|
|
634
|
+
df = self.spark.createDataFrame(
|
|
635
|
+
[(datetime.timedelta(microseconds=123),)], schema="td interval day to second"
|
|
636
|
+
).select(noop("td").alias("td"))
|
|
637
|
+
|
|
638
|
+
df.select(
|
|
639
|
+
assert_true(lit("INTERVAL '0 00:00:00.000123' DAY TO SECOND") == df.td.cast("string"))
|
|
640
|
+
).collect()
|
|
641
|
+
self.assertEqual(df.schema[0].dataType.simpleString(), "interval day to second")
|
|
642
|
+
self.assertEqual(df.first()[0], datetime.timedelta(microseconds=123))
|
|
643
|
+
|
|
644
|
+
def test_nonparam_udf_with_aggregate(self):
|
|
645
|
+
import pyspark.sql.functions as f
|
|
646
|
+
|
|
647
|
+
df = self.spark.createDataFrame([(1, 2), (1, 2)])
|
|
648
|
+
f_udf = f.udf(lambda: "const_str")
|
|
649
|
+
rows = df.distinct().withColumn("a", f_udf()).collect()
|
|
650
|
+
self.assertEqual(rows, [Row(_1=1, _2=2, a="const_str")])
|
|
651
|
+
|
|
652
|
+
# SPARK-24721
|
|
653
|
+
@unittest.skipIf(not test_compiled, test_not_compiled_message) # type: ignore
|
|
654
|
+
def test_datasource_with_udf(self):
|
|
655
|
+
from pyspark.sql.functions import lit, col
|
|
656
|
+
|
|
657
|
+
path = tempfile.mkdtemp()
|
|
658
|
+
shutil.rmtree(path)
|
|
659
|
+
|
|
660
|
+
try:
|
|
661
|
+
self.spark.range(1).write.mode("overwrite").format("csv").save(path)
|
|
662
|
+
filesource_df = self.spark.read.option("inferSchema", True).csv(path).toDF("i")
|
|
663
|
+
datasource_df = (
|
|
664
|
+
self.spark.read.format("org.apache.spark.sql.sources.SimpleScanSource")
|
|
665
|
+
.option("from", 0)
|
|
666
|
+
.option("to", 1)
|
|
667
|
+
.load()
|
|
668
|
+
.toDF("i")
|
|
669
|
+
)
|
|
670
|
+
datasource_v2_df = (
|
|
671
|
+
self.spark.read.format("org.apache.spark.sql.connector.SimpleDataSourceV2")
|
|
672
|
+
.load()
|
|
673
|
+
.toDF("i", "j")
|
|
674
|
+
)
|
|
675
|
+
|
|
676
|
+
c1 = udf(lambda x: x + 1, "int")(lit(1))
|
|
677
|
+
c2 = udf(lambda x: x + 1, "int")(col("i"))
|
|
678
|
+
|
|
679
|
+
f1 = udf(lambda x: False, "boolean")(lit(1))
|
|
680
|
+
f2 = udf(lambda x: False, "boolean")(col("i"))
|
|
681
|
+
|
|
682
|
+
for df in [filesource_df, datasource_df, datasource_v2_df]:
|
|
683
|
+
result = df.withColumn("c", c1)
|
|
684
|
+
expected = df.withColumn("c", lit(2))
|
|
685
|
+
self.assertEqual(expected.collect(), result.collect())
|
|
686
|
+
|
|
687
|
+
for df in [filesource_df, datasource_df, datasource_v2_df]:
|
|
688
|
+
result = df.withColumn("c", c2)
|
|
689
|
+
expected = df.withColumn("c", col("i") + 1)
|
|
690
|
+
self.assertEqual(expected.collect(), result.collect())
|
|
691
|
+
|
|
692
|
+
for df in [filesource_df, datasource_df, datasource_v2_df]:
|
|
693
|
+
for f in [f1, f2]:
|
|
694
|
+
result = df.filter(f)
|
|
695
|
+
self.assertEqual(0, result.count())
|
|
696
|
+
finally:
|
|
697
|
+
shutil.rmtree(path)
|
|
698
|
+
|
|
699
|
+
# SPARK-42134
|
|
700
|
+
def test_file_dsv2_with_udf_filter(self):
|
|
701
|
+
from pyspark.sql.functions import lit
|
|
702
|
+
|
|
703
|
+
path = tempfile.mkdtemp()
|
|
704
|
+
shutil.rmtree(path)
|
|
705
|
+
|
|
706
|
+
try:
|
|
707
|
+
with self.sql_conf({"spark.sql.sources.useV1SourceList": ""}):
|
|
708
|
+
self.spark.range(1).write.mode("overwrite").format("parquet").save(path)
|
|
709
|
+
df = self.spark.read.parquet(path).toDF("i")
|
|
710
|
+
f = udf(lambda x: False, "boolean")(lit(1))
|
|
711
|
+
result = df.filter(f)
|
|
712
|
+
self.assertEqual(0, result.count())
|
|
713
|
+
|
|
714
|
+
finally:
|
|
715
|
+
shutil.rmtree(path)
|
|
716
|
+
|
|
717
|
+
# SPARK-25591
|
|
718
|
+
def test_same_accumulator_in_udfs(self):
|
|
719
|
+
data_schema = StructType(
|
|
720
|
+
[StructField("a", IntegerType(), True), StructField("b", IntegerType(), True)]
|
|
721
|
+
)
|
|
722
|
+
data = self.spark.createDataFrame([[1, 2]], schema=data_schema)
|
|
723
|
+
|
|
724
|
+
test_accum = self.sc.accumulator(0)
|
|
725
|
+
|
|
726
|
+
def first_udf(x):
|
|
727
|
+
test_accum.add(1)
|
|
728
|
+
return x
|
|
729
|
+
|
|
730
|
+
def second_udf(x):
|
|
731
|
+
test_accum.add(100)
|
|
732
|
+
return x
|
|
733
|
+
|
|
734
|
+
func_udf = udf(first_udf, IntegerType())
|
|
735
|
+
func_udf2 = udf(second_udf, IntegerType())
|
|
736
|
+
data = data.withColumn("out1", func_udf(data["a"]))
|
|
737
|
+
data = data.withColumn("out2", func_udf2(data["b"]))
|
|
738
|
+
data.collect()
|
|
739
|
+
self.assertEqual(test_accum.value, 101)
|
|
740
|
+
|
|
741
|
+
# SPARK-26293
|
|
742
|
+
def test_udf_in_subquery(self):
|
|
743
|
+
f = udf(lambda x: x, "long")
|
|
744
|
+
with self.tempView("v"):
|
|
745
|
+
self.spark.range(1).filter(f("id") >= 0).createTempView("v")
|
|
746
|
+
result = self.spark.sql(
|
|
747
|
+
"select i from values(0L) as data(i) where i in (select id from v)"
|
|
748
|
+
)
|
|
749
|
+
self.assertEqual(result.collect(), [Row(i=0)])
|
|
750
|
+
|
|
751
|
+
def test_udf_globals_not_overwritten(self):
|
|
752
|
+
@udf("string")
|
|
753
|
+
def f():
|
|
754
|
+
assert "itertools" not in str(map)
|
|
755
|
+
|
|
756
|
+
self.spark.range(1).select(f()).collect()
|
|
757
|
+
|
|
758
|
+
def test_worker_original_stdin_closed(self):
|
|
759
|
+
# Test if it closes the original standard input of worker inherited from the daemon,
|
|
760
|
+
# and replaces it with '/dev/null'. See SPARK-26175.
|
|
761
|
+
def task(iterator):
|
|
762
|
+
import sys
|
|
763
|
+
|
|
764
|
+
res = sys.stdin.read()
|
|
765
|
+
# Because the standard input is '/dev/null', it reaches to EOF.
|
|
766
|
+
assert res == "", "Expect read EOF from stdin."
|
|
767
|
+
return iterator
|
|
768
|
+
|
|
769
|
+
self.sc.parallelize(range(1), 1).mapPartitions(task).count()
|
|
770
|
+
|
|
771
|
+
def test_udf_with_256_args(self):
|
|
772
|
+
N = 256
|
|
773
|
+
data = [["data-%d" % i for i in range(N)]] * 5
|
|
774
|
+
df = self.spark.createDataFrame(data)
|
|
775
|
+
|
|
776
|
+
def f(*a):
|
|
777
|
+
return "success"
|
|
778
|
+
|
|
779
|
+
fUdf = udf(f, StringType())
|
|
780
|
+
|
|
781
|
+
r = df.select(fUdf(*df.columns))
|
|
782
|
+
self.assertEqual(r.first()[0], "success")
|
|
783
|
+
|
|
784
|
+
def test_udf_cache(self):
|
|
785
|
+
def func(x):
|
|
786
|
+
return x
|
|
787
|
+
|
|
788
|
+
df = self.spark.range(1)
|
|
789
|
+
df.select(udf(func)("id")).cache()
|
|
790
|
+
|
|
791
|
+
self.assertEqual(
|
|
792
|
+
df.select(udf(func)("id"))
|
|
793
|
+
._jdf.queryExecution()
|
|
794
|
+
.withCachedData()
|
|
795
|
+
.getClass()
|
|
796
|
+
.getSimpleName(),
|
|
797
|
+
"InMemoryRelation",
|
|
798
|
+
)
|
|
799
|
+
|
|
800
|
+
# SPARK-34545
|
|
801
|
+
def test_udf_input_serialization_valuecompare_disabled(self):
|
|
802
|
+
def f(e):
|
|
803
|
+
return e[0]
|
|
804
|
+
|
|
805
|
+
df = self.spark.createDataFrame([((1.0, 1.0), (1, 1))], ["c1", "c2"])
|
|
806
|
+
result = df.select(
|
|
807
|
+
"*", udf(f, DoubleType())("c1").alias("c3"), udf(f, IntegerType())("c2").alias("c4")
|
|
808
|
+
)
|
|
809
|
+
self.assertEqual(
|
|
810
|
+
result.collect(), [Row(c1=Row(_1=1.0, _2=1.0), c2=Row(_1=1, _2=1), c3=1.0, c4=1)]
|
|
811
|
+
)
|
|
812
|
+
|
|
813
|
+
# SPARK-33277
|
|
814
|
+
def test_udf_with_column_vector(self):
|
|
815
|
+
path = tempfile.mkdtemp()
|
|
816
|
+
shutil.rmtree(path)
|
|
817
|
+
|
|
818
|
+
try:
|
|
819
|
+
self.spark.range(0, 100000, 1, 1).write.parquet(path)
|
|
820
|
+
|
|
821
|
+
def f(x):
|
|
822
|
+
return 0
|
|
823
|
+
|
|
824
|
+
fUdf = udf(f, LongType())
|
|
825
|
+
|
|
826
|
+
for offheap in ["true", "false"]:
|
|
827
|
+
with self.sql_conf({"spark.sql.columnVector.offheap.enabled": offheap}):
|
|
828
|
+
self.assertEquals(
|
|
829
|
+
self.spark.read.parquet(path).select(fUdf("id")).head(), Row(0)
|
|
830
|
+
)
|
|
831
|
+
finally:
|
|
832
|
+
shutil.rmtree(path)
|
|
833
|
+
|
|
834
|
+
def test_udf_with_rand(self):
|
|
835
|
+
# SPARK-40121: rand() with Python UDF.
|
|
836
|
+
self.assertEqual(
|
|
837
|
+
len(self.spark.range(10).select(udf(lambda x: x, DoubleType())(rand())).collect()), 10
|
|
838
|
+
)
|
|
839
|
+
|
|
840
|
+
def test_nested_struct(self):
|
|
841
|
+
df = self.spark.range(1).selectExpr(
|
|
842
|
+
"struct(1, struct('John', 30, ('value', 10))) as nested_struct"
|
|
843
|
+
)
|
|
844
|
+
# Input
|
|
845
|
+
row = df.select(udf(lambda x: str(x))("nested_struct")).first()
|
|
846
|
+
self.assertEquals(
|
|
847
|
+
row[0], "Row(col1=1, col2=Row(col1='John', col2=30, col3=Row(col1='value', col2=10)))"
|
|
848
|
+
)
|
|
849
|
+
# Output
|
|
850
|
+
row = df.select(udf(lambda x: x, returnType=df.dtypes[0][1])("nested_struct")).first()
|
|
851
|
+
self.assertEquals(
|
|
852
|
+
row[0], Row(col1=1, col2=Row(col1="John", col2=30, col3=Row(col1="value", col2=10)))
|
|
853
|
+
)
|
|
854
|
+
|
|
855
|
+
def test_nested_map(self):
|
|
856
|
+
df = self.spark.range(1).selectExpr("map('a', map('b', 'c')) as nested_map")
|
|
857
|
+
# Input
|
|
858
|
+
row = df.select(udf(lambda x: str(x))("nested_map")).first()
|
|
859
|
+
self.assertEquals(row[0], "{'a': {'b': 'c'}}")
|
|
860
|
+
# Output
|
|
861
|
+
|
|
862
|
+
@udf(returnType=df.dtypes[0][1])
|
|
863
|
+
def f(x):
|
|
864
|
+
x["a"]["b"] = "d"
|
|
865
|
+
return x
|
|
866
|
+
|
|
867
|
+
row = df.select(f("nested_map")).first()
|
|
868
|
+
self.assertEquals(row[0], {"a": {"b": "d"}})
|
|
869
|
+
|
|
870
|
+
def test_nested_array(self):
|
|
871
|
+
df = self.spark.range(1).selectExpr("array(array(1, 2), array(3, 4)) as nested_array")
|
|
872
|
+
# Input
|
|
873
|
+
row = df.select(udf(lambda x: str(x))("nested_array")).first()
|
|
874
|
+
self.assertEquals(row[0], "[[1, 2], [3, 4]]")
|
|
875
|
+
# Output
|
|
876
|
+
|
|
877
|
+
@udf(returnType=df.dtypes[0][1])
|
|
878
|
+
def f(x):
|
|
879
|
+
x.append([4, 5])
|
|
880
|
+
return x
|
|
881
|
+
|
|
882
|
+
row = df.select(f("nested_array")).first()
|
|
883
|
+
self.assertEquals(row[0], [[1, 2], [3, 4], [4, 5]])
|
|
884
|
+
|
|
885
|
+
def test_complex_return_types(self):
|
|
886
|
+
row = (
|
|
887
|
+
self.spark.range(1)
|
|
888
|
+
.selectExpr("array(1, 2, 3) as array", "map('a', 'b') as map", "struct(1, 2) as struct")
|
|
889
|
+
.select(
|
|
890
|
+
udf(lambda x: x, "array<int>")("array"),
|
|
891
|
+
udf(lambda x: x, "map<string,string>")("map"),
|
|
892
|
+
udf(lambda x: x, "struct<col1:int,col2:int>")("struct"),
|
|
893
|
+
)
|
|
894
|
+
.first()
|
|
895
|
+
)
|
|
896
|
+
|
|
897
|
+
self.assertEquals(row[0], [1, 2, 3])
|
|
898
|
+
self.assertEquals(row[1], {"a": "b"})
|
|
899
|
+
self.assertEquals(row[2], Row(col1=1, col2=2))
|
|
900
|
+
|
|
901
|
+
def test_raise_stop_iteration(self):
|
|
902
|
+
@udf("int")
|
|
903
|
+
def test_udf(a):
|
|
904
|
+
if a < 5:
|
|
905
|
+
return a
|
|
906
|
+
else:
|
|
907
|
+
raise StopIteration()
|
|
908
|
+
|
|
909
|
+
assertDataFrameEqual(
|
|
910
|
+
self.spark.range(5).select(test_udf(col("id"))), [Row(i) for i in range(5)]
|
|
911
|
+
)
|
|
912
|
+
|
|
913
|
+
with self.assertRaisesRegex(PythonException, "StopIteration"):
|
|
914
|
+
self.spark.range(10).select(test_udf(col("id"))).show()
|
|
915
|
+
|
|
916
|
+
|
|
917
|
+
class UDFTests(BaseUDFTestsMixin, ReusedSQLTestCase):
|
|
918
|
+
@classmethod
|
|
919
|
+
def setUpClass(cls):
|
|
920
|
+
super(BaseUDFTestsMixin, cls).setUpClass()
|
|
921
|
+
cls.spark.conf.set("spark.sql.execution.pythonUDF.arrow.enabled", "false")
|
|
922
|
+
|
|
923
|
+
|
|
924
|
+
class UDFInitializationTests(unittest.TestCase):
|
|
925
|
+
def tearDown(self):
|
|
926
|
+
if SparkSession._instantiatedSession is not None:
|
|
927
|
+
SparkSession._instantiatedSession.stop()
|
|
928
|
+
|
|
929
|
+
if SparkContext._active_spark_context is not None:
|
|
930
|
+
SparkContext._active_spark_context.stop()
|
|
931
|
+
|
|
932
|
+
def test_udf_init_should_not_initialize_context(self):
|
|
933
|
+
UserDefinedFunction(lambda x: x, StringType())
|
|
934
|
+
|
|
935
|
+
self.assertIsNone(
|
|
936
|
+
SparkContext._active_spark_context,
|
|
937
|
+
"SparkContext shouldn't be initialized when UserDefinedFunction is created.",
|
|
938
|
+
)
|
|
939
|
+
self.assertIsNone(
|
|
940
|
+
SparkSession._instantiatedSession,
|
|
941
|
+
"SparkSession shouldn't be initialized when UserDefinedFunction is created.",
|
|
942
|
+
)
|
|
943
|
+
|
|
944
|
+
def test_err_parse_type_when_no_sc(self):
|
|
945
|
+
with self.assertRaisesRegex(
|
|
946
|
+
RuntimeError,
|
|
947
|
+
"SparkContext or SparkSession should be created first",
|
|
948
|
+
):
|
|
949
|
+
udf(lambda x: x, "integer")
|
|
950
|
+
|
|
951
|
+
|
|
952
|
+
if __name__ == "__main__":
|
|
953
|
+
from pyspark.sql.tests.test_udf import * # noqa: F401
|
|
954
|
+
|
|
955
|
+
try:
|
|
956
|
+
import xmlrunner # type: ignore
|
|
957
|
+
|
|
958
|
+
testRunner = xmlrunner.XMLTestRunner(output="target/test-reports", verbosity=2)
|
|
959
|
+
except ImportError:
|
|
960
|
+
testRunner = None
|
|
961
|
+
unittest.main(testRunner=testRunner, verbosity=2)
|