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,1581 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
|
4
|
+
# contributor license agreements. See the NOTICE file distributed with
|
|
5
|
+
# this work for additional information regarding copyright ownership.
|
|
6
|
+
# The ASF licenses this file to You under the Apache License, Version 2.0
|
|
7
|
+
# (the "License"); you may not use this file except in compliance with
|
|
8
|
+
# the License. You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
#
|
|
18
|
+
|
|
19
|
+
import array
|
|
20
|
+
import ctypes
|
|
21
|
+
import datetime
|
|
22
|
+
import os
|
|
23
|
+
import pickle
|
|
24
|
+
import sys
|
|
25
|
+
import unittest
|
|
26
|
+
|
|
27
|
+
from pyspark.sql import Row
|
|
28
|
+
from pyspark.sql import functions as F
|
|
29
|
+
from pyspark.errors import AnalysisException, PySparkTypeError, PySparkValueError
|
|
30
|
+
from pyspark.sql.types import (
|
|
31
|
+
ByteType,
|
|
32
|
+
ShortType,
|
|
33
|
+
IntegerType,
|
|
34
|
+
FloatType,
|
|
35
|
+
DateType,
|
|
36
|
+
TimestampType,
|
|
37
|
+
DayTimeIntervalType,
|
|
38
|
+
YearMonthIntervalType,
|
|
39
|
+
MapType,
|
|
40
|
+
StringType,
|
|
41
|
+
CharType,
|
|
42
|
+
VarcharType,
|
|
43
|
+
StructType,
|
|
44
|
+
StructField,
|
|
45
|
+
ArrayType,
|
|
46
|
+
DoubleType,
|
|
47
|
+
LongType,
|
|
48
|
+
DecimalType,
|
|
49
|
+
BinaryType,
|
|
50
|
+
BooleanType,
|
|
51
|
+
NullType,
|
|
52
|
+
)
|
|
53
|
+
from pyspark.sql.types import (
|
|
54
|
+
_array_signed_int_typecode_ctype_mappings,
|
|
55
|
+
_array_type_mappings,
|
|
56
|
+
_array_unsigned_int_typecode_ctype_mappings,
|
|
57
|
+
_infer_type,
|
|
58
|
+
_make_type_verifier,
|
|
59
|
+
_merge_type,
|
|
60
|
+
)
|
|
61
|
+
from pyspark.testing.objects import (
|
|
62
|
+
ExamplePointUDT,
|
|
63
|
+
PythonOnlyUDT,
|
|
64
|
+
ExamplePoint,
|
|
65
|
+
PythonOnlyPoint,
|
|
66
|
+
MyObject,
|
|
67
|
+
)
|
|
68
|
+
from pyspark.testing.sqlutils import ReusedSQLTestCase
|
|
69
|
+
from pyspark.testing.utils import PySparkErrorTestUtils
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
class TypesTestsMixin:
|
|
73
|
+
def test_apply_schema_to_row(self):
|
|
74
|
+
df = self.spark.read.json(self.sc.parallelize(["""{"a":2}"""]))
|
|
75
|
+
df2 = self.spark.createDataFrame(df.rdd.map(lambda x: x), df.schema)
|
|
76
|
+
self.assertEqual(df.collect(), df2.collect())
|
|
77
|
+
|
|
78
|
+
rdd = self.sc.parallelize(range(10)).map(lambda x: Row(a=x))
|
|
79
|
+
df3 = self.spark.createDataFrame(rdd, df.schema)
|
|
80
|
+
self.assertEqual(10, df3.count())
|
|
81
|
+
|
|
82
|
+
def test_infer_schema_to_local(self):
|
|
83
|
+
input = [{"a": 1}, {"b": "coffee"}]
|
|
84
|
+
rdd = self.sc.parallelize(input)
|
|
85
|
+
df = self.spark.createDataFrame(input)
|
|
86
|
+
df2 = self.spark.createDataFrame(rdd, samplingRatio=1.0)
|
|
87
|
+
self.assertEqual(df.schema, df2.schema)
|
|
88
|
+
|
|
89
|
+
rdd = self.sc.parallelize(range(10)).map(lambda x: Row(a=x, b=None))
|
|
90
|
+
df3 = self.spark.createDataFrame(rdd, df.schema)
|
|
91
|
+
self.assertEqual(10, df3.count())
|
|
92
|
+
|
|
93
|
+
def test_apply_schema_to_dict_and_rows(self):
|
|
94
|
+
schema = StructType().add("a", IntegerType()).add("b", StringType())
|
|
95
|
+
input = [{"a": 1}, {"b": "coffee"}]
|
|
96
|
+
rdd = self.sc.parallelize(input)
|
|
97
|
+
for verify in [False, True]:
|
|
98
|
+
df = self.spark.createDataFrame(input, schema, verifySchema=verify)
|
|
99
|
+
df2 = self.spark.createDataFrame(rdd, schema, verifySchema=verify)
|
|
100
|
+
self.assertEqual(df.schema, df2.schema)
|
|
101
|
+
|
|
102
|
+
rdd = self.sc.parallelize(range(10)).map(lambda x: Row(a=x, b=None))
|
|
103
|
+
df3 = self.spark.createDataFrame(rdd, schema, verifySchema=verify)
|
|
104
|
+
self.assertEqual(10, df3.count())
|
|
105
|
+
input = [Row(a=x, b=str(x)) for x in range(10)]
|
|
106
|
+
df4 = self.spark.createDataFrame(input, schema, verifySchema=verify)
|
|
107
|
+
self.assertEqual(10, df4.count())
|
|
108
|
+
|
|
109
|
+
def test_create_dataframe_schema_mismatch(self):
|
|
110
|
+
rdd = self.sc.parallelize(range(3)).map(lambda i: Row(a=i))
|
|
111
|
+
schema = StructType([StructField("a", IntegerType()), StructField("b", StringType())])
|
|
112
|
+
df = self.spark.createDataFrame(rdd, schema)
|
|
113
|
+
self.assertRaises(Exception, lambda: df.show())
|
|
114
|
+
|
|
115
|
+
def test_infer_schema(self):
|
|
116
|
+
d = [Row(l=[], d={}, s=None), Row(l=[Row(a=1, b="s")], d={"key": Row(c=1.0, d="2")}, s="")]
|
|
117
|
+
rdd = self.sc.parallelize(d)
|
|
118
|
+
df = self.spark.createDataFrame(rdd)
|
|
119
|
+
self.assertEqual([], df.rdd.map(lambda r: r.l).first())
|
|
120
|
+
self.assertEqual([None, ""], df.rdd.map(lambda r: r.s).collect())
|
|
121
|
+
|
|
122
|
+
with self.tempView("test"):
|
|
123
|
+
df.createOrReplaceTempView("test")
|
|
124
|
+
result = self.spark.sql("SELECT l from test")
|
|
125
|
+
self.assertEqual([], result.head()[0])
|
|
126
|
+
# We set `spark.sql.ansi.enabled` to False for this case
|
|
127
|
+
# since it occurs an error in ANSI mode if there is a list index
|
|
128
|
+
# or key that does not exist.
|
|
129
|
+
with self.sql_conf({"spark.sql.ansi.enabled": False}):
|
|
130
|
+
result = self.spark.sql("SELECT l[0].a from test where d['key'].d = '2'")
|
|
131
|
+
self.assertEqual(1, result.head()[0])
|
|
132
|
+
|
|
133
|
+
df2 = self.spark.createDataFrame(rdd, samplingRatio=1.0)
|
|
134
|
+
self.assertEqual(df.schema, df2.schema)
|
|
135
|
+
self.assertEqual({}, df2.rdd.map(lambda r: r.d).first())
|
|
136
|
+
self.assertEqual([None, ""], df2.rdd.map(lambda r: r.s).collect())
|
|
137
|
+
|
|
138
|
+
with self.tempView("test2"):
|
|
139
|
+
df2.createOrReplaceTempView("test2")
|
|
140
|
+
result = self.spark.sql("SELECT l from test2")
|
|
141
|
+
self.assertEqual([], result.head()[0])
|
|
142
|
+
# We set `spark.sql.ansi.enabled` to False for this case
|
|
143
|
+
# since it occurs an error in ANSI mode if there is a list index
|
|
144
|
+
# or key that does not exist.
|
|
145
|
+
with self.sql_conf({"spark.sql.ansi.enabled": False}):
|
|
146
|
+
result = self.spark.sql("SELECT l[0].a from test2 where d['key'].d = '2'")
|
|
147
|
+
self.assertEqual(1, result.head()[0])
|
|
148
|
+
|
|
149
|
+
def test_infer_schema_specification(self):
|
|
150
|
+
from decimal import Decimal
|
|
151
|
+
|
|
152
|
+
class A:
|
|
153
|
+
def __init__(self):
|
|
154
|
+
self.a = 1
|
|
155
|
+
|
|
156
|
+
data = [
|
|
157
|
+
True,
|
|
158
|
+
1,
|
|
159
|
+
"a",
|
|
160
|
+
"a",
|
|
161
|
+
datetime.date(1970, 1, 1),
|
|
162
|
+
datetime.datetime(1970, 1, 1, 0, 0),
|
|
163
|
+
datetime.timedelta(microseconds=123456678),
|
|
164
|
+
1.0,
|
|
165
|
+
array.array("d", [1]),
|
|
166
|
+
[1],
|
|
167
|
+
(1,),
|
|
168
|
+
{"a": 1},
|
|
169
|
+
bytearray(1),
|
|
170
|
+
Decimal(1),
|
|
171
|
+
Row(a=1),
|
|
172
|
+
Row("a")(1),
|
|
173
|
+
A(),
|
|
174
|
+
]
|
|
175
|
+
|
|
176
|
+
df = self.spark.createDataFrame([data])
|
|
177
|
+
actual = list(map(lambda x: x.dataType.simpleString(), df.schema))
|
|
178
|
+
expected = [
|
|
179
|
+
"boolean",
|
|
180
|
+
"bigint",
|
|
181
|
+
"string",
|
|
182
|
+
"string",
|
|
183
|
+
"date",
|
|
184
|
+
"timestamp",
|
|
185
|
+
"interval day to second",
|
|
186
|
+
"double",
|
|
187
|
+
"array<double>",
|
|
188
|
+
"array<bigint>",
|
|
189
|
+
"struct<_1:bigint>",
|
|
190
|
+
"map<string,bigint>",
|
|
191
|
+
"binary",
|
|
192
|
+
"decimal(38,18)",
|
|
193
|
+
"struct<a:bigint>",
|
|
194
|
+
"struct<a:bigint>",
|
|
195
|
+
"struct<a:bigint>",
|
|
196
|
+
]
|
|
197
|
+
self.assertEqual(actual, expected)
|
|
198
|
+
|
|
199
|
+
actual = list(df.first())
|
|
200
|
+
expected = [
|
|
201
|
+
True,
|
|
202
|
+
1,
|
|
203
|
+
"a",
|
|
204
|
+
"a",
|
|
205
|
+
datetime.date(1970, 1, 1),
|
|
206
|
+
datetime.datetime(1970, 1, 1, 0, 0),
|
|
207
|
+
datetime.timedelta(microseconds=123456678),
|
|
208
|
+
1.0,
|
|
209
|
+
[1.0],
|
|
210
|
+
[1],
|
|
211
|
+
Row(_1=1),
|
|
212
|
+
{"a": 1},
|
|
213
|
+
bytearray(b"\x00"),
|
|
214
|
+
Decimal("1.000000000000000000"),
|
|
215
|
+
Row(a=1),
|
|
216
|
+
Row(a=1),
|
|
217
|
+
Row(a=1),
|
|
218
|
+
]
|
|
219
|
+
self.assertEqual(actual, expected)
|
|
220
|
+
|
|
221
|
+
with self.sql_conf({"spark.sql.timestampType": "TIMESTAMP_NTZ"}):
|
|
222
|
+
with self.sql_conf({"spark.sql.session.timeZone": "America/Sao_Paulo"}):
|
|
223
|
+
df = self.spark.createDataFrame([(datetime.datetime(1970, 1, 1, 0, 0),)])
|
|
224
|
+
self.assertEqual(list(df.schema)[0].dataType.simpleString(), "timestamp_ntz")
|
|
225
|
+
self.assertEqual(df.first()[0], datetime.datetime(1970, 1, 1, 0, 0))
|
|
226
|
+
|
|
227
|
+
df = self.spark.createDataFrame(
|
|
228
|
+
[
|
|
229
|
+
(datetime.datetime(1970, 1, 1, 0, 0),),
|
|
230
|
+
(datetime.datetime(1970, 1, 1, 0, 0, tzinfo=datetime.timezone.utc),),
|
|
231
|
+
]
|
|
232
|
+
)
|
|
233
|
+
self.assertEqual(list(df.schema)[0].dataType.simpleString(), "timestamp")
|
|
234
|
+
|
|
235
|
+
def test_infer_schema_not_enough_names(self):
|
|
236
|
+
df = self.spark.createDataFrame([["a", "b"]], ["col1"])
|
|
237
|
+
self.assertEqual(df.columns, ["col1", "_2"])
|
|
238
|
+
|
|
239
|
+
def test_infer_schema_upcast_int_to_string(self):
|
|
240
|
+
df = self.spark.createDataFrame(
|
|
241
|
+
self.spark.sparkContext.parallelize([[1, 1], ["x", 1]]),
|
|
242
|
+
schema=["a", "b"],
|
|
243
|
+
samplingRatio=0.99,
|
|
244
|
+
)
|
|
245
|
+
self.assertEqual([Row(a="1", b=1), Row(a="x", b=1)], df.collect())
|
|
246
|
+
|
|
247
|
+
def test_infer_schema_upcast_float_to_string(self):
|
|
248
|
+
df = self.spark.createDataFrame([[1.33, 1], ["2.1", 1]], schema=["a", "b"])
|
|
249
|
+
self.assertEqual([Row(a="1.33", b=1), Row(a="2.1", b=1)], df.collect())
|
|
250
|
+
|
|
251
|
+
def test_infer_schema_upcast_boolean_to_string(self):
|
|
252
|
+
df = self.spark.createDataFrame([[True, 1], ["false", 1]], schema=["a", "b"])
|
|
253
|
+
self.assertEqual([Row(a="true", b=1), Row(a="false", b=1)], df.collect())
|
|
254
|
+
|
|
255
|
+
def test_infer_nested_schema(self):
|
|
256
|
+
NestedRow = Row("f1", "f2")
|
|
257
|
+
nestedRdd1 = self.sc.parallelize(
|
|
258
|
+
[NestedRow([1, 2], {"row1": 1.0}), NestedRow([2, 3], {"row2": 2.0})]
|
|
259
|
+
)
|
|
260
|
+
df = self.spark.createDataFrame(nestedRdd1)
|
|
261
|
+
self.assertEqual(Row(f1=[1, 2], f2={"row1": 1.0}), df.collect()[0])
|
|
262
|
+
|
|
263
|
+
nestedRdd2 = self.sc.parallelize(
|
|
264
|
+
[NestedRow([[1, 2], [2, 3]], [1, 2]), NestedRow([[2, 3], [3, 4]], [2, 3])]
|
|
265
|
+
)
|
|
266
|
+
df = self.spark.createDataFrame(nestedRdd2)
|
|
267
|
+
self.assertEqual(Row(f1=[[1, 2], [2, 3]], f2=[1, 2]), df.collect()[0])
|
|
268
|
+
|
|
269
|
+
from collections import namedtuple
|
|
270
|
+
|
|
271
|
+
CustomRow = namedtuple("CustomRow", "field1 field2")
|
|
272
|
+
rdd = self.sc.parallelize(
|
|
273
|
+
[
|
|
274
|
+
CustomRow(field1=1, field2="row1"),
|
|
275
|
+
CustomRow(field1=2, field2="row2"),
|
|
276
|
+
CustomRow(field1=3, field2="row3"),
|
|
277
|
+
]
|
|
278
|
+
)
|
|
279
|
+
df = self.spark.createDataFrame(rdd)
|
|
280
|
+
self.assertEqual(Row(field1=1, field2="row1"), df.first())
|
|
281
|
+
|
|
282
|
+
def test_infer_nested_dict_as_struct(self):
|
|
283
|
+
# SPARK-35929: Test inferring nested dict as a struct type.
|
|
284
|
+
NestedRow = Row("f1", "f2")
|
|
285
|
+
|
|
286
|
+
with self.sql_conf({"spark.sql.pyspark.inferNestedDictAsStruct.enabled": True}):
|
|
287
|
+
data = [
|
|
288
|
+
NestedRow([{"payment": 200.5, "name": "A"}], [1, 2]),
|
|
289
|
+
NestedRow([{"payment": 100.5, "name": "B"}], [2, 3]),
|
|
290
|
+
]
|
|
291
|
+
|
|
292
|
+
df = self.spark.createDataFrame(data)
|
|
293
|
+
self.assertEqual(Row(f1=[Row(payment=200.5, name="A")], f2=[1, 2]), df.first())
|
|
294
|
+
|
|
295
|
+
def test_infer_nested_dict_as_struct_with_rdd(self):
|
|
296
|
+
# SPARK-35929: Test inferring nested dict as a struct type.
|
|
297
|
+
NestedRow = Row("f1", "f2")
|
|
298
|
+
|
|
299
|
+
with self.sql_conf({"spark.sql.pyspark.inferNestedDictAsStruct.enabled": True}):
|
|
300
|
+
data = [
|
|
301
|
+
NestedRow([{"payment": 200.5, "name": "A"}], [1, 2]),
|
|
302
|
+
NestedRow([{"payment": 100.5, "name": "B"}], [2, 3]),
|
|
303
|
+
]
|
|
304
|
+
|
|
305
|
+
nestedRdd = self.sc.parallelize(data)
|
|
306
|
+
df = self.spark.createDataFrame(nestedRdd)
|
|
307
|
+
self.assertEqual(Row(f1=[Row(payment=200.5, name="A")], f2=[1, 2]), df.first())
|
|
308
|
+
|
|
309
|
+
def test_infer_array_merge_element_types(self):
|
|
310
|
+
# SPARK-39168: Test inferring array element type from all values in array
|
|
311
|
+
ArrayRow = Row("f1", "f2")
|
|
312
|
+
|
|
313
|
+
data = [ArrayRow([1, None], [None, 2])]
|
|
314
|
+
|
|
315
|
+
df = self.spark.createDataFrame(data)
|
|
316
|
+
self.assertEqual(Row(f1=[1, None], f2=[None, 2]), df.first())
|
|
317
|
+
|
|
318
|
+
# Test legacy behavior inferring only from the first element
|
|
319
|
+
with self.sql_conf(
|
|
320
|
+
{"spark.sql.pyspark.legacy.inferArrayTypeFromFirstElement.enabled": True}
|
|
321
|
+
):
|
|
322
|
+
# Legacy: f2 schema inferred as an array of nulls, should raise error
|
|
323
|
+
self.assertRaises(ValueError, lambda: self.spark.createDataFrame(data))
|
|
324
|
+
|
|
325
|
+
# an array with only null values should raise an error
|
|
326
|
+
data2 = [ArrayRow([1], [None])]
|
|
327
|
+
self.assertRaises(ValueError, lambda: self.spark.createDataFrame(data2))
|
|
328
|
+
|
|
329
|
+
# an array with no values should raise an error
|
|
330
|
+
data3 = [ArrayRow([1], [])]
|
|
331
|
+
self.assertRaises(ValueError, lambda: self.spark.createDataFrame(data3))
|
|
332
|
+
|
|
333
|
+
# an array with conflicting types should raise an error
|
|
334
|
+
# in this case this is ArrayType(StringType) and ArrayType(NullType)
|
|
335
|
+
data4 = [ArrayRow([1, "1"], [None])]
|
|
336
|
+
with self.assertRaisesRegex(ValueError, "types cannot be determined after inferring"):
|
|
337
|
+
self.spark.createDataFrame(data4)
|
|
338
|
+
|
|
339
|
+
def test_infer_array_merge_element_types_with_rdd(self):
|
|
340
|
+
# SPARK-39168: Test inferring array element type from all values in array
|
|
341
|
+
ArrayRow = Row("f1", "f2")
|
|
342
|
+
|
|
343
|
+
data = [ArrayRow([1, None], [None, 2])]
|
|
344
|
+
|
|
345
|
+
rdd = self.sc.parallelize(data)
|
|
346
|
+
df = self.spark.createDataFrame(rdd)
|
|
347
|
+
self.assertEqual(Row(f1=[1, None], f2=[None, 2]), df.first())
|
|
348
|
+
|
|
349
|
+
def test_infer_array_element_type_empty(self):
|
|
350
|
+
# SPARK-39168: Test inferring array element type from all rows
|
|
351
|
+
ArrayRow = Row("f1")
|
|
352
|
+
|
|
353
|
+
data = [ArrayRow([]), ArrayRow([None]), ArrayRow([1])]
|
|
354
|
+
|
|
355
|
+
rdd = self.sc.parallelize(data)
|
|
356
|
+
df = self.spark.createDataFrame(rdd)
|
|
357
|
+
rows = df.collect()
|
|
358
|
+
self.assertEqual(Row(f1=[]), rows[0])
|
|
359
|
+
self.assertEqual(Row(f1=[None]), rows[1])
|
|
360
|
+
self.assertEqual(Row(f1=[1]), rows[2])
|
|
361
|
+
|
|
362
|
+
df = self.spark.createDataFrame(data)
|
|
363
|
+
rows = df.collect()
|
|
364
|
+
self.assertEqual(Row(f1=[]), rows[0])
|
|
365
|
+
self.assertEqual(Row(f1=[None]), rows[1])
|
|
366
|
+
self.assertEqual(Row(f1=[1]), rows[2])
|
|
367
|
+
|
|
368
|
+
def test_infer_array_element_type_with_struct(self):
|
|
369
|
+
# SPARK-39168: Test inferring array of struct type from all struct values
|
|
370
|
+
NestedRow = Row("f1")
|
|
371
|
+
|
|
372
|
+
with self.sql_conf({"spark.sql.pyspark.inferNestedDictAsStruct.enabled": True}):
|
|
373
|
+
data = [NestedRow([{"payment": 200.5}, {"name": "A"}])]
|
|
374
|
+
|
|
375
|
+
nestedRdd = self.sc.parallelize(data)
|
|
376
|
+
df = self.spark.createDataFrame(nestedRdd)
|
|
377
|
+
self.assertEqual(
|
|
378
|
+
Row(f1=[Row(payment=200.5, name=None), Row(payment=None, name="A")]), df.first()
|
|
379
|
+
)
|
|
380
|
+
|
|
381
|
+
df = self.spark.createDataFrame(data)
|
|
382
|
+
self.assertEqual(
|
|
383
|
+
Row(f1=[Row(payment=200.5, name=None), Row(payment=None, name="A")]), df.first()
|
|
384
|
+
)
|
|
385
|
+
|
|
386
|
+
# Test legacy behavior inferring only from the first element; excludes "name" field
|
|
387
|
+
with self.sql_conf(
|
|
388
|
+
{"spark.sql.pyspark.legacy.inferArrayTypeFromFirstElement.enabled": True}
|
|
389
|
+
):
|
|
390
|
+
df = self.spark.createDataFrame(data)
|
|
391
|
+
self.assertEqual(Row(f1=[Row(payment=200.5), Row(payment=None)]), df.first())
|
|
392
|
+
|
|
393
|
+
def test_create_dataframe_from_dict_respects_schema(self):
|
|
394
|
+
df = self.spark.createDataFrame([{"a": 1}], ["b"])
|
|
395
|
+
self.assertEqual(df.columns, ["b"])
|
|
396
|
+
|
|
397
|
+
def test_negative_decimal(self):
|
|
398
|
+
try:
|
|
399
|
+
self.spark.sql("set spark.sql.legacy.allowNegativeScaleOfDecimal=true")
|
|
400
|
+
df = self.spark.createDataFrame([(1,), (11,)], ["value"])
|
|
401
|
+
ret = df.select(F.col("value").cast(DecimalType(1, -1))).collect()
|
|
402
|
+
actual = list(map(lambda r: int(r.value), ret))
|
|
403
|
+
self.assertEqual(actual, [0, 10])
|
|
404
|
+
finally:
|
|
405
|
+
self.spark.sql("set spark.sql.legacy.allowNegativeScaleOfDecimal=false")
|
|
406
|
+
|
|
407
|
+
def test_create_dataframe_from_objects(self):
|
|
408
|
+
data = [MyObject(1, "1"), MyObject(2, "2")]
|
|
409
|
+
df = self.spark.createDataFrame(data)
|
|
410
|
+
self.assertEqual(df.dtypes, [("key", "bigint"), ("value", "string")])
|
|
411
|
+
self.assertEqual(df.first(), Row(key=1, value="1"))
|
|
412
|
+
|
|
413
|
+
def test_apply_schema(self):
|
|
414
|
+
from datetime import date, datetime, timedelta
|
|
415
|
+
|
|
416
|
+
rdd = self.sc.parallelize(
|
|
417
|
+
[
|
|
418
|
+
(
|
|
419
|
+
127,
|
|
420
|
+
-128,
|
|
421
|
+
-32768,
|
|
422
|
+
32767,
|
|
423
|
+
2147483647,
|
|
424
|
+
1.0,
|
|
425
|
+
date(2010, 1, 1),
|
|
426
|
+
datetime(2010, 1, 1, 1, 1, 1),
|
|
427
|
+
timedelta(days=1),
|
|
428
|
+
{"a": 1},
|
|
429
|
+
(2,),
|
|
430
|
+
[1, 2, 3],
|
|
431
|
+
None,
|
|
432
|
+
)
|
|
433
|
+
]
|
|
434
|
+
)
|
|
435
|
+
schema = StructType(
|
|
436
|
+
[
|
|
437
|
+
StructField("byte1", ByteType(), False),
|
|
438
|
+
StructField("byte2", ByteType(), False),
|
|
439
|
+
StructField("short1", ShortType(), False),
|
|
440
|
+
StructField("short2", ShortType(), False),
|
|
441
|
+
StructField("int1", IntegerType(), False),
|
|
442
|
+
StructField("float1", FloatType(), False),
|
|
443
|
+
StructField("date1", DateType(), False),
|
|
444
|
+
StructField("time1", TimestampType(), False),
|
|
445
|
+
StructField("daytime1", DayTimeIntervalType(), False),
|
|
446
|
+
StructField("map1", MapType(StringType(), IntegerType(), False), False),
|
|
447
|
+
StructField("struct1", StructType([StructField("b", ShortType(), False)]), False),
|
|
448
|
+
StructField("list1", ArrayType(ByteType(), False), False),
|
|
449
|
+
StructField("null1", DoubleType(), True),
|
|
450
|
+
]
|
|
451
|
+
)
|
|
452
|
+
df = self.spark.createDataFrame(rdd, schema)
|
|
453
|
+
results = df.rdd.map(
|
|
454
|
+
lambda x: (
|
|
455
|
+
x.byte1,
|
|
456
|
+
x.byte2,
|
|
457
|
+
x.short1,
|
|
458
|
+
x.short2,
|
|
459
|
+
x.int1,
|
|
460
|
+
x.float1,
|
|
461
|
+
x.date1,
|
|
462
|
+
x.time1,
|
|
463
|
+
x.daytime1,
|
|
464
|
+
x.map1["a"],
|
|
465
|
+
x.struct1.b,
|
|
466
|
+
x.list1,
|
|
467
|
+
x.null1,
|
|
468
|
+
)
|
|
469
|
+
)
|
|
470
|
+
r = (
|
|
471
|
+
127,
|
|
472
|
+
-128,
|
|
473
|
+
-32768,
|
|
474
|
+
32767,
|
|
475
|
+
2147483647,
|
|
476
|
+
1.0,
|
|
477
|
+
date(2010, 1, 1),
|
|
478
|
+
datetime(2010, 1, 1, 1, 1, 1),
|
|
479
|
+
timedelta(days=1),
|
|
480
|
+
1,
|
|
481
|
+
2,
|
|
482
|
+
[1, 2, 3],
|
|
483
|
+
None,
|
|
484
|
+
)
|
|
485
|
+
self.assertEqual(r, results.first())
|
|
486
|
+
|
|
487
|
+
with self.tempView("table2"):
|
|
488
|
+
df.createOrReplaceTempView("table2")
|
|
489
|
+
r = self.spark.sql(
|
|
490
|
+
"SELECT byte1 - 1 AS byte1, byte2 + 1 AS byte2, "
|
|
491
|
+
+ "short1 + 1 AS short1, short2 - 1 AS short2, int1 - 1 AS int1, "
|
|
492
|
+
+ "float1 + 1.5 as float1 FROM table2"
|
|
493
|
+
).first()
|
|
494
|
+
|
|
495
|
+
self.assertEqual((126, -127, -32767, 32766, 2147483646, 2.5), tuple(r))
|
|
496
|
+
|
|
497
|
+
def test_convert_row_to_dict(self):
|
|
498
|
+
row = Row(l=[Row(a=1, b="s")], d={"key": Row(c=1.0, d="2")})
|
|
499
|
+
self.assertEqual(1, row.asDict()["l"][0].a)
|
|
500
|
+
df = self.spark.createDataFrame([row])
|
|
501
|
+
|
|
502
|
+
with self.tempView("test"):
|
|
503
|
+
df.createOrReplaceTempView("test")
|
|
504
|
+
row = self.spark.sql("select l, d from test").head()
|
|
505
|
+
self.assertEqual(1, row.asDict()["l"][0].a)
|
|
506
|
+
self.assertEqual(1.0, row.asDict()["d"]["key"].c)
|
|
507
|
+
|
|
508
|
+
def test_udt(self):
|
|
509
|
+
from pyspark.sql.types import _parse_datatype_json_string, _infer_type, _make_type_verifier
|
|
510
|
+
|
|
511
|
+
def check_datatype(datatype):
|
|
512
|
+
pickled = pickle.loads(pickle.dumps(datatype))
|
|
513
|
+
assert datatype == pickled
|
|
514
|
+
scala_datatype = self.spark._jsparkSession.parseDataType(datatype.json())
|
|
515
|
+
python_datatype = _parse_datatype_json_string(scala_datatype.json())
|
|
516
|
+
assert datatype == python_datatype
|
|
517
|
+
|
|
518
|
+
check_datatype(ExamplePointUDT())
|
|
519
|
+
structtype_with_udt = StructType(
|
|
520
|
+
[
|
|
521
|
+
StructField("label", DoubleType(), False),
|
|
522
|
+
StructField("point", ExamplePointUDT(), False),
|
|
523
|
+
]
|
|
524
|
+
)
|
|
525
|
+
check_datatype(structtype_with_udt)
|
|
526
|
+
p = ExamplePoint(1.0, 2.0)
|
|
527
|
+
self.assertEqual(_infer_type(p), ExamplePointUDT())
|
|
528
|
+
_make_type_verifier(ExamplePointUDT())(ExamplePoint(1.0, 2.0))
|
|
529
|
+
self.assertRaises(ValueError, lambda: _make_type_verifier(ExamplePointUDT())([1.0, 2.0]))
|
|
530
|
+
|
|
531
|
+
check_datatype(PythonOnlyUDT())
|
|
532
|
+
structtype_with_udt = StructType(
|
|
533
|
+
[
|
|
534
|
+
StructField("label", DoubleType(), False),
|
|
535
|
+
StructField("point", PythonOnlyUDT(), False),
|
|
536
|
+
]
|
|
537
|
+
)
|
|
538
|
+
check_datatype(structtype_with_udt)
|
|
539
|
+
p = PythonOnlyPoint(1.0, 2.0)
|
|
540
|
+
self.assertEqual(_infer_type(p), PythonOnlyUDT())
|
|
541
|
+
_make_type_verifier(PythonOnlyUDT())(PythonOnlyPoint(1.0, 2.0))
|
|
542
|
+
self.assertRaises(ValueError, lambda: _make_type_verifier(PythonOnlyUDT())([1.0, 2.0]))
|
|
543
|
+
|
|
544
|
+
def test_simple_udt_in_df(self):
|
|
545
|
+
schema = StructType().add("key", LongType()).add("val", PythonOnlyUDT())
|
|
546
|
+
df = self.spark.createDataFrame(
|
|
547
|
+
[(i % 3, PythonOnlyPoint(float(i), float(i))) for i in range(10)], schema=schema
|
|
548
|
+
)
|
|
549
|
+
df.collect()
|
|
550
|
+
|
|
551
|
+
def test_nested_udt_in_df(self):
|
|
552
|
+
schema = StructType().add("key", LongType()).add("val", ArrayType(PythonOnlyUDT()))
|
|
553
|
+
df = self.spark.createDataFrame(
|
|
554
|
+
[(i % 3, [PythonOnlyPoint(float(i), float(i))]) for i in range(10)], schema=schema
|
|
555
|
+
)
|
|
556
|
+
df.collect()
|
|
557
|
+
|
|
558
|
+
schema = (
|
|
559
|
+
StructType().add("key", LongType()).add("val", MapType(LongType(), PythonOnlyUDT()))
|
|
560
|
+
)
|
|
561
|
+
df = self.spark.createDataFrame(
|
|
562
|
+
[(i % 3, {i % 3: PythonOnlyPoint(float(i + 1), float(i + 1))}) for i in range(10)],
|
|
563
|
+
schema=schema,
|
|
564
|
+
)
|
|
565
|
+
df.collect()
|
|
566
|
+
|
|
567
|
+
def test_complex_nested_udt_in_df(self):
|
|
568
|
+
schema = StructType().add("key", LongType()).add("val", PythonOnlyUDT())
|
|
569
|
+
df = self.spark.createDataFrame(
|
|
570
|
+
[(i % 3, PythonOnlyPoint(float(i), float(i))) for i in range(10)], schema=schema
|
|
571
|
+
)
|
|
572
|
+
df.collect()
|
|
573
|
+
|
|
574
|
+
gd = df.groupby("key").agg({"val": "collect_list"})
|
|
575
|
+
gd.collect()
|
|
576
|
+
udf = F.udf(lambda k, v: [(k, v[0])], ArrayType(df.schema))
|
|
577
|
+
gd.select(udf(*gd)).collect()
|
|
578
|
+
|
|
579
|
+
def test_udt_with_none(self):
|
|
580
|
+
df = self.spark.range(0, 10, 1, 1)
|
|
581
|
+
|
|
582
|
+
def myudf(x):
|
|
583
|
+
if x > 0:
|
|
584
|
+
return PythonOnlyPoint(float(x), float(x))
|
|
585
|
+
|
|
586
|
+
self.spark.catalog.registerFunction("udf", myudf, PythonOnlyUDT())
|
|
587
|
+
rows = [r[0] for r in df.selectExpr("udf(id)").take(2)]
|
|
588
|
+
self.assertEqual(rows, [None, PythonOnlyPoint(1, 1)])
|
|
589
|
+
|
|
590
|
+
def test_infer_schema_with_udt(self):
|
|
591
|
+
row = Row(label=1.0, point=ExamplePoint(1.0, 2.0))
|
|
592
|
+
df = self.spark.createDataFrame([row])
|
|
593
|
+
schema = df.schema
|
|
594
|
+
field = [f for f in schema.fields if f.name == "point"][0]
|
|
595
|
+
self.assertEqual(type(field.dataType), ExamplePointUDT)
|
|
596
|
+
|
|
597
|
+
with self.tempView("labeled_point"):
|
|
598
|
+
df.createOrReplaceTempView("labeled_point")
|
|
599
|
+
point = self.spark.sql("SELECT point FROM labeled_point").head().point
|
|
600
|
+
self.assertEqual(point, ExamplePoint(1.0, 2.0))
|
|
601
|
+
|
|
602
|
+
row = Row(label=1.0, point=PythonOnlyPoint(1.0, 2.0))
|
|
603
|
+
df = self.spark.createDataFrame([row])
|
|
604
|
+
schema = df.schema
|
|
605
|
+
field = [f for f in schema.fields if f.name == "point"][0]
|
|
606
|
+
self.assertEqual(type(field.dataType), PythonOnlyUDT)
|
|
607
|
+
|
|
608
|
+
with self.tempView("labeled_point"):
|
|
609
|
+
df.createOrReplaceTempView("labeled_point")
|
|
610
|
+
point = self.spark.sql("SELECT point FROM labeled_point").head().point
|
|
611
|
+
self.assertEqual(point, PythonOnlyPoint(1.0, 2.0))
|
|
612
|
+
|
|
613
|
+
def test_infer_schema_with_udt_with_column_names(self):
|
|
614
|
+
row = (1.0, ExamplePoint(1.0, 2.0))
|
|
615
|
+
df = self.spark.createDataFrame([row], ["label", "point"])
|
|
616
|
+
schema = df.schema
|
|
617
|
+
field = [f for f in schema.fields if f.name == "point"][0]
|
|
618
|
+
self.assertEqual(type(field.dataType), ExamplePointUDT)
|
|
619
|
+
|
|
620
|
+
with self.tempView("labeled_point"):
|
|
621
|
+
df.createOrReplaceTempView("labeled_point")
|
|
622
|
+
point = self.spark.sql("SELECT point FROM labeled_point").head().point
|
|
623
|
+
self.assertEqual(point, ExamplePoint(1.0, 2.0))
|
|
624
|
+
|
|
625
|
+
row = (1.0, PythonOnlyPoint(1.0, 2.0))
|
|
626
|
+
df = self.spark.createDataFrame([row], ["label", "point"])
|
|
627
|
+
schema = df.schema
|
|
628
|
+
field = [f for f in schema.fields if f.name == "point"][0]
|
|
629
|
+
self.assertEqual(type(field.dataType), PythonOnlyUDT)
|
|
630
|
+
|
|
631
|
+
with self.tempView("labeled_point"):
|
|
632
|
+
df.createOrReplaceTempView("labeled_point")
|
|
633
|
+
point = self.spark.sql("SELECT point FROM labeled_point").head().point
|
|
634
|
+
self.assertEqual(point, PythonOnlyPoint(1.0, 2.0))
|
|
635
|
+
|
|
636
|
+
def test_apply_schema_with_udt(self):
|
|
637
|
+
row = (1.0, ExamplePoint(1.0, 2.0))
|
|
638
|
+
schema = StructType(
|
|
639
|
+
[
|
|
640
|
+
StructField("label", DoubleType(), False),
|
|
641
|
+
StructField("point", ExamplePointUDT(), False),
|
|
642
|
+
]
|
|
643
|
+
)
|
|
644
|
+
df = self.spark.createDataFrame([row], schema)
|
|
645
|
+
point = df.head().point
|
|
646
|
+
self.assertEqual(point, ExamplePoint(1.0, 2.0))
|
|
647
|
+
|
|
648
|
+
row = (1.0, PythonOnlyPoint(1.0, 2.0))
|
|
649
|
+
schema = StructType(
|
|
650
|
+
[
|
|
651
|
+
StructField("label", DoubleType(), False),
|
|
652
|
+
StructField("point", PythonOnlyUDT(), False),
|
|
653
|
+
]
|
|
654
|
+
)
|
|
655
|
+
df = self.spark.createDataFrame([row], schema)
|
|
656
|
+
point = df.head().point
|
|
657
|
+
self.assertEqual(point, PythonOnlyPoint(1.0, 2.0))
|
|
658
|
+
|
|
659
|
+
def test_apply_schema_with_nullable_udt(self):
|
|
660
|
+
rows = [(1.0, ExamplePoint(1.0, 2.0)), (2.0, None)]
|
|
661
|
+
schema = StructType(
|
|
662
|
+
[
|
|
663
|
+
StructField("label", DoubleType(), False),
|
|
664
|
+
StructField("point", ExamplePointUDT(), True),
|
|
665
|
+
]
|
|
666
|
+
)
|
|
667
|
+
df = self.spark.createDataFrame(rows, schema)
|
|
668
|
+
points = [row.point for row in df.collect()]
|
|
669
|
+
self.assertEqual(points, [ExamplePoint(1.0, 2.0), None])
|
|
670
|
+
|
|
671
|
+
rows = [(1.0, PythonOnlyPoint(1.0, 2.0)), (2.0, None)]
|
|
672
|
+
schema = StructType(
|
|
673
|
+
[
|
|
674
|
+
StructField("label", DoubleType(), False),
|
|
675
|
+
StructField("point", PythonOnlyUDT(), True),
|
|
676
|
+
]
|
|
677
|
+
)
|
|
678
|
+
df = self.spark.createDataFrame(rows, schema)
|
|
679
|
+
points = [row.point for row in df.collect()]
|
|
680
|
+
self.assertEqual(points, [PythonOnlyPoint(1.0, 2.0), None])
|
|
681
|
+
|
|
682
|
+
def test_udf_with_udt(self):
|
|
683
|
+
row = Row(label=1.0, point=ExamplePoint(1.0, 2.0))
|
|
684
|
+
df = self.spark.createDataFrame([row])
|
|
685
|
+
udf = F.udf(lambda p: p.y, DoubleType())
|
|
686
|
+
self.assertEqual(2.0, df.select(udf(df.point)).first()[0])
|
|
687
|
+
udf2 = F.udf(lambda p: ExamplePoint(p.x + 1, p.y + 1), ExamplePointUDT())
|
|
688
|
+
self.assertEqual(ExamplePoint(2.0, 3.0), df.select(udf2(df.point)).first()[0])
|
|
689
|
+
|
|
690
|
+
row = Row(label=1.0, point=PythonOnlyPoint(1.0, 2.0))
|
|
691
|
+
df = self.spark.createDataFrame([row])
|
|
692
|
+
udf = F.udf(lambda p: p.y, DoubleType())
|
|
693
|
+
self.assertEqual(2.0, df.select(udf(df.point)).first()[0])
|
|
694
|
+
udf2 = F.udf(lambda p: PythonOnlyPoint(p.x + 1, p.y + 1), PythonOnlyUDT())
|
|
695
|
+
self.assertEqual(PythonOnlyPoint(2.0, 3.0), df.select(udf2(df.point)).first()[0])
|
|
696
|
+
|
|
697
|
+
def test_rdd_with_udt(self):
|
|
698
|
+
row = Row(label=1.0, point=ExamplePoint(1.0, 2.0))
|
|
699
|
+
df = self.spark.createDataFrame([row])
|
|
700
|
+
self.assertEqual(1.0, df.rdd.map(lambda r: r.point.x).first())
|
|
701
|
+
|
|
702
|
+
row = Row(label=1.0, point=PythonOnlyPoint(1.0, 2.0))
|
|
703
|
+
df = self.spark.createDataFrame([row])
|
|
704
|
+
self.assertEqual(1.0, df.rdd.map(lambda r: r.point.x).first())
|
|
705
|
+
|
|
706
|
+
def test_parquet_with_udt(self):
|
|
707
|
+
row = Row(label=1.0, point=ExamplePoint(1.0, 2.0))
|
|
708
|
+
df0 = self.spark.createDataFrame([row])
|
|
709
|
+
output_dir = os.path.join(self.tempdir.name, "labeled_point")
|
|
710
|
+
df0.write.parquet(output_dir)
|
|
711
|
+
df1 = self.spark.read.parquet(output_dir)
|
|
712
|
+
point = df1.head().point
|
|
713
|
+
self.assertEqual(point, ExamplePoint(1.0, 2.0))
|
|
714
|
+
|
|
715
|
+
row = Row(label=1.0, point=PythonOnlyPoint(1.0, 2.0))
|
|
716
|
+
df0 = self.spark.createDataFrame([row])
|
|
717
|
+
df0.write.parquet(output_dir, mode="overwrite")
|
|
718
|
+
df1 = self.spark.read.parquet(output_dir)
|
|
719
|
+
point = df1.head().point
|
|
720
|
+
self.assertEqual(point, PythonOnlyPoint(1.0, 2.0))
|
|
721
|
+
|
|
722
|
+
def test_union_with_udt(self):
|
|
723
|
+
row1 = (1.0, ExamplePoint(1.0, 2.0))
|
|
724
|
+
row2 = (2.0, ExamplePoint(3.0, 4.0))
|
|
725
|
+
schema = StructType(
|
|
726
|
+
[
|
|
727
|
+
StructField("label", DoubleType(), False),
|
|
728
|
+
StructField("point", ExamplePointUDT(), False),
|
|
729
|
+
]
|
|
730
|
+
)
|
|
731
|
+
df1 = self.spark.createDataFrame([row1], schema)
|
|
732
|
+
df2 = self.spark.createDataFrame([row2], schema)
|
|
733
|
+
|
|
734
|
+
result = df1.union(df2).orderBy("label").collect()
|
|
735
|
+
self.assertEqual(
|
|
736
|
+
result,
|
|
737
|
+
[
|
|
738
|
+
Row(label=1.0, point=ExamplePoint(1.0, 2.0)),
|
|
739
|
+
Row(label=2.0, point=ExamplePoint(3.0, 4.0)),
|
|
740
|
+
],
|
|
741
|
+
)
|
|
742
|
+
|
|
743
|
+
def test_cast_to_string_with_udt(self):
|
|
744
|
+
row = (ExamplePoint(1.0, 2.0), PythonOnlyPoint(3.0, 4.0))
|
|
745
|
+
schema = StructType(
|
|
746
|
+
[
|
|
747
|
+
StructField("point", ExamplePointUDT(), False),
|
|
748
|
+
StructField("pypoint", PythonOnlyUDT(), False),
|
|
749
|
+
]
|
|
750
|
+
)
|
|
751
|
+
df = self.spark.createDataFrame([row], schema)
|
|
752
|
+
|
|
753
|
+
result = df.select(F.col("point").cast("string"), F.col("pypoint").cast("string")).head()
|
|
754
|
+
self.assertEqual(result, Row(point="(1.0, 2.0)", pypoint="[3.0, 4.0]"))
|
|
755
|
+
|
|
756
|
+
@unittest.skipIf(
|
|
757
|
+
"SPARK_SKIP_CONNECT_COMPAT_TESTS" in os.environ, "SPARK-49787: Supported since Spark 4.0.0"
|
|
758
|
+
)
|
|
759
|
+
def test_cast_to_udt_with_udt(self):
|
|
760
|
+
row = Row(point=ExamplePoint(1.0, 2.0), python_only_point=PythonOnlyPoint(1.0, 2.0))
|
|
761
|
+
df = self.spark.createDataFrame([row])
|
|
762
|
+
with self.assertRaises(AnalysisException):
|
|
763
|
+
df.select(F.col("point").cast(PythonOnlyUDT())).collect()
|
|
764
|
+
with self.assertRaises(AnalysisException):
|
|
765
|
+
df.select(F.col("python_only_point").cast(ExamplePointUDT())).collect()
|
|
766
|
+
|
|
767
|
+
def test_struct_type(self):
|
|
768
|
+
struct1 = StructType().add("f1", StringType(), True).add("f2", StringType(), True, None)
|
|
769
|
+
struct2 = StructType(
|
|
770
|
+
[StructField("f1", StringType(), True), StructField("f2", StringType(), True, None)]
|
|
771
|
+
)
|
|
772
|
+
self.assertEqual(struct1.fieldNames(), struct2.names)
|
|
773
|
+
self.assertEqual(struct1, struct2)
|
|
774
|
+
|
|
775
|
+
struct1 = StructType().add("f1", StringType(), True).add("f2", StringType(), True, None)
|
|
776
|
+
struct2 = StructType([StructField("f1", StringType(), True)])
|
|
777
|
+
self.assertNotEqual(struct1.fieldNames(), struct2.names)
|
|
778
|
+
self.assertNotEqual(struct1, struct2)
|
|
779
|
+
|
|
780
|
+
struct1 = (
|
|
781
|
+
StructType()
|
|
782
|
+
.add(StructField("f1", StringType(), True))
|
|
783
|
+
.add(StructField("f2", StringType(), True, None))
|
|
784
|
+
)
|
|
785
|
+
struct2 = StructType(
|
|
786
|
+
[StructField("f1", StringType(), True), StructField("f2", StringType(), True, None)]
|
|
787
|
+
)
|
|
788
|
+
self.assertEqual(struct1.fieldNames(), struct2.names)
|
|
789
|
+
self.assertEqual(struct1, struct2)
|
|
790
|
+
|
|
791
|
+
struct1 = (
|
|
792
|
+
StructType()
|
|
793
|
+
.add(StructField("f1", StringType(), True))
|
|
794
|
+
.add(StructField("f2", StringType(), True, None))
|
|
795
|
+
)
|
|
796
|
+
struct2 = StructType([StructField("f1", StringType(), True)])
|
|
797
|
+
self.assertNotEqual(struct1.fieldNames(), struct2.names)
|
|
798
|
+
self.assertNotEqual(struct1, struct2)
|
|
799
|
+
|
|
800
|
+
# Catch exception raised during improper construction
|
|
801
|
+
self.assertRaises(ValueError, lambda: StructType().add("name"))
|
|
802
|
+
|
|
803
|
+
struct1 = StructType().add("f1", StringType(), True).add("f2", StringType(), True, None)
|
|
804
|
+
for field in struct1:
|
|
805
|
+
self.assertIsInstance(field, StructField)
|
|
806
|
+
|
|
807
|
+
struct1 = StructType().add("f1", StringType(), True).add("f2", StringType(), True, None)
|
|
808
|
+
self.assertEqual(len(struct1), 2)
|
|
809
|
+
|
|
810
|
+
struct1 = StructType().add("f1", StringType(), True).add("f2", StringType(), True, None)
|
|
811
|
+
self.assertIs(struct1["f1"], struct1.fields[0])
|
|
812
|
+
self.assertIs(struct1[0], struct1.fields[0])
|
|
813
|
+
self.assertEqual(struct1[0:1], StructType(struct1.fields[0:1]))
|
|
814
|
+
self.assertRaises(KeyError, lambda: struct1["f9"])
|
|
815
|
+
self.assertRaises(IndexError, lambda: struct1[9])
|
|
816
|
+
self.assertRaises(TypeError, lambda: struct1[9.9])
|
|
817
|
+
|
|
818
|
+
@unittest.skipIf(
|
|
819
|
+
"SPARK_SKIP_CONNECT_COMPAT_TESTS" in os.environ, "Failed with different Client <> Server"
|
|
820
|
+
)
|
|
821
|
+
def test_parse_datatype_string(self):
|
|
822
|
+
from pyspark.sql.types import _all_atomic_types, _parse_datatype_string
|
|
823
|
+
|
|
824
|
+
for k, t in _all_atomic_types.items():
|
|
825
|
+
if k != "varchar" and k != "char":
|
|
826
|
+
self.assertEqual(t(), _parse_datatype_string(k))
|
|
827
|
+
self.assertEqual(IntegerType(), _parse_datatype_string("int"))
|
|
828
|
+
self.assertEqual(CharType(1), _parse_datatype_string("char(1)"))
|
|
829
|
+
self.assertEqual(CharType(10), _parse_datatype_string("char( 10 )"))
|
|
830
|
+
self.assertEqual(CharType(11), _parse_datatype_string("char( 11)"))
|
|
831
|
+
self.assertEqual(VarcharType(1), _parse_datatype_string("varchar(1)"))
|
|
832
|
+
self.assertEqual(VarcharType(10), _parse_datatype_string("varchar( 10 )"))
|
|
833
|
+
self.assertEqual(VarcharType(11), _parse_datatype_string("varchar( 11)"))
|
|
834
|
+
self.assertEqual(DecimalType(1, 1), _parse_datatype_string("decimal(1 ,1)"))
|
|
835
|
+
self.assertEqual(DecimalType(10, 1), _parse_datatype_string("decimal( 10,1 )"))
|
|
836
|
+
self.assertEqual(DecimalType(11, 1), _parse_datatype_string("decimal(11,1)"))
|
|
837
|
+
self.assertEqual(ArrayType(IntegerType()), _parse_datatype_string("array<int >"))
|
|
838
|
+
self.assertEqual(
|
|
839
|
+
MapType(IntegerType(), DoubleType()), _parse_datatype_string("map< int, double >")
|
|
840
|
+
)
|
|
841
|
+
self.assertEqual(
|
|
842
|
+
StructType([StructField("a", IntegerType()), StructField("c", DoubleType())]),
|
|
843
|
+
_parse_datatype_string("struct<a:int, c:double >"),
|
|
844
|
+
)
|
|
845
|
+
self.assertEqual(
|
|
846
|
+
StructType([StructField("a", IntegerType()), StructField("c", DoubleType())]),
|
|
847
|
+
_parse_datatype_string("a:int, c:double"),
|
|
848
|
+
)
|
|
849
|
+
self.assertEqual(
|
|
850
|
+
StructType([StructField("a", IntegerType()), StructField("c", DoubleType())]),
|
|
851
|
+
_parse_datatype_string("a INT, c DOUBLE"),
|
|
852
|
+
)
|
|
853
|
+
|
|
854
|
+
def test_metadata_null(self):
|
|
855
|
+
schema = StructType(
|
|
856
|
+
[
|
|
857
|
+
StructField("f1", StringType(), True, None),
|
|
858
|
+
StructField("f2", StringType(), True, {"a": None}),
|
|
859
|
+
]
|
|
860
|
+
)
|
|
861
|
+
self.spark.createDataFrame([["a", "b"], ["c", "d"]], schema)
|
|
862
|
+
|
|
863
|
+
def test_access_nested_types(self):
|
|
864
|
+
df = self.spark.createDataFrame([Row(l=[1], r=Row(a=1, b="b"), d={"k": "v"})])
|
|
865
|
+
self.assertEqual(1, df.select(df.l[0]).first()[0])
|
|
866
|
+
self.assertEqual(1, df.select(df.l.getItem(0)).first()[0])
|
|
867
|
+
self.assertEqual(1, df.select(df.r.a).first()[0])
|
|
868
|
+
self.assertEqual("b", df.select(df.r.getField("b")).first()[0])
|
|
869
|
+
self.assertEqual("v", df.select(df.d["k"]).first()[0])
|
|
870
|
+
self.assertEqual("v", df.select(df.d.getItem("k")).first()[0])
|
|
871
|
+
|
|
872
|
+
def test_infer_long_type(self):
|
|
873
|
+
longrow = [Row(f1="a", f2=100000000000000)]
|
|
874
|
+
df = self.sc.parallelize(longrow).toDF()
|
|
875
|
+
self.assertEqual(df.schema.fields[1].dataType, LongType())
|
|
876
|
+
|
|
877
|
+
# this saving as Parquet caused issues as well.
|
|
878
|
+
output_dir = os.path.join(self.tempdir.name, "infer_long_type")
|
|
879
|
+
df.write.parquet(output_dir)
|
|
880
|
+
df1 = self.spark.read.parquet(output_dir)
|
|
881
|
+
self.assertEqual("a", df1.first().f1)
|
|
882
|
+
self.assertEqual(100000000000000, df1.first().f2)
|
|
883
|
+
|
|
884
|
+
self.assertEqual(_infer_type(1), LongType())
|
|
885
|
+
self.assertEqual(_infer_type(2**10), LongType())
|
|
886
|
+
self.assertEqual(_infer_type(2**20), LongType())
|
|
887
|
+
self.assertEqual(_infer_type(2**31 - 1), LongType())
|
|
888
|
+
self.assertEqual(_infer_type(2**31), LongType())
|
|
889
|
+
self.assertEqual(_infer_type(2**61), LongType())
|
|
890
|
+
self.assertEqual(_infer_type(2**71), LongType())
|
|
891
|
+
|
|
892
|
+
def test_infer_binary_type(self):
|
|
893
|
+
binaryrow = [Row(f1="a", f2=b"abcd")]
|
|
894
|
+
df = self.sc.parallelize(binaryrow).toDF()
|
|
895
|
+
self.assertEqual(df.schema.fields[1].dataType, BinaryType())
|
|
896
|
+
|
|
897
|
+
# this saving as Parquet caused issues as well.
|
|
898
|
+
output_dir = os.path.join(self.tempdir.name, "infer_binary_type")
|
|
899
|
+
df.write.parquet(output_dir)
|
|
900
|
+
df1 = self.spark.read.parquet(output_dir)
|
|
901
|
+
self.assertEqual("a", df1.first().f1)
|
|
902
|
+
self.assertEqual(b"abcd", df1.first().f2)
|
|
903
|
+
|
|
904
|
+
self.assertEqual(_infer_type(b""), BinaryType())
|
|
905
|
+
self.assertEqual(_infer_type(b"1234"), BinaryType())
|
|
906
|
+
|
|
907
|
+
def test_merge_type(self):
|
|
908
|
+
self.assertEqual(_merge_type(LongType(), NullType()), LongType())
|
|
909
|
+
self.assertEqual(_merge_type(NullType(), LongType()), LongType())
|
|
910
|
+
|
|
911
|
+
self.assertEqual(_merge_type(LongType(), LongType()), LongType())
|
|
912
|
+
|
|
913
|
+
self.assertEqual(
|
|
914
|
+
_merge_type(ArrayType(LongType()), ArrayType(LongType())), ArrayType(LongType())
|
|
915
|
+
)
|
|
916
|
+
with self.assertRaises(PySparkTypeError) as pe:
|
|
917
|
+
_merge_type(ArrayType(LongType()), ArrayType(DoubleType()))
|
|
918
|
+
self.check_error(
|
|
919
|
+
exception=pe.exception,
|
|
920
|
+
error_class="CANNOT_MERGE_TYPE",
|
|
921
|
+
message_parameters={"data_type1": "LongType", "data_type2": "DoubleType"},
|
|
922
|
+
)
|
|
923
|
+
|
|
924
|
+
self.assertEqual(
|
|
925
|
+
_merge_type(MapType(StringType(), LongType()), MapType(StringType(), LongType())),
|
|
926
|
+
MapType(StringType(), LongType()),
|
|
927
|
+
)
|
|
928
|
+
|
|
929
|
+
self.assertEqual(
|
|
930
|
+
_merge_type(MapType(StringType(), LongType()), MapType(DoubleType(), LongType())),
|
|
931
|
+
MapType(StringType(), LongType()),
|
|
932
|
+
)
|
|
933
|
+
|
|
934
|
+
with self.assertRaises(PySparkTypeError) as pe:
|
|
935
|
+
_merge_type(MapType(StringType(), LongType()), MapType(StringType(), DoubleType()))
|
|
936
|
+
self.check_error(
|
|
937
|
+
exception=pe.exception,
|
|
938
|
+
error_class="CANNOT_MERGE_TYPE",
|
|
939
|
+
message_parameters={"data_type1": "LongType", "data_type2": "DoubleType"},
|
|
940
|
+
)
|
|
941
|
+
|
|
942
|
+
self.assertEqual(
|
|
943
|
+
_merge_type(
|
|
944
|
+
StructType([StructField("f1", LongType()), StructField("f2", StringType())]),
|
|
945
|
+
StructType([StructField("f1", LongType()), StructField("f2", StringType())]),
|
|
946
|
+
),
|
|
947
|
+
StructType([StructField("f1", LongType()), StructField("f2", StringType())]),
|
|
948
|
+
)
|
|
949
|
+
with self.assertRaises(PySparkTypeError) as pe:
|
|
950
|
+
_merge_type(
|
|
951
|
+
StructType([StructField("f1", LongType()), StructField("f2", StringType())]),
|
|
952
|
+
StructType([StructField("f1", DoubleType()), StructField("f2", StringType())]),
|
|
953
|
+
)
|
|
954
|
+
self.check_error(
|
|
955
|
+
exception=pe.exception,
|
|
956
|
+
error_class="CANNOT_MERGE_TYPE",
|
|
957
|
+
message_parameters={"data_type1": "LongType", "data_type2": "DoubleType"},
|
|
958
|
+
)
|
|
959
|
+
|
|
960
|
+
self.assertEqual(
|
|
961
|
+
_merge_type(
|
|
962
|
+
StructType([StructField("f1", StructType([StructField("f2", LongType())]))]),
|
|
963
|
+
StructType([StructField("f1", StructType([StructField("f2", LongType())]))]),
|
|
964
|
+
),
|
|
965
|
+
StructType([StructField("f1", StructType([StructField("f2", LongType())]))]),
|
|
966
|
+
)
|
|
967
|
+
self.assertEqual(
|
|
968
|
+
_merge_type(
|
|
969
|
+
StructType([StructField("f1", StructType([StructField("f2", LongType())]))]),
|
|
970
|
+
StructType([StructField("f1", StructType([StructField("f2", StringType())]))]),
|
|
971
|
+
),
|
|
972
|
+
StructType([StructField("f1", StructType([StructField("f2", StringType())]))]),
|
|
973
|
+
)
|
|
974
|
+
|
|
975
|
+
self.assertEqual(
|
|
976
|
+
_merge_type(
|
|
977
|
+
StructType(
|
|
978
|
+
[StructField("f1", ArrayType(LongType())), StructField("f2", StringType())]
|
|
979
|
+
),
|
|
980
|
+
StructType(
|
|
981
|
+
[StructField("f1", ArrayType(LongType())), StructField("f2", StringType())]
|
|
982
|
+
),
|
|
983
|
+
),
|
|
984
|
+
StructType([StructField("f1", ArrayType(LongType())), StructField("f2", StringType())]),
|
|
985
|
+
)
|
|
986
|
+
with self.assertRaises(PySparkTypeError) as pe:
|
|
987
|
+
_merge_type(
|
|
988
|
+
StructType(
|
|
989
|
+
[StructField("f1", ArrayType(LongType())), StructField("f2", StringType())]
|
|
990
|
+
),
|
|
991
|
+
StructType(
|
|
992
|
+
[StructField("f1", ArrayType(DoubleType())), StructField("f2", StringType())]
|
|
993
|
+
),
|
|
994
|
+
)
|
|
995
|
+
self.check_error(
|
|
996
|
+
exception=pe.exception,
|
|
997
|
+
error_class="CANNOT_MERGE_TYPE",
|
|
998
|
+
message_parameters={"data_type1": "LongType", "data_type2": "DoubleType"},
|
|
999
|
+
)
|
|
1000
|
+
|
|
1001
|
+
self.assertEqual(
|
|
1002
|
+
_merge_type(
|
|
1003
|
+
StructType(
|
|
1004
|
+
[
|
|
1005
|
+
StructField("f1", MapType(StringType(), LongType())),
|
|
1006
|
+
StructField("f2", StringType()),
|
|
1007
|
+
]
|
|
1008
|
+
),
|
|
1009
|
+
StructType(
|
|
1010
|
+
[
|
|
1011
|
+
StructField("f1", MapType(StringType(), LongType())),
|
|
1012
|
+
StructField("f2", StringType()),
|
|
1013
|
+
]
|
|
1014
|
+
),
|
|
1015
|
+
),
|
|
1016
|
+
StructType(
|
|
1017
|
+
[
|
|
1018
|
+
StructField("f1", MapType(StringType(), LongType())),
|
|
1019
|
+
StructField("f2", StringType()),
|
|
1020
|
+
]
|
|
1021
|
+
),
|
|
1022
|
+
)
|
|
1023
|
+
with self.assertRaises(PySparkTypeError) as pe:
|
|
1024
|
+
_merge_type(
|
|
1025
|
+
StructType(
|
|
1026
|
+
[
|
|
1027
|
+
StructField("f1", MapType(StringType(), LongType())),
|
|
1028
|
+
StructField("f2", StringType()),
|
|
1029
|
+
]
|
|
1030
|
+
),
|
|
1031
|
+
StructType(
|
|
1032
|
+
[
|
|
1033
|
+
StructField("f1", MapType(StringType(), DoubleType())),
|
|
1034
|
+
StructField("f2", StringType()),
|
|
1035
|
+
]
|
|
1036
|
+
),
|
|
1037
|
+
)
|
|
1038
|
+
self.check_error(
|
|
1039
|
+
exception=pe.exception,
|
|
1040
|
+
error_class="CANNOT_MERGE_TYPE",
|
|
1041
|
+
message_parameters={"data_type1": "LongType", "data_type2": "DoubleType"},
|
|
1042
|
+
)
|
|
1043
|
+
|
|
1044
|
+
self.assertEqual(
|
|
1045
|
+
_merge_type(
|
|
1046
|
+
StructType([StructField("f1", ArrayType(MapType(StringType(), LongType())))]),
|
|
1047
|
+
StructType([StructField("f1", ArrayType(MapType(StringType(), LongType())))]),
|
|
1048
|
+
),
|
|
1049
|
+
StructType([StructField("f1", ArrayType(MapType(StringType(), LongType())))]),
|
|
1050
|
+
)
|
|
1051
|
+
self.assertEqual(
|
|
1052
|
+
_merge_type(
|
|
1053
|
+
StructType([StructField("f1", ArrayType(MapType(StringType(), LongType())))]),
|
|
1054
|
+
StructType([StructField("f1", ArrayType(MapType(DoubleType(), LongType())))]),
|
|
1055
|
+
),
|
|
1056
|
+
StructType([StructField("f1", ArrayType(MapType(StringType(), LongType())))]),
|
|
1057
|
+
)
|
|
1058
|
+
|
|
1059
|
+
# test for SPARK-16542
|
|
1060
|
+
def test_array_types(self):
|
|
1061
|
+
# This test need to make sure that the Scala type selected is at least
|
|
1062
|
+
# as large as the python's types. This is necessary because python's
|
|
1063
|
+
# array types depend on C implementation on the machine. Therefore there
|
|
1064
|
+
# is no machine independent correspondence between python's array types
|
|
1065
|
+
# and Scala types.
|
|
1066
|
+
# See: https://docs.python.org/2/library/array.html
|
|
1067
|
+
|
|
1068
|
+
def assertCollectSuccess(typecode, value):
|
|
1069
|
+
row = Row(myarray=array.array(typecode, [value]))
|
|
1070
|
+
df = self.spark.createDataFrame([row])
|
|
1071
|
+
self.assertEqual(df.first()["myarray"][0], value)
|
|
1072
|
+
|
|
1073
|
+
# supported string types
|
|
1074
|
+
#
|
|
1075
|
+
# String types in python's array are "u" for Py_UNICODE and "c" for char.
|
|
1076
|
+
# "u" will be removed in python 4, and "c" is not supported in python 3.
|
|
1077
|
+
supported_string_types = []
|
|
1078
|
+
if sys.version_info[0] < 4:
|
|
1079
|
+
supported_string_types += ["u"]
|
|
1080
|
+
# test unicode
|
|
1081
|
+
assertCollectSuccess("u", "a")
|
|
1082
|
+
|
|
1083
|
+
# supported float and double
|
|
1084
|
+
#
|
|
1085
|
+
# Test max, min, and precision for float and double, assuming IEEE 754
|
|
1086
|
+
# floating-point format.
|
|
1087
|
+
supported_fractional_types = ["f", "d"]
|
|
1088
|
+
assertCollectSuccess("f", ctypes.c_float(1e38).value)
|
|
1089
|
+
assertCollectSuccess("f", ctypes.c_float(1e-38).value)
|
|
1090
|
+
assertCollectSuccess("f", ctypes.c_float(1.123456).value)
|
|
1091
|
+
assertCollectSuccess("d", sys.float_info.max)
|
|
1092
|
+
assertCollectSuccess("d", sys.float_info.min)
|
|
1093
|
+
assertCollectSuccess("d", sys.float_info.epsilon)
|
|
1094
|
+
|
|
1095
|
+
# supported signed int types
|
|
1096
|
+
#
|
|
1097
|
+
# The size of C types changes with implementation, we need to make sure
|
|
1098
|
+
# that there is no overflow error on the platform running this test.
|
|
1099
|
+
supported_signed_int_types = list(
|
|
1100
|
+
set(_array_signed_int_typecode_ctype_mappings.keys()).intersection(
|
|
1101
|
+
set(_array_type_mappings.keys())
|
|
1102
|
+
)
|
|
1103
|
+
)
|
|
1104
|
+
for t in supported_signed_int_types:
|
|
1105
|
+
ctype = _array_signed_int_typecode_ctype_mappings[t]
|
|
1106
|
+
max_val = 2 ** (ctypes.sizeof(ctype) * 8 - 1)
|
|
1107
|
+
assertCollectSuccess(t, max_val - 1)
|
|
1108
|
+
assertCollectSuccess(t, -max_val)
|
|
1109
|
+
|
|
1110
|
+
# supported unsigned int types
|
|
1111
|
+
#
|
|
1112
|
+
# JVM does not have unsigned types. We need to be very careful to make
|
|
1113
|
+
# sure that there is no overflow error.
|
|
1114
|
+
supported_unsigned_int_types = list(
|
|
1115
|
+
set(_array_unsigned_int_typecode_ctype_mappings.keys()).intersection(
|
|
1116
|
+
set(_array_type_mappings.keys())
|
|
1117
|
+
)
|
|
1118
|
+
)
|
|
1119
|
+
for t in supported_unsigned_int_types:
|
|
1120
|
+
ctype = _array_unsigned_int_typecode_ctype_mappings[t]
|
|
1121
|
+
assertCollectSuccess(t, 2 ** (ctypes.sizeof(ctype) * 8) - 1)
|
|
1122
|
+
|
|
1123
|
+
# all supported types
|
|
1124
|
+
#
|
|
1125
|
+
# Make sure the types tested above:
|
|
1126
|
+
# 1. are all supported types
|
|
1127
|
+
# 2. cover all supported types
|
|
1128
|
+
supported_types = (
|
|
1129
|
+
supported_string_types
|
|
1130
|
+
+ supported_fractional_types
|
|
1131
|
+
+ supported_signed_int_types
|
|
1132
|
+
+ supported_unsigned_int_types
|
|
1133
|
+
)
|
|
1134
|
+
self.assertEqual(set(supported_types), set(_array_type_mappings.keys()))
|
|
1135
|
+
|
|
1136
|
+
# all unsupported types
|
|
1137
|
+
#
|
|
1138
|
+
# Keys in _array_type_mappings is a complete list of all supported types,
|
|
1139
|
+
# and types not in _array_type_mappings are considered unsupported.
|
|
1140
|
+
# PyPy seems not having array.typecodes.
|
|
1141
|
+
all_types = set(["b", "B", "u", "h", "H", "i", "I", "l", "L", "q", "Q", "f", "d"])
|
|
1142
|
+
unsupported_types = all_types - set(supported_types)
|
|
1143
|
+
# test unsupported types
|
|
1144
|
+
for t in unsupported_types:
|
|
1145
|
+
with self.assertRaises(PySparkTypeError) as pe:
|
|
1146
|
+
a = array.array(t)
|
|
1147
|
+
self.spark.createDataFrame([Row(myarray=a)]).collect()
|
|
1148
|
+
|
|
1149
|
+
self.check_error(
|
|
1150
|
+
exception=pe.exception,
|
|
1151
|
+
error_class="CANNOT_INFER_TYPE_FOR_FIELD",
|
|
1152
|
+
message_parameters={"field_name": "myarray"},
|
|
1153
|
+
)
|
|
1154
|
+
|
|
1155
|
+
def test_repr(self):
|
|
1156
|
+
instances = [
|
|
1157
|
+
NullType(),
|
|
1158
|
+
StringType(),
|
|
1159
|
+
CharType(10),
|
|
1160
|
+
VarcharType(10),
|
|
1161
|
+
BinaryType(),
|
|
1162
|
+
BooleanType(),
|
|
1163
|
+
DateType(),
|
|
1164
|
+
TimestampType(),
|
|
1165
|
+
DecimalType(),
|
|
1166
|
+
DoubleType(),
|
|
1167
|
+
FloatType(),
|
|
1168
|
+
ByteType(),
|
|
1169
|
+
IntegerType(),
|
|
1170
|
+
LongType(),
|
|
1171
|
+
ShortType(),
|
|
1172
|
+
ArrayType(StringType()),
|
|
1173
|
+
MapType(StringType(), IntegerType()),
|
|
1174
|
+
StructField("f1", StringType(), True),
|
|
1175
|
+
StructType([StructField("f1", StringType(), True)]),
|
|
1176
|
+
]
|
|
1177
|
+
for instance in instances:
|
|
1178
|
+
self.assertEqual(eval(repr(instance)), instance)
|
|
1179
|
+
|
|
1180
|
+
def test_daytime_interval_type_constructor(self):
|
|
1181
|
+
# SPARK-37277: Test constructors in day time interval.
|
|
1182
|
+
self.assertEqual(DayTimeIntervalType().simpleString(), "interval day to second")
|
|
1183
|
+
self.assertEqual(
|
|
1184
|
+
DayTimeIntervalType(DayTimeIntervalType.DAY).simpleString(), "interval day"
|
|
1185
|
+
)
|
|
1186
|
+
self.assertEqual(
|
|
1187
|
+
DayTimeIntervalType(
|
|
1188
|
+
DayTimeIntervalType.HOUR, DayTimeIntervalType.SECOND
|
|
1189
|
+
).simpleString(),
|
|
1190
|
+
"interval hour to second",
|
|
1191
|
+
)
|
|
1192
|
+
|
|
1193
|
+
with self.assertRaisesRegex(RuntimeError, "interval None to 3 is invalid"):
|
|
1194
|
+
DayTimeIntervalType(endField=DayTimeIntervalType.SECOND)
|
|
1195
|
+
|
|
1196
|
+
with self.assertRaisesRegex(RuntimeError, "interval 123 to 123 is invalid"):
|
|
1197
|
+
DayTimeIntervalType(123)
|
|
1198
|
+
|
|
1199
|
+
with self.assertRaisesRegex(RuntimeError, "interval 0 to 321 is invalid"):
|
|
1200
|
+
DayTimeIntervalType(DayTimeIntervalType.DAY, 321)
|
|
1201
|
+
|
|
1202
|
+
def test_daytime_interval_type(self):
|
|
1203
|
+
# SPARK-37277: Support DayTimeIntervalType in createDataFrame
|
|
1204
|
+
timedetlas = [
|
|
1205
|
+
(datetime.timedelta(microseconds=123),),
|
|
1206
|
+
(
|
|
1207
|
+
datetime.timedelta(
|
|
1208
|
+
days=1, seconds=23, microseconds=123, milliseconds=4, minutes=5, hours=11
|
|
1209
|
+
),
|
|
1210
|
+
),
|
|
1211
|
+
(datetime.timedelta(microseconds=-123),),
|
|
1212
|
+
(datetime.timedelta(days=-1),),
|
|
1213
|
+
(datetime.timedelta(microseconds=388629894454999981),),
|
|
1214
|
+
(datetime.timedelta(days=-1, seconds=86399, microseconds=999999),), # -1 microsecond
|
|
1215
|
+
]
|
|
1216
|
+
df = self.spark.createDataFrame(timedetlas, schema="td interval day to second")
|
|
1217
|
+
self.assertEqual(set(r.td for r in df.collect()), set(set(r[0] for r in timedetlas)))
|
|
1218
|
+
|
|
1219
|
+
exprs = [
|
|
1220
|
+
"INTERVAL '1 02:03:04' DAY TO SECOND AS a",
|
|
1221
|
+
"INTERVAL '1 02:03' DAY TO MINUTE AS b",
|
|
1222
|
+
"INTERVAL '1 02' DAY TO HOUR AS c",
|
|
1223
|
+
"INTERVAL '1' DAY AS d",
|
|
1224
|
+
"INTERVAL '26:03:04' HOUR TO SECOND AS e",
|
|
1225
|
+
"INTERVAL '26:03' HOUR TO MINUTE AS f",
|
|
1226
|
+
"INTERVAL '26' HOUR AS g",
|
|
1227
|
+
"INTERVAL '1563:04' MINUTE TO SECOND AS h",
|
|
1228
|
+
"INTERVAL '1563' MINUTE AS i",
|
|
1229
|
+
"INTERVAL '93784' SECOND AS j",
|
|
1230
|
+
]
|
|
1231
|
+
df = self.spark.range(1).selectExpr(exprs)
|
|
1232
|
+
|
|
1233
|
+
actual = list(df.first())
|
|
1234
|
+
expected = [
|
|
1235
|
+
datetime.timedelta(days=1, hours=2, minutes=3, seconds=4),
|
|
1236
|
+
datetime.timedelta(days=1, hours=2, minutes=3),
|
|
1237
|
+
datetime.timedelta(days=1, hours=2),
|
|
1238
|
+
datetime.timedelta(days=1),
|
|
1239
|
+
datetime.timedelta(hours=26, minutes=3, seconds=4),
|
|
1240
|
+
datetime.timedelta(hours=26, minutes=3),
|
|
1241
|
+
datetime.timedelta(hours=26),
|
|
1242
|
+
datetime.timedelta(minutes=1563, seconds=4),
|
|
1243
|
+
datetime.timedelta(minutes=1563),
|
|
1244
|
+
datetime.timedelta(seconds=93784),
|
|
1245
|
+
]
|
|
1246
|
+
|
|
1247
|
+
for n, (a, e) in enumerate(zip(actual, expected)):
|
|
1248
|
+
self.assertEqual(a, e, "%s does not match with %s" % (exprs[n], expected[n]))
|
|
1249
|
+
|
|
1250
|
+
def test_yearmonth_interval_type_constructor(self):
|
|
1251
|
+
self.assertEqual(YearMonthIntervalType().simpleString(), "interval year to month")
|
|
1252
|
+
self.assertEqual(
|
|
1253
|
+
YearMonthIntervalType(YearMonthIntervalType.YEAR).simpleString(), "interval year"
|
|
1254
|
+
)
|
|
1255
|
+
self.assertEqual(
|
|
1256
|
+
YearMonthIntervalType(
|
|
1257
|
+
YearMonthIntervalType.YEAR, YearMonthIntervalType.MONTH
|
|
1258
|
+
).simpleString(),
|
|
1259
|
+
"interval year to month",
|
|
1260
|
+
)
|
|
1261
|
+
|
|
1262
|
+
with self.assertRaisesRegex(RuntimeError, "interval None to 3 is invalid"):
|
|
1263
|
+
YearMonthIntervalType(endField=3)
|
|
1264
|
+
|
|
1265
|
+
with self.assertRaisesRegex(RuntimeError, "interval 123 to 123 is invalid"):
|
|
1266
|
+
YearMonthIntervalType(123)
|
|
1267
|
+
|
|
1268
|
+
with self.assertRaisesRegex(RuntimeError, "interval 0 to 321 is invalid"):
|
|
1269
|
+
YearMonthIntervalType(YearMonthIntervalType.YEAR, 321)
|
|
1270
|
+
|
|
1271
|
+
def test_yearmonth_interval_type(self):
|
|
1272
|
+
schema1 = self.spark.sql("SELECT INTERVAL '10-8' YEAR TO MONTH AS interval").schema
|
|
1273
|
+
self.assertEqual(schema1.fields[0].dataType, YearMonthIntervalType(0, 1))
|
|
1274
|
+
|
|
1275
|
+
schema2 = self.spark.sql("SELECT INTERVAL '10' YEAR AS interval").schema
|
|
1276
|
+
self.assertEqual(schema2.fields[0].dataType, YearMonthIntervalType(0, 0))
|
|
1277
|
+
|
|
1278
|
+
schema3 = self.spark.sql("SELECT INTERVAL '8' MONTH AS interval").schema
|
|
1279
|
+
self.assertEqual(schema3.fields[0].dataType, YearMonthIntervalType(1, 1))
|
|
1280
|
+
|
|
1281
|
+
def test_infer_array_element_type_with_struct(self):
|
|
1282
|
+
# SPARK-48248: Nested array to respect legacy conf of inferArrayTypeFromFirstElement
|
|
1283
|
+
with self.sql_conf(
|
|
1284
|
+
{"spark.sql.pyspark.legacy.inferArrayTypeFromFirstElement.enabled": True}
|
|
1285
|
+
):
|
|
1286
|
+
self.assertEqual([[1, None]], self.spark.createDataFrame([[[[1, "a"]]]]).first()[0])
|
|
1287
|
+
|
|
1288
|
+
|
|
1289
|
+
class DataTypeTests(unittest.TestCase):
|
|
1290
|
+
# regression test for SPARK-6055
|
|
1291
|
+
def test_data_type_eq(self):
|
|
1292
|
+
lt = LongType()
|
|
1293
|
+
lt2 = pickle.loads(pickle.dumps(LongType()))
|
|
1294
|
+
self.assertEqual(lt, lt2)
|
|
1295
|
+
|
|
1296
|
+
# regression test for SPARK-7978
|
|
1297
|
+
def test_decimal_type(self):
|
|
1298
|
+
t1 = DecimalType()
|
|
1299
|
+
t2 = DecimalType(10, 2)
|
|
1300
|
+
self.assertTrue(t2 is not t1)
|
|
1301
|
+
self.assertNotEqual(t1, t2)
|
|
1302
|
+
t3 = DecimalType(8)
|
|
1303
|
+
self.assertNotEqual(t2, t3)
|
|
1304
|
+
|
|
1305
|
+
def test_char_type(self):
|
|
1306
|
+
v1 = CharType(10)
|
|
1307
|
+
v2 = CharType(20)
|
|
1308
|
+
self.assertTrue(v2 is not v1)
|
|
1309
|
+
self.assertNotEqual(v1, v2)
|
|
1310
|
+
v3 = CharType(10)
|
|
1311
|
+
self.assertEqual(v1, v3)
|
|
1312
|
+
self.assertFalse(v1 is v3)
|
|
1313
|
+
|
|
1314
|
+
def test_varchar_type(self):
|
|
1315
|
+
v1 = VarcharType(10)
|
|
1316
|
+
v2 = VarcharType(20)
|
|
1317
|
+
self.assertTrue(v2 is not v1)
|
|
1318
|
+
self.assertNotEqual(v1, v2)
|
|
1319
|
+
v3 = VarcharType(10)
|
|
1320
|
+
self.assertEqual(v1, v3)
|
|
1321
|
+
self.assertFalse(v1 is v3)
|
|
1322
|
+
|
|
1323
|
+
# regression test for SPARK-10392
|
|
1324
|
+
def test_datetype_equal_zero(self):
|
|
1325
|
+
dt = DateType()
|
|
1326
|
+
self.assertEqual(dt.fromInternal(0), datetime.date(1970, 1, 1))
|
|
1327
|
+
|
|
1328
|
+
# regression test for SPARK-17035
|
|
1329
|
+
def test_timestamp_microsecond(self):
|
|
1330
|
+
tst = TimestampType()
|
|
1331
|
+
self.assertEqual(tst.toInternal(datetime.datetime.max) % 1000000, 999999)
|
|
1332
|
+
|
|
1333
|
+
# regression test for SPARK-23299
|
|
1334
|
+
def test_row_without_column_name(self):
|
|
1335
|
+
row = Row("Alice", 11)
|
|
1336
|
+
self.assertEqual(repr(row), "<Row('Alice', 11)>")
|
|
1337
|
+
|
|
1338
|
+
# test __repr__ with unicode values
|
|
1339
|
+
self.assertEqual(repr(Row("数", "量")), "<Row('数', '量')>")
|
|
1340
|
+
|
|
1341
|
+
# SPARK-44643: test __repr__ with empty Row
|
|
1342
|
+
def test_row_repr_with_empty_row(self):
|
|
1343
|
+
self.assertEqual(repr(Row(a=Row())), "Row(a=<Row()>)")
|
|
1344
|
+
self.assertEqual(repr(Row(Row())), "<Row(<Row()>)>")
|
|
1345
|
+
|
|
1346
|
+
EmptyRow = Row()
|
|
1347
|
+
self.assertEqual(repr(Row(a=EmptyRow())), "Row(a=Row())")
|
|
1348
|
+
self.assertEqual(repr(Row(EmptyRow())), "<Row(Row())>")
|
|
1349
|
+
|
|
1350
|
+
def test_empty_row(self):
|
|
1351
|
+
row = Row()
|
|
1352
|
+
self.assertEqual(len(row), 0)
|
|
1353
|
+
|
|
1354
|
+
def test_struct_field_type_name(self):
|
|
1355
|
+
struct_field = StructField("a", IntegerType())
|
|
1356
|
+
self.assertRaises(TypeError, struct_field.typeName)
|
|
1357
|
+
|
|
1358
|
+
def test_invalid_create_row(self):
|
|
1359
|
+
row_class = Row("c1", "c2")
|
|
1360
|
+
self.assertRaises(ValueError, lambda: row_class(1, 2, 3))
|
|
1361
|
+
|
|
1362
|
+
|
|
1363
|
+
class DataTypeVerificationTests(unittest.TestCase, PySparkErrorTestUtils):
|
|
1364
|
+
def test_verify_type_exception_msg(self):
|
|
1365
|
+
with self.assertRaises(PySparkValueError) as pe:
|
|
1366
|
+
_make_type_verifier(StringType(), nullable=False, name="test_name")(None)
|
|
1367
|
+
|
|
1368
|
+
self.check_error(
|
|
1369
|
+
exception=pe.exception,
|
|
1370
|
+
error_class="CANNOT_BE_NONE",
|
|
1371
|
+
message_parameters={
|
|
1372
|
+
"arg_name": "obj",
|
|
1373
|
+
},
|
|
1374
|
+
)
|
|
1375
|
+
|
|
1376
|
+
schema = StructType([StructField("a", StructType([StructField("b", IntegerType())]))])
|
|
1377
|
+
with self.assertRaises(PySparkTypeError) as pe:
|
|
1378
|
+
_make_type_verifier(schema)([["data"]])
|
|
1379
|
+
|
|
1380
|
+
self.check_error(
|
|
1381
|
+
exception=pe.exception,
|
|
1382
|
+
error_class="CANNOT_ACCEPT_OBJECT_IN_TYPE",
|
|
1383
|
+
message_parameters={
|
|
1384
|
+
"data_type": "IntegerType()",
|
|
1385
|
+
"obj_name": "data",
|
|
1386
|
+
"obj_type": "str",
|
|
1387
|
+
},
|
|
1388
|
+
)
|
|
1389
|
+
|
|
1390
|
+
def test_verify_type_ok_nullable(self):
|
|
1391
|
+
obj = None
|
|
1392
|
+
types = [IntegerType(), FloatType(), StringType(), StructType([])]
|
|
1393
|
+
for data_type in types:
|
|
1394
|
+
try:
|
|
1395
|
+
_make_type_verifier(data_type, nullable=True)(obj)
|
|
1396
|
+
except Exception:
|
|
1397
|
+
self.fail("verify_type(%s, %s, nullable=True)" % (obj, data_type))
|
|
1398
|
+
|
|
1399
|
+
def test_verify_type_not_nullable(self):
|
|
1400
|
+
import array
|
|
1401
|
+
import datetime
|
|
1402
|
+
import decimal
|
|
1403
|
+
|
|
1404
|
+
schema = StructType(
|
|
1405
|
+
[
|
|
1406
|
+
StructField("s", StringType(), nullable=False),
|
|
1407
|
+
StructField("i", IntegerType(), nullable=True),
|
|
1408
|
+
]
|
|
1409
|
+
)
|
|
1410
|
+
|
|
1411
|
+
class MyObj:
|
|
1412
|
+
def __init__(self, **kwargs):
|
|
1413
|
+
for k, v in kwargs.items():
|
|
1414
|
+
setattr(self, k, v)
|
|
1415
|
+
|
|
1416
|
+
# obj, data_type
|
|
1417
|
+
success_spec = [
|
|
1418
|
+
# String
|
|
1419
|
+
("", StringType()),
|
|
1420
|
+
(1, StringType()),
|
|
1421
|
+
(1.0, StringType()),
|
|
1422
|
+
([], StringType()),
|
|
1423
|
+
({}, StringType()),
|
|
1424
|
+
# Char
|
|
1425
|
+
("", CharType(10)),
|
|
1426
|
+
(1, CharType(10)),
|
|
1427
|
+
(1.0, CharType(10)),
|
|
1428
|
+
([], CharType(10)),
|
|
1429
|
+
({}, CharType(10)),
|
|
1430
|
+
# Varchar
|
|
1431
|
+
("", VarcharType(10)),
|
|
1432
|
+
(1, VarcharType(10)),
|
|
1433
|
+
(1.0, VarcharType(10)),
|
|
1434
|
+
([], VarcharType(10)),
|
|
1435
|
+
({}, VarcharType(10)),
|
|
1436
|
+
# UDT
|
|
1437
|
+
(ExamplePoint(1.0, 2.0), ExamplePointUDT()),
|
|
1438
|
+
# Boolean
|
|
1439
|
+
(True, BooleanType()),
|
|
1440
|
+
# Byte
|
|
1441
|
+
(-(2**7), ByteType()),
|
|
1442
|
+
(2**7 - 1, ByteType()),
|
|
1443
|
+
# Short
|
|
1444
|
+
(-(2**15), ShortType()),
|
|
1445
|
+
(2**15 - 1, ShortType()),
|
|
1446
|
+
# Integer
|
|
1447
|
+
(-(2**31), IntegerType()),
|
|
1448
|
+
(2**31 - 1, IntegerType()),
|
|
1449
|
+
# Long
|
|
1450
|
+
(-(2**63), LongType()),
|
|
1451
|
+
(2**63 - 1, LongType()),
|
|
1452
|
+
# Float & Double
|
|
1453
|
+
(1.0, FloatType()),
|
|
1454
|
+
(1.0, DoubleType()),
|
|
1455
|
+
# Decimal
|
|
1456
|
+
(decimal.Decimal("1.0"), DecimalType()),
|
|
1457
|
+
# Binary
|
|
1458
|
+
(bytearray([1, 2]), BinaryType()),
|
|
1459
|
+
# Date/Timestamp
|
|
1460
|
+
(datetime.date(2000, 1, 2), DateType()),
|
|
1461
|
+
(datetime.datetime(2000, 1, 2, 3, 4), DateType()),
|
|
1462
|
+
(datetime.datetime(2000, 1, 2, 3, 4), TimestampType()),
|
|
1463
|
+
# Array
|
|
1464
|
+
([], ArrayType(IntegerType())),
|
|
1465
|
+
(["1", None], ArrayType(StringType(), containsNull=True)),
|
|
1466
|
+
([1, 2], ArrayType(IntegerType())),
|
|
1467
|
+
((1, 2), ArrayType(IntegerType())),
|
|
1468
|
+
(array.array("h", [1, 2]), ArrayType(IntegerType())),
|
|
1469
|
+
# Map
|
|
1470
|
+
({}, MapType(StringType(), IntegerType())),
|
|
1471
|
+
({"a": 1}, MapType(StringType(), IntegerType())),
|
|
1472
|
+
({"a": None}, MapType(StringType(), IntegerType(), valueContainsNull=True)),
|
|
1473
|
+
# Struct
|
|
1474
|
+
({"s": "a", "i": 1}, schema),
|
|
1475
|
+
({"s": "a", "i": None}, schema),
|
|
1476
|
+
({"s": "a"}, schema),
|
|
1477
|
+
({"s": "a", "f": 1.0}, schema),
|
|
1478
|
+
(Row(s="a", i=1), schema),
|
|
1479
|
+
(Row(s="a", i=None), schema),
|
|
1480
|
+
(["a", 1], schema),
|
|
1481
|
+
(["a", None], schema),
|
|
1482
|
+
(("a", 1), schema),
|
|
1483
|
+
(MyObj(s="a", i=1), schema),
|
|
1484
|
+
(MyObj(s="a", i=None), schema),
|
|
1485
|
+
(MyObj(s="a"), schema),
|
|
1486
|
+
]
|
|
1487
|
+
|
|
1488
|
+
# obj, data_type, exception class
|
|
1489
|
+
failure_spec = [
|
|
1490
|
+
# String (match anything but None)
|
|
1491
|
+
(None, StringType(), ValueError),
|
|
1492
|
+
# CharType (match anything but None)
|
|
1493
|
+
(None, CharType(10), ValueError),
|
|
1494
|
+
# VarcharType (match anything but None)
|
|
1495
|
+
(None, VarcharType(10), ValueError),
|
|
1496
|
+
# UDT
|
|
1497
|
+
(ExamplePoint(1.0, 2.0), PythonOnlyUDT(), ValueError),
|
|
1498
|
+
# Boolean
|
|
1499
|
+
(1, BooleanType(), TypeError),
|
|
1500
|
+
("True", BooleanType(), TypeError),
|
|
1501
|
+
([1], BooleanType(), TypeError),
|
|
1502
|
+
# Byte
|
|
1503
|
+
(-(2**7) - 1, ByteType(), ValueError),
|
|
1504
|
+
(2**7, ByteType(), ValueError),
|
|
1505
|
+
("1", ByteType(), TypeError),
|
|
1506
|
+
(1.0, ByteType(), TypeError),
|
|
1507
|
+
# Short
|
|
1508
|
+
(-(2**15) - 1, ShortType(), ValueError),
|
|
1509
|
+
(2**15, ShortType(), ValueError),
|
|
1510
|
+
# Integer
|
|
1511
|
+
(-(2**31) - 1, IntegerType(), ValueError),
|
|
1512
|
+
(2**31, IntegerType(), ValueError),
|
|
1513
|
+
# Float & Double
|
|
1514
|
+
(1, FloatType(), TypeError),
|
|
1515
|
+
(1, DoubleType(), TypeError),
|
|
1516
|
+
# Decimal
|
|
1517
|
+
(1.0, DecimalType(), TypeError),
|
|
1518
|
+
(1, DecimalType(), TypeError),
|
|
1519
|
+
("1.0", DecimalType(), TypeError),
|
|
1520
|
+
# Binary
|
|
1521
|
+
(1, BinaryType(), TypeError),
|
|
1522
|
+
# Date/Timestamp
|
|
1523
|
+
("2000-01-02", DateType(), TypeError),
|
|
1524
|
+
(946811040, TimestampType(), TypeError),
|
|
1525
|
+
# Array
|
|
1526
|
+
(["1", None], ArrayType(StringType(), containsNull=False), ValueError),
|
|
1527
|
+
([1, "2"], ArrayType(IntegerType()), TypeError),
|
|
1528
|
+
# Map
|
|
1529
|
+
({"a": 1}, MapType(IntegerType(), IntegerType()), TypeError),
|
|
1530
|
+
({"a": "1"}, MapType(StringType(), IntegerType()), TypeError),
|
|
1531
|
+
(
|
|
1532
|
+
{"a": None},
|
|
1533
|
+
MapType(StringType(), IntegerType(), valueContainsNull=False),
|
|
1534
|
+
ValueError,
|
|
1535
|
+
),
|
|
1536
|
+
# Struct
|
|
1537
|
+
({"s": "a", "i": "1"}, schema, TypeError),
|
|
1538
|
+
(Row(s="a"), schema, ValueError), # Row can't have missing field
|
|
1539
|
+
(Row(s="a", i="1"), schema, TypeError),
|
|
1540
|
+
(["a"], schema, ValueError),
|
|
1541
|
+
(["a", "1"], schema, TypeError),
|
|
1542
|
+
(MyObj(s="a", i="1"), schema, TypeError),
|
|
1543
|
+
(MyObj(s=None, i="1"), schema, ValueError),
|
|
1544
|
+
]
|
|
1545
|
+
|
|
1546
|
+
# Check success cases
|
|
1547
|
+
for obj, data_type in success_spec:
|
|
1548
|
+
try:
|
|
1549
|
+
_make_type_verifier(data_type, nullable=False)(obj)
|
|
1550
|
+
except Exception:
|
|
1551
|
+
self.fail("verify_type(%s, %s, nullable=False)" % (obj, data_type))
|
|
1552
|
+
|
|
1553
|
+
# Check failure cases
|
|
1554
|
+
for obj, data_type, exp in failure_spec:
|
|
1555
|
+
msg = "verify_type(%s, %s, nullable=False) == %s" % (obj, data_type, exp)
|
|
1556
|
+
with self.assertRaises(exp, msg=msg):
|
|
1557
|
+
_make_type_verifier(data_type, nullable=False)(obj)
|
|
1558
|
+
|
|
1559
|
+
def test_row_without_field_sorting(self):
|
|
1560
|
+
r = Row(b=1, a=2)
|
|
1561
|
+
TestRow = Row("b", "a")
|
|
1562
|
+
expected = TestRow(1, 2)
|
|
1563
|
+
|
|
1564
|
+
self.assertEqual(r, expected)
|
|
1565
|
+
self.assertEqual(repr(r), "Row(b=1, a=2)")
|
|
1566
|
+
|
|
1567
|
+
|
|
1568
|
+
class TypesTests(TypesTestsMixin, ReusedSQLTestCase):
|
|
1569
|
+
pass
|
|
1570
|
+
|
|
1571
|
+
|
|
1572
|
+
if __name__ == "__main__":
|
|
1573
|
+
from pyspark.sql.tests.test_types import * # noqa: F401
|
|
1574
|
+
|
|
1575
|
+
try:
|
|
1576
|
+
import xmlrunner
|
|
1577
|
+
|
|
1578
|
+
testRunner = xmlrunner.XMLTestRunner(output="target/test-reports", verbosity=2)
|
|
1579
|
+
except ImportError:
|
|
1580
|
+
testRunner = None
|
|
1581
|
+
unittest.main(testRunner=testRunner, verbosity=2)
|