diff --git a/python/MANIFEST.in b/python/MANIFEST.in index 862d62b1d3b29..0374b3096d471 100644 --- a/python/MANIFEST.in +++ b/python/MANIFEST.in @@ -14,7 +14,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -global-exclude *.py[cod] __pycache__ .DS_Store +# Reference: https://setuptools.pypa.io/en/latest/userguide/miscellaneous.html + +graft pyspark recursive-include deps/jars *.jar graft deps/bin recursive-include deps/sbin spark-config.sh spark-daemon.sh start-history-server.sh stop-history-server.sh @@ -22,5 +24,8 @@ recursive-include deps/data *.data *.txt recursive-include deps/licenses *.txt recursive-include deps/examples *.py recursive-include lib *.zip -recursive-include pyspark *.pyi py.typed include README.md + +# Note that these commands are processed in the order they appear, so keep +# this exclude at the end. +global-exclude *.py[cod] __pycache__ .DS_Store diff --git a/python/docs/source/getting_started/install.rst b/python/docs/source/getting_started/install.rst index f7476b9110aa4..21926ae295bfd 100644 --- a/python/docs/source/getting_started/install.rst +++ b/python/docs/source/getting_started/install.rst @@ -145,7 +145,7 @@ PySpark is included in the distributions available at the `Apache Spark website You can download a distribution you want from the site. After that, uncompress the tar file into the directory where you want to install Spark, for example, as below: -.. parsed-literal:: +.. code-block:: bash tar xzvf spark-\ |release|\-bin-hadoop3.tgz @@ -153,7 +153,7 @@ Ensure the ``SPARK_HOME`` environment variable points to the directory where the Update ``PYTHONPATH`` environment variable such that it can find the PySpark and Py4J under ``SPARK_HOME/python/lib``. One example of doing this is shown below: -.. parsed-literal:: +.. code-block:: bash cd spark-\ |release|\-bin-hadoop3 export SPARK_HOME=`pwd` diff --git a/python/pyspark/errors/error-conditions.json b/python/pyspark/errors/error-conditions.json new file mode 100644 index 0000000000000..7771791e41caa --- /dev/null +++ b/python/pyspark/errors/error-conditions.json @@ -0,0 +1,1146 @@ +{ + "APPLICATION_NAME_NOT_SET": { + "message": [ + "An application name must be set in your configuration." + ] + }, + "ARGUMENT_REQUIRED": { + "message": [ + "Argument `` is required when ." + ] + }, + "ARROW_LEGACY_IPC_FORMAT": { + "message": [ + "Arrow legacy IPC format is not supported in PySpark, please unset ARROW_PRE_0_15_IPC_FORMAT." + ] + }, + "ATTRIBUTE_NOT_CALLABLE": { + "message": [ + "Attribute `` in provided object `` is not callable." + ] + }, + "ATTRIBUTE_NOT_SUPPORTED": { + "message": [ + "Attribute `` is not supported." + ] + }, + "AXIS_LENGTH_MISMATCH": { + "message": [ + "Length mismatch: Expected axis has element, new values have elements." + ] + }, + "BROADCAST_VARIABLE_NOT_LOADED": { + "message": [ + "Broadcast variable `` not loaded." + ] + }, + "CALL_BEFORE_INITIALIZE": { + "message": [ + "Not supported to call `` before initialize ." + ] + }, + "CANNOT_ACCEPT_OBJECT_IN_TYPE": { + "message": [ + "`` can not accept object `` in type ``." + ] + }, + "CANNOT_ACCESS_TO_DUNDER": { + "message": [ + "Dunder(double underscore) attribute is for internal use only." + ] + }, + "CANNOT_APPLY_IN_FOR_COLUMN": { + "message": [ + "Cannot apply 'in' operator against a column: please use 'contains' in a string column or 'array_contains' function for an array column." + ] + }, + "CANNOT_BE_EMPTY": { + "message": [ + "At least one must be specified." + ] + }, + "CANNOT_BE_NONE": { + "message": [ + "Argument `` cannot be None." + ] + }, + "CANNOT_CONFIGURE_SPARK_CONNECT": { + "message": [ + "Spark Connect server cannot be configured: Existing [], New []." + ] + }, + "CANNOT_CONFIGURE_SPARK_CONNECT_MASTER": { + "message": [ + "Spark Connect server and Spark master cannot be configured together: Spark master [], Spark Connect []." + ] + }, + "CANNOT_CONVERT_COLUMN_INTO_BOOL": { + "message": [ + "Cannot convert column into bool: please use '&' for 'and', '|' for 'or', '~' for 'not' when building DataFrame boolean expressions." + ] + }, + "CANNOT_CONVERT_TYPE": { + "message": [ + "Cannot convert into ." + ] + }, + "CANNOT_DETERMINE_TYPE": { + "message": [ + "Some of types cannot be determined after inferring." + ] + }, + "CANNOT_GET_BATCH_ID": { + "message": [ + "Could not get batch id from ." + ] + }, + "CANNOT_INFER_ARRAY_TYPE": { + "message": [ + "Can not infer Array Type from a list with None as the first element." + ] + }, + "CANNOT_INFER_EMPTY_SCHEMA": { + "message": [ + "Can not infer schema from an empty dataset." + ] + }, + "CANNOT_INFER_SCHEMA_FOR_TYPE": { + "message": [ + "Can not infer schema for type: ``." + ] + }, + "CANNOT_INFER_TYPE_FOR_FIELD": { + "message": [ + "Unable to infer the type of the field ``." + ] + }, + "CANNOT_MERGE_TYPE": { + "message": [ + "Can not merge type `` and ``." + ] + }, + "CANNOT_OPEN_SOCKET": { + "message": [ + "Can not open socket: ." + ] + }, + "CANNOT_PARSE_DATATYPE": { + "message": [ + "Unable to parse datatype. ." + ] + }, + "CANNOT_PROVIDE_METADATA": { + "message": [ + "Metadata can only be provided for a single column." + ] + }, + "CANNOT_SET_TOGETHER": { + "message": [ + " should not be set together." + ] + }, + "CANNOT_SPECIFY_RETURN_TYPE_FOR_UDF": { + "message": [ + "returnType can not be specified when `` is a user-defined function, but got ." + ] + }, + "CANNOT_WITHOUT": { + "message": [ + "Cannot without ." + ] + }, + "COLUMN_IN_LIST": { + "message": [ + "`` does not allow a Column in a list." + ] + }, + "CONNECT_URL_ALREADY_DEFINED": { + "message": [ + "Only one Spark Connect client URL can be set; however, got a different URL [] from the existing []." + ] + }, + "CONNECT_URL_NOT_SET": { + "message": [ + "Cannot create a Spark Connect session because the Spark Connect remote URL has not been set. Please define the remote URL by setting either the 'spark.remote' option or the 'SPARK_REMOTE' environment variable." + ] + }, + "CONTEXT_ONLY_VALID_ON_DRIVER": { + "message": [ + "It appears that you are attempting to reference SparkContext from a broadcast variable, action, or transformation. SparkContext can only be used on the driver, not in code that it run on workers. For more information, see SPARK-5063." + ] + }, + "CONTEXT_UNAVAILABLE_FOR_REMOTE_CLIENT": { + "message": [ + "Remote client cannot create a SparkContext. Create SparkSession instead." + ] + }, + "DATA_SOURCE_CREATE_ERROR": { + "message": [ + "Failed to create python data source instance, error: ." + ] + }, + "DATA_SOURCE_INVALID_RETURN_TYPE": { + "message": [ + "Unsupported return type ('') from Python data source ''. Expected types: ." + ] + }, + "DATA_SOURCE_RETURN_SCHEMA_MISMATCH": { + "message": [ + "Return schema mismatch in the result from 'read' method. Expected: columns, Found: columns. Make sure the returned values match the required output schema." + ] + }, + "DATA_SOURCE_TYPE_MISMATCH": { + "message": [ + "Expected , but got ." + ] + }, + "DIFFERENT_PANDAS_DATAFRAME": { + "message": [ + "DataFrames are not almost equal:", + "Left:", + "", + "", + "Right:", + "", + "" + ] + }, + "DIFFERENT_PANDAS_INDEX": { + "message": [ + "Indices are not almost equal:", + "Left:", + "", + "", + "Right:", + "", + "" + ] + }, + "DIFFERENT_PANDAS_MULTIINDEX": { + "message": [ + "MultiIndices are not almost equal:", + "Left:", + "", + "", + "Right:", + "", + "" + ] + }, + "DIFFERENT_PANDAS_SERIES": { + "message": [ + "Series are not almost equal:", + "Left:", + "", + "", + "Right:", + "", + "" + ] + }, + "DIFFERENT_ROWS": { + "message": [ + "" + ] + }, + "DIFFERENT_SCHEMA": { + "message": [ + "Schemas do not match.", + "--- actual", + "+++ expected", + "" + ] + }, + "DISALLOWED_TYPE_FOR_CONTAINER": { + "message": [ + "Argument ``(type: ) should only contain a type in [], got " + ] + }, + "DUPLICATED_FIELD_NAME_IN_ARROW_STRUCT": { + "message": [ + "Duplicated field names in Arrow Struct are not allowed, got " + ] + }, + "ERROR_OCCURRED_WHILE_CALLING": { + "message": [ + "An error occurred while calling : ." + ] + }, + "FIELD_DATA_TYPE_UNACCEPTABLE": { + "message": [ + " can not accept object in type ." + ] + }, + "FIELD_DATA_TYPE_UNACCEPTABLE_WITH_NAME": { + "message": [ + ": can not accept object in type ." + ] + }, + "FIELD_NOT_NULLABLE": { + "message": [ + "Field is not nullable, but got None." + ] + }, + "FIELD_NOT_NULLABLE_WITH_NAME": { + "message": [ + ": This field is not nullable, but got None." + ] + }, + "FIELD_STRUCT_LENGTH_MISMATCH": { + "message": [ + "Length of object () does not match with length of fields ()." + ] + }, + "FIELD_STRUCT_LENGTH_MISMATCH_WITH_NAME": { + "message": [ + ": Length of object () does not match with length of fields ()." + ] + }, + "FIELD_TYPE_MISMATCH": { + "message": [ + " is not an instance of type ." + ] + }, + "FIELD_TYPE_MISMATCH_WITH_NAME": { + "message": [ + ": is not an instance of type ." + ] + }, + "HIGHER_ORDER_FUNCTION_SHOULD_RETURN_COLUMN": { + "message": [ + "Function `` should return Column, got ." + ] + }, + "INCORRECT_CONF_FOR_PROFILE": { + "message": [ + "`spark.python.profile` or `spark.python.profile.memory` configuration", + " must be set to `true` to enable Python profile." + ] + }, + "INDEX_NOT_POSITIVE": { + "message": [ + "Index must be positive, got ''." + ] + }, + "INDEX_OUT_OF_RANGE": { + "message": [ + " index out of range, got ''." + ] + }, + "INVALID_ARROW_UDTF_RETURN_TYPE": { + "message": [ + "The return type of the arrow-optimized Python UDTF should be of type 'pandas.DataFrame', but the '' method returned a value of type with value: ." + ] + }, + "INVALID_BROADCAST_OPERATION": { + "message": [ + "Broadcast can only be in driver." + ] + }, + "INVALID_CALL_ON_UNRESOLVED_OBJECT": { + "message": [ + "Invalid call to `` on unresolved object." + ] + }, + "INVALID_CONNECT_URL": { + "message": [ + "Invalid URL for Spark Connect: " + ] + }, + "INVALID_INTERVAL_CASTING": { + "message": [ + "Interval to is invalid." + ] + }, + "INVALID_ITEM_FOR_CONTAINER": { + "message": [ + "All items in `` should be in , got ." + ] + }, + "INVALID_MULTIPLE_ARGUMENT_CONDITIONS": { + "message": [ + "[{arg_names}] cannot be ." + ] + }, + "INVALID_NDARRAY_DIMENSION": { + "message": [ + "NumPy array input should be of dimensions." + ] + }, + "INVALID_NUMBER_OF_DATAFRAMES_IN_GROUP": { + "message": [ + "Invalid number of dataframes in group ." + ] + }, + "INVALID_PANDAS_UDF": { + "message": [ + "Invalid function: " + ] + }, + "INVALID_PANDAS_UDF_TYPE": { + "message": [ + "`` should be one of the values from PandasUDFType, got " + ] + }, + "INVALID_RETURN_TYPE_FOR_ARROW_UDF": { + "message": [ + "Grouped and Cogrouped map Arrow UDF should return StructType for , got ." + ] + }, + "INVALID_RETURN_TYPE_FOR_PANDAS_UDF": { + "message": [ + "Pandas UDF should return StructType for , got ." + ] + }, + "INVALID_SESSION_UUID_ID": { + "message": [ + "Parameter value must be a valid UUID format: " + ] + }, + "INVALID_TIMEOUT_TIMESTAMP": { + "message": [ + "Timeout timestamp () cannot be earlier than the current watermark ()." + ] + }, + "INVALID_TYPE": { + "message": [ + "Argument `` should not be a ." + ] + }, + "INVALID_TYPENAME_CALL": { + "message": [ + "StructField does not have typeName. Use typeName on its type explicitly instead." + ] + }, + "INVALID_TYPE_DF_EQUALITY_ARG": { + "message": [ + "Expected type for `` but got type ." + ] + }, + "INVALID_UDF_EVAL_TYPE": { + "message": [ + "Eval type for UDF must be ." + ] + }, + "INVALID_UDTF_BOTH_RETURN_TYPE_AND_ANALYZE": { + "message": [ + "The UDTF '' is invalid. It has both its return type and an 'analyze' attribute. Please make it have one of either the return type or the 'analyze' static method in '' and try again." + ] + }, + "INVALID_UDTF_EVAL_TYPE": { + "message": [ + "The eval type for the UDTF '' is invalid. It must be one of ." + ] + }, + "INVALID_UDTF_HANDLER_TYPE": { + "message": [ + "The UDTF is invalid. The function handler must be a class, but got ''. Please provide a class as the function handler." + ] + }, + "INVALID_UDTF_NO_EVAL": { + "message": [ + "The UDTF '' is invalid. It does not implement the required 'eval' method. Please implement the 'eval' method in '' and try again." + ] + }, + "INVALID_UDTF_RETURN_TYPE": { + "message": [ + "The UDTF '' is invalid. It does not specify its return type or implement the required 'analyze' static method. Please specify the return type or implement the 'analyze' static method in '' and try again." + ] + }, + "INVALID_WHEN_USAGE": { + "message": [ + "when() can only be applied on a Column previously generated by when() function, and cannot be applied once otherwise() is applied." + ] + }, + "INVALID_WINDOW_BOUND_TYPE": { + "message": [ + "Invalid window bound type: ." + ] + }, + "JAVA_GATEWAY_EXITED": { + "message": [ + "Java gateway process exited before sending its port number." + ] + }, + "JVM_ATTRIBUTE_NOT_SUPPORTED": { + "message": [ + "Attribute `` is not supported in Spark Connect as it depends on the JVM. If you need to use this attribute, do not use Spark Connect when creating your session. Visit https://spark.apache.org/docs/latest/sql-getting-started.html#starting-point-sparksession for creating regular Spark Session in detail." + ] + }, + "KEY_NOT_EXISTS": { + "message": [ + "Key `` is not exists." + ] + }, + "KEY_VALUE_PAIR_REQUIRED": { + "message": [ + "Key-value pair or a list of pairs is required." + ] + }, + "LENGTH_SHOULD_BE_THE_SAME": { + "message": [ + " and should be of the same length, got and ." + ] + }, + "MASTER_URL_NOT_SET": { + "message": [ + "A master URL must be set in your configuration." + ] + }, + "MISSING_LIBRARY_FOR_PROFILER": { + "message": [ + "Install the 'memory_profiler' library in the cluster to enable memory profiling." + ] + }, + "MISSING_VALID_PLAN": { + "message": [ + "Argument to does not contain a valid plan." + ] + }, + "MIXED_TYPE_REPLACEMENT": { + "message": [ + "Mixed type replacements are not supported." + ] + }, + "NEGATIVE_VALUE": { + "message": [ + "Value for `` must be greater than or equal to 0, got ''." + ] + }, + "NOT_BOOL": { + "message": [ + "Argument `` should be a bool, got ." + ] + }, + "NOT_BOOL_OR_DICT_OR_FLOAT_OR_INT_OR_LIST_OR_STR_OR_TUPLE": { + "message": [ + "Argument `` should be a bool, dict, float, int, str or tuple, got ." + ] + }, + "NOT_BOOL_OR_DICT_OR_FLOAT_OR_INT_OR_STR": { + "message": [ + "Argument `` should be a bool, dict, float, int or str, got ." + ] + }, + "NOT_BOOL_OR_FLOAT_OR_INT": { + "message": [ + "Argument `` should be a bool, float or int, got ." + ] + }, + "NOT_BOOL_OR_FLOAT_OR_INT_OR_LIST_OR_NONE_OR_STR_OR_TUPLE": { + "message": [ + "Argument `` should be a bool, float, int, list, None, str or tuple, got ." + ] + }, + "NOT_BOOL_OR_FLOAT_OR_INT_OR_STR": { + "message": [ + "Argument `` should be a bool, float, int or str, got ." + ] + }, + "NOT_BOOL_OR_LIST": { + "message": [ + "Argument `` should be a bool or list, got ." + ] + }, + "NOT_BOOL_OR_STR": { + "message": [ + "Argument `` should be a bool or str, got ." + ] + }, + "NOT_CALLABLE": { + "message": [ + "Argument `` should be a callable, got ." + ] + }, + "NOT_COLUMN": { + "message": [ + "Argument `` should be a Column, got ." + ] + }, + "NOT_COLUMN_OR_DATATYPE_OR_STR": { + "message": [ + "Argument `` should be a Column, str or DataType, but got ." + ] + }, + "NOT_COLUMN_OR_FLOAT_OR_INT_OR_LIST_OR_STR": { + "message": [ + "Argument `` should be a Column, float, integer, list or string, got ." + ] + }, + "NOT_COLUMN_OR_INT": { + "message": [ + "Argument `` should be a Column or int, got ." + ] + }, + "NOT_COLUMN_OR_INT_OR_LIST_OR_STR_OR_TUPLE": { + "message": [ + "Argument `` should be a Column, int, list, str or tuple, got ." + ] + }, + "NOT_COLUMN_OR_INT_OR_STR": { + "message": [ + "Argument `` should be a Column, int or str, got ." + ] + }, + "NOT_COLUMN_OR_LIST_OR_STR": { + "message": [ + "Argument `` should be a Column, list or str, got ." + ] + }, + "NOT_COLUMN_OR_STR": { + "message": [ + "Argument `` should be a Column or str, got ." + ] + }, + "NOT_COLUMN_OR_STR_OR_STRUCT": { + "message": [ + "Argument `` should be a StructType, Column or str, got ." + ] + }, + "NOT_DATAFRAME": { + "message": [ + "Argument `` should be a DataFrame, got ." + ] + }, + "NOT_DATATYPE_OR_STR": { + "message": [ + "Argument `` should be a DataType or str, got ." + ] + }, + "NOT_DICT": { + "message": [ + "Argument `` should be a dict, got ." + ] + }, + "NOT_EXPRESSION": { + "message": [ + "Argument `` should be an Expression, got ." + ] + }, + "NOT_FLOAT_OR_INT": { + "message": [ + "Argument `` should be a float or int, got ." + ] + }, + "NOT_FLOAT_OR_INT_OR_LIST_OR_STR": { + "message": [ + "Argument `` should be a float, int, list or str, got ." + ] + }, + "NOT_IMPLEMENTED": { + "message": [ + " is not implemented." + ] + }, + "NOT_INT": { + "message": [ + "Argument `` should be an int, got ." + ] + }, + "NOT_INT_OR_SLICE_OR_STR": { + "message": [ + "Argument `` should be an int, slice or str, got ." + ] + }, + "NOT_IN_BARRIER_STAGE": { + "message": [ + "It is not in a barrier stage." + ] + }, + "NOT_ITERABLE": { + "message": [ + " is not iterable." + ] + }, + "NOT_LIST": { + "message": [ + "Argument `` should be a list, got ." + ] + }, + "NOT_LIST_OF_COLUMN": { + "message": [ + "Argument `` should be a list[Column]." + ] + }, + "NOT_LIST_OF_COLUMN_OR_STR": { + "message": [ + "Argument `` should be a list[Column]." + ] + }, + "NOT_LIST_OF_FLOAT_OR_INT": { + "message": [ + "Argument `` should be a list[float, int], got ." + ] + }, + "NOT_LIST_OF_STR": { + "message": [ + "Argument `` should be a list[str], got ." + ] + }, + "NOT_LIST_OR_NONE_OR_STRUCT": { + "message": [ + "Argument `` should be a list, None or StructType, got ." + ] + }, + "NOT_LIST_OR_STR_OR_TUPLE": { + "message": [ + "Argument `` should be a list, str or tuple, got ." + ] + }, + "NOT_LIST_OR_TUPLE": { + "message": [ + "Argument `` should be a list or tuple, got ." + ] + }, + "NOT_NUMERIC_COLUMNS": { + "message": [ + "Numeric aggregation function can only be applied on numeric columns, got ." + ] + }, + "NOT_OBSERVATION_OR_STR": { + "message": [ + "Argument `` should be an Observation or str, got ." + ] + }, + "NOT_SAME_TYPE": { + "message": [ + "Argument `` and `` should be the same type, got and ." + ] + }, + "NOT_STR": { + "message": [ + "Argument `` should be a str, got ." + ] + }, + "NOT_STRUCT": { + "message": [ + "Argument `` should be a struct type, got ." + ] + }, + "NOT_STR_OR_LIST_OF_RDD": { + "message": [ + "Argument `` should be a str or list[RDD], got ." + ] + }, + "NOT_STR_OR_STRUCT": { + "message": [ + "Argument `` should be a str or struct type, got ." + ] + }, + "NOT_WINDOWSPEC": { + "message": [ + "Argument `` should be a WindowSpec, got ." + ] + }, + "NO_ACTIVE_EXCEPTION": { + "message": [ + "No active exception." + ] + }, + "NO_ACTIVE_OR_DEFAULT_SESSION": { + "message": [ + "No active or default Spark session found. Please create a new Spark session before running the code." + ] + }, + "NO_ACTIVE_SESSION": { + "message": [ + "No active Spark session found. Please create a new Spark session before running the code." + ] + }, + "NO_OBSERVE_BEFORE_GET": { + "message": [ + "Should observe by calling `DataFrame.observe` before `get`." + ] + }, + "NO_SCHEMA_AND_DRIVER_DEFAULT_SCHEME": { + "message": [ + "Only allows to be a path without scheme, and Spark Driver should use the default scheme to determine the destination file system." + ] + }, + "ONLY_ALLOWED_FOR_SINGLE_COLUMN": { + "message": [ + "Argument `` can only be provided for a single column." + ] + }, + "ONLY_ALLOW_SINGLE_TRIGGER": { + "message": [ + "Only a single trigger is allowed." + ] + }, + "ONLY_SUPPORTED_WITH_SPARK_CONNECT": { + "message": [ + " is only supported with Spark Connect; however, the current Spark session does not use Spark Connect." + ] + }, + "PACKAGE_NOT_INSTALLED": { + "message": [ + " >= must be installed; however, it was not found." + ] + }, + "PIPE_FUNCTION_EXITED": { + "message": [ + "Pipe function `` exited with error code ." + ] + }, + "PYTHON_HASH_SEED_NOT_SET": { + "message": [ + "Randomness of hash of string should be disabled via PYTHONHASHSEED." + ] + }, + "PYTHON_STREAMING_DATA_SOURCE_RUNTIME_ERROR": { + "message": [ + "Failed when running Python streaming data source: " + ] + }, + "PYTHON_VERSION_MISMATCH": { + "message": [ + "Python in worker has different version: than that in driver: , PySpark cannot run with different minor versions.", + "Please check environment variables PYSPARK_PYTHON and PYSPARK_DRIVER_PYTHON are correctly set." + ] + }, + "RDD_TRANSFORM_ONLY_VALID_ON_DRIVER": { + "message": [ + "It appears that you are attempting to broadcast an RDD or reference an RDD from an ", + "action or transformation. RDD transformations and actions can only be invoked by the ", + "driver, not inside of other transformations; for example, ", + "rdd1.map(lambda x: rdd2.values.count() * x) is invalid because the values ", + "transformation and count action cannot be performed inside of the rdd1.map ", + "transformation. For more information, see SPARK-5063." + ] + }, + "READ_ONLY": { + "message": [ + " is read-only." + ] + }, + "RESPONSE_ALREADY_RECEIVED": { + "message": [ + "OPERATION_NOT_FOUND on the server but responses were already received from it." + ] + }, + "RESULT_COLUMNS_MISMATCH_FOR_ARROW_UDF": { + "message": [ + "Column names of the returned pyarrow.Table do not match specified schema." + ] + }, + "RESULT_COLUMNS_MISMATCH_FOR_PANDAS_UDF": { + "message": [ + "Column names of the returned pandas.DataFrame do not match specified schema." + ] + }, + "RESULT_LENGTH_MISMATCH_FOR_PANDAS_UDF": { + "message": [ + "Number of columns of the returned pandas.DataFrame doesn't match specified schema. Expected: Actual: " + ] + }, + "RESULT_LENGTH_MISMATCH_FOR_SCALAR_ITER_PANDAS_UDF": { + "message": [ + "The length of output in Scalar iterator pandas UDF should be the same with the input's; however, the length of output was and the length of input was ." + ] + }, + "RESULT_TYPE_MISMATCH_FOR_ARROW_UDF": { + "message": [ + "Columns do not match in their data type: ." + ] + }, + "RETRIES_EXCEEDED": { + "message": [ + "The maximum number of retries has been exceeded." + ] + }, + "REUSE_OBSERVATION": { + "message": [ + "An Observation can be used with a DataFrame only once." + ] + }, + "SCHEMA_MISMATCH_FOR_PANDAS_UDF": { + "message": [ + "Result vector from pandas_udf was not the required length: expected , got ." + ] + }, + "SESSION_ALREADY_EXIST": { + "message": [ + "Cannot start a remote Spark session because there is a regular Spark session already running." + ] + }, + "SESSION_NEED_CONN_STR_OR_BUILDER": { + "message": [ + "Needs either connection string or channelBuilder (mutually exclusive) to create a new SparkSession." + ] + }, + "SESSION_NOT_SAME": { + "message": [ + "Both Datasets must belong to the same SparkSession." + ] + }, + "SESSION_OR_CONTEXT_EXISTS": { + "message": [ + "There should not be an existing Spark Session or Spark Context." + ] + }, + "SESSION_OR_CONTEXT_NOT_EXISTS": { + "message": [ + "SparkContext or SparkSession should be created first." + ] + }, + "SLICE_WITH_STEP": { + "message": [ + "Slice with step is not supported." + ] + }, + "STATE_NOT_EXISTS": { + "message": [ + "State is either not defined or has already been removed." + ] + }, + "STOP_ITERATION_OCCURRED": { + "message": [ + "Caught StopIteration thrown from user's code; failing the task: " + ] + }, + "STOP_ITERATION_OCCURRED_FROM_SCALAR_ITER_PANDAS_UDF": { + "message": [ + "pandas iterator UDF should exhaust the input iterator." + ] + }, + "STREAMING_CONNECT_SERIALIZATION_ERROR": { + "message": [ + "Cannot serialize the function ``. If you accessed the Spark session, or a DataFrame defined outside of the function, or any object that contains a Spark session, please be aware that they are not allowed in Spark Connect. For `foreachBatch`, please access the Spark session using `df.sparkSession`, where `df` is the first parameter in your `foreachBatch` function. For `StreamingQueryListener`, please access the Spark session using `self.spark`. For details please check out the PySpark doc for `foreachBatch` and `StreamingQueryListener`." + ] + }, + "TEST_CLASS_NOT_COMPILED": { + "message": [ + " doesn't exist. Spark sql test classes are not compiled." + ] + }, + "TOO_MANY_VALUES": { + "message": [ + "Expected values for ``, got ." + ] + }, + "TYPE_HINT_SHOULD_BE_SPECIFIED": { + "message": [ + "Type hints for should be specified; however, got ." + ] + }, + "UDF_RETURN_TYPE": { + "message": [ + "Return type of the user-defined function should be , but is ." + ] + }, + "UDTF_ARROW_TYPE_CAST_ERROR": { + "message": [ + "Cannot convert the output value of the column '' with type '' to the specified return type of the column: ''. Please check if the data types match and try again." + ] + }, + "UDTF_CONSTRUCTOR_INVALID_IMPLEMENTS_ANALYZE_METHOD": { + "message": [ + "Failed to evaluate the user-defined table function '' because its constructor is invalid: the function implements the 'analyze' method, but its constructor has more than two arguments (including the 'self' reference). Please update the table function so that its constructor accepts exactly one 'self' argument, or one 'self' argument plus another argument for the result of the 'analyze' method, and try the query again." + ] + }, + "UDTF_CONSTRUCTOR_INVALID_NO_ANALYZE_METHOD": { + "message": [ + "Failed to evaluate the user-defined table function '' because its constructor is invalid: the function does not implement the 'analyze' method, and its constructor has more than one argument (including the 'self' reference). Please update the table function so that its constructor accepts exactly one 'self' argument, and try the query again." + ] + }, + "UDTF_EVAL_METHOD_ARGUMENTS_DO_NOT_MATCH_SIGNATURE": { + "message": [ + "Failed to evaluate the user-defined table function '' because the function arguments did not match the expected signature of the 'eval' method (). Please update the query so that this table function call provides arguments matching the expected signature, or else update the table function so that its 'eval' method accepts the provided arguments, and then try the query again." + ] + }, + "UDTF_EXEC_ERROR": { + "message": [ + "User defined table function encountered an error in the '' method: " + ] + }, + "UDTF_INVALID_OUTPUT_ROW_TYPE": { + "message": [ + "The type of an individual output row in the '' method of the UDTF is invalid. Each row should be a tuple, list, or dict, but got ''. Please make sure that the output rows are of the correct type." + ] + }, + "UDTF_RETURN_NOT_ITERABLE": { + "message": [ + "The return value of the '' method of the UDTF is invalid. It should be an iterable (e.g., generator or list), but got ''. Please make sure that the UDTF returns one of these types." + ] + }, + "UDTF_RETURN_SCHEMA_MISMATCH": { + "message": [ + "The number of columns in the result does not match the specified schema. Expected column count: , Actual column count: . Please make sure the values returned by the '' method have the same number of columns as specified in the output schema." + ] + }, + "UDTF_RETURN_TYPE_MISMATCH": { + "message": [ + "Mismatch in return type for the UDTF ''. Expected a 'StructType', but got ''. Please ensure the return type is a correctly formatted StructType." + ] + }, + "UDTF_SERIALIZATION_ERROR": { + "message": [ + "Cannot serialize the UDTF '': " + ] + }, + "UNEXPECTED_RESPONSE_FROM_SERVER": { + "message": [ + "Unexpected response from iterator server." + ] + }, + "UNEXPECTED_TUPLE_WITH_STRUCT": { + "message": [ + "Unexpected tuple with StructType." + ] + }, + "UNKNOWN_EXPLAIN_MODE": { + "message": [ + "Unknown explain mode: ''. Accepted explain modes are 'simple', 'extended', 'codegen', 'cost', 'formatted'." + ] + }, + "UNKNOWN_INTERRUPT_TYPE": { + "message": [ + "Unknown interrupt type: ''. Accepted interrupt types are 'all'." + ] + }, + "UNKNOWN_RESPONSE": { + "message": [ + "Unknown response: ." + ] + }, + "UNKNOWN_VALUE_FOR": { + "message": [ + "Unknown value for ``." + ] + }, + "UNSUPPORTED_DATA_TYPE": { + "message": [ + "Unsupported DataType ``." + ] + }, + "UNSUPPORTED_DATA_TYPE_FOR_ARROW": { + "message": [ + "Single data type is not supported with Arrow." + ] + }, + "UNSUPPORTED_DATA_TYPE_FOR_ARROW_CONVERSION": { + "message": [ + " is not supported in conversion to Arrow." + ] + }, + "UNSUPPORTED_DATA_TYPE_FOR_ARROW_VERSION": { + "message": [ + " is only supported with pyarrow 2.0.0 and above." + ] + }, + "UNSUPPORTED_JOIN_TYPE": { + "message": [ + "Unsupported join type: . Supported join types include: 'inner', 'outer', 'full', 'fullouter', 'full_outer', 'leftouter', 'left', 'left_outer', 'rightouter', 'right', 'right_outer', 'leftsemi', 'left_semi', 'semi', 'leftanti', 'left_anti', 'anti', 'cross'." + ] + }, + "UNSUPPORTED_LITERAL": { + "message": [ + "Unsupported Literal ''." + ] + }, + "UNSUPPORTED_LOCAL_CONNECTION_STRING": { + "message": [ + "Creating new SparkSessions with `local` connection string is not supported." + ] + }, + "UNSUPPORTED_NUMPY_ARRAY_SCALAR": { + "message": [ + "The type of array scalar '' is not supported." + ] + }, + "UNSUPPORTED_OPERATION": { + "message": [ + " is not supported." + ] + }, + "UNSUPPORTED_PACKAGE_VERSION": { + "message": [ + " >= must be installed; however, your version is ." + ] + }, + "UNSUPPORTED_PARAM_TYPE_FOR_HIGHER_ORDER_FUNCTION": { + "message": [ + "Function `` should use only POSITIONAL or POSITIONAL OR KEYWORD arguments." + ] + }, + "UNSUPPORTED_SIGNATURE": { + "message": [ + "Unsupported signature: ." + ] + }, + "UNSUPPORTED_WITH_ARROW_OPTIMIZATION": { + "message": [ + " is not supported with Arrow optimization enabled in Python UDFs. Disable 'spark.sql.execution.pythonUDF.arrow.enabled' to workaround." + ] + }, + "VALUE_ALLOWED": { + "message": [ + "Value for `` does not allow ." + ] + }, + "VALUE_NOT_ACCESSIBLE": { + "message": [ + "Value `` cannot be accessed inside tasks." + ] + }, + "VALUE_NOT_ALLOWED": { + "message": [ + "Value for `` has to be amongst the following values: ." + ] + }, + "VALUE_NOT_ANY_OR_ALL": { + "message": [ + "Value for `` must be 'any' or 'all', got ''." + ] + }, + "VALUE_NOT_BETWEEN": { + "message": [ + "Value for `` must be between and ." + ] + }, + "VALUE_NOT_NON_EMPTY_STR": { + "message": [ + "Value for `` must be a non-empty string, got ''." + ] + }, + "VALUE_NOT_PEARSON": { + "message": [ + "Value for `` only supports the 'pearson', got ''." + ] + }, + "VALUE_NOT_PLAIN_COLUMN_REFERENCE": { + "message": [ + "Value `` in `` should be a plain column reference such as `df.col` or `col('column')`." + ] + }, + "VALUE_NOT_POSITIVE": { + "message": [ + "Value for `` must be positive, got ''." + ] + }, + "VALUE_NOT_TRUE": { + "message": [ + "Value for `` must be True, got ''." + ] + }, + "VALUE_OUT_OF_BOUNDS": { + "message": [ + "Value for `` must be between and (inclusive), got " + ] + }, + "WRONG_NUM_ARGS_FOR_HIGHER_ORDER_FUNCTION": { + "message": [ + "Function `` should take between 1 and 3 arguments, but the provided function takes ." + ] + }, + "WRONG_NUM_COLUMNS": { + "message": [ + "Function `` should take at least columns." + ] + }, + "ZERO_INDEX": { + "message": [ + "Index must be non-zero." + ] + } +} diff --git a/python/pyspark/errors/error_classes.py b/python/pyspark/errors/error_classes.py index 6b7f19b449185..c6b60c79b34d6 100644 --- a/python/pyspark/errors/error_classes.py +++ b/python/pyspark/errors/error_classes.py @@ -15,1160 +15,17 @@ # limitations under the License. # -# NOTE: Automatically sort this file via -# - cd $SPARK_HOME -# - bin/pyspark -# - from pyspark.errors.exceptions import _write_self; _write_self() import json +import importlib.resources - -ERROR_CLASSES_JSON = ''' -{ - "APPLICATION_NAME_NOT_SET": { - "message": [ - "An application name must be set in your configuration." - ] - }, - "ARGUMENT_REQUIRED": { - "message": [ - "Argument `` is required when ." - ] - }, - "ARROW_LEGACY_IPC_FORMAT": { - "message": [ - "Arrow legacy IPC format is not supported in PySpark, please unset ARROW_PRE_0_15_IPC_FORMAT." - ] - }, - "ATTRIBUTE_NOT_CALLABLE": { - "message": [ - "Attribute `` in provided object `` is not callable." - ] - }, - "ATTRIBUTE_NOT_SUPPORTED": { - "message": [ - "Attribute `` is not supported." - ] - }, - "AXIS_LENGTH_MISMATCH": { - "message": [ - "Length mismatch: Expected axis has element, new values have elements." - ] - }, - "BROADCAST_VARIABLE_NOT_LOADED": { - "message": [ - "Broadcast variable `` not loaded." - ] - }, - "CALL_BEFORE_INITIALIZE": { - "message": [ - "Not supported to call `` before initialize ." - ] - }, - "CANNOT_ACCEPT_OBJECT_IN_TYPE": { - "message": [ - "`` can not accept object `` in type ``." - ] - }, - "CANNOT_ACCESS_TO_DUNDER": { - "message": [ - "Dunder(double underscore) attribute is for internal use only." - ] - }, - "CANNOT_APPLY_IN_FOR_COLUMN": { - "message": [ - "Cannot apply 'in' operator against a column: please use 'contains' in a string column or 'array_contains' function for an array column." - ] - }, - "CANNOT_BE_EMPTY": { - "message": [ - "At least one must be specified." - ] - }, - "CANNOT_BE_NONE": { - "message": [ - "Argument `` cannot be None." - ] - }, - "CANNOT_CONFIGURE_SPARK_CONNECT": { - "message": [ - "Spark Connect server cannot be configured: Existing [], New []." - ] - }, - "CANNOT_CONFIGURE_SPARK_CONNECT_MASTER": { - "message": [ - "Spark Connect server and Spark master cannot be configured together: Spark master [], Spark Connect []." - ] - }, - "CANNOT_CONVERT_COLUMN_INTO_BOOL": { - "message": [ - "Cannot convert column into bool: please use '&' for 'and', '|' for 'or', '~' for 'not' when building DataFrame boolean expressions." - ] - }, - "CANNOT_CONVERT_TYPE": { - "message": [ - "Cannot convert into ." - ] - }, - "CANNOT_DETERMINE_TYPE": { - "message": [ - "Some of types cannot be determined after inferring." - ] - }, - "CANNOT_GET_BATCH_ID": { - "message": [ - "Could not get batch id from ." - ] - }, - "CANNOT_INFER_ARRAY_TYPE": { - "message": [ - "Can not infer Array Type from a list with None as the first element." - ] - }, - "CANNOT_INFER_EMPTY_SCHEMA": { - "message": [ - "Can not infer schema from an empty dataset." - ] - }, - "CANNOT_INFER_SCHEMA_FOR_TYPE": { - "message": [ - "Can not infer schema for type: ``." - ] - }, - "CANNOT_INFER_TYPE_FOR_FIELD": { - "message": [ - "Unable to infer the type of the field ``." - ] - }, - "CANNOT_MERGE_TYPE": { - "message": [ - "Can not merge type `` and ``." - ] - }, - "CANNOT_OPEN_SOCKET": { - "message": [ - "Can not open socket: ." - ] - }, - "CANNOT_PARSE_DATATYPE": { - "message": [ - "Unable to parse datatype. ." - ] - }, - "CANNOT_PROVIDE_METADATA": { - "message": [ - "Metadata can only be provided for a single column." - ] - }, - "CANNOT_SET_TOGETHER": { - "message": [ - " should not be set together." - ] - }, - "CANNOT_SPECIFY_RETURN_TYPE_FOR_UDF": { - "message": [ - "returnType can not be specified when `` is a user-defined function, but got ." - ] - }, - "CANNOT_WITHOUT": { - "message": [ - "Cannot without ." - ] - }, - "COLUMN_IN_LIST": { - "message": [ - "`` does not allow a Column in a list." - ] - }, - "CONNECT_URL_ALREADY_DEFINED": { - "message": [ - "Only one Spark Connect client URL can be set; however, got a different URL [] from the existing []." - ] - }, - "CONNECT_URL_NOT_SET": { - "message": [ - "Cannot create a Spark Connect session because the Spark Connect remote URL has not been set. Please define the remote URL by setting either the 'spark.remote' option or the 'SPARK_REMOTE' environment variable." - ] - }, - "CONTEXT_ONLY_VALID_ON_DRIVER": { - "message": [ - "It appears that you are attempting to reference SparkContext from a broadcast variable, action, or transformation. SparkContext can only be used on the driver, not in code that it run on workers. For more information, see SPARK-5063." - ] - }, - "CONTEXT_UNAVAILABLE_FOR_REMOTE_CLIENT": { - "message": [ - "Remote client cannot create a SparkContext. Create SparkSession instead." - ] - }, - "DATA_SOURCE_CREATE_ERROR": { - "message": [ - "Failed to create python data source instance, error: ." - ] - }, - "DATA_SOURCE_INVALID_RETURN_TYPE": { - "message": [ - "Unsupported return type ('') from Python data source ''. Expected types: ." - ] - }, - "DATA_SOURCE_RETURN_SCHEMA_MISMATCH": { - "message": [ - "Return schema mismatch in the result from 'read' method. Expected: columns, Found: columns. Make sure the returned values match the required output schema." - ] - }, - "DATA_SOURCE_TYPE_MISMATCH": { - "message": [ - "Expected , but got ." - ] - }, - "DIFFERENT_PANDAS_DATAFRAME": { - "message": [ - "DataFrames are not almost equal:", - "Left:", - "", - "", - "Right:", - "", - "" - ] - }, - "DIFFERENT_PANDAS_INDEX": { - "message": [ - "Indices are not almost equal:", - "Left:", - "", - "", - "Right:", - "", - "" - ] - }, - "DIFFERENT_PANDAS_MULTIINDEX": { - "message": [ - "MultiIndices are not almost equal:", - "Left:", - "", - "", - "Right:", - "", - "" - ] - }, - "DIFFERENT_PANDAS_SERIES": { - "message": [ - "Series are not almost equal:", - "Left:", - "", - "", - "Right:", - "", - "" - ] - }, - "DIFFERENT_ROWS": { - "message": [ - "" - ] - }, - "DIFFERENT_SCHEMA": { - "message": [ - "Schemas do not match.", - "--- actual", - "+++ expected", - "" - ] - }, - "DISALLOWED_TYPE_FOR_CONTAINER": { - "message": [ - "Argument ``(type: ) should only contain a type in [], got " - ] - }, - "DUPLICATED_FIELD_NAME_IN_ARROW_STRUCT": { - "message": [ - "Duplicated field names in Arrow Struct are not allowed, got " - ] - }, - "ERROR_OCCURRED_WHILE_CALLING": { - "message": [ - "An error occurred while calling : ." - ] - }, - "FIELD_DATA_TYPE_UNACCEPTABLE": { - "message": [ - " can not accept object in type ." - ] - }, - "FIELD_DATA_TYPE_UNACCEPTABLE_WITH_NAME": { - "message": [ - ": can not accept object in type ." - ] - }, - "FIELD_NOT_NULLABLE": { - "message": [ - "Field is not nullable, but got None." - ] - }, - "FIELD_NOT_NULLABLE_WITH_NAME": { - "message": [ - ": This field is not nullable, but got None." - ] - }, - "FIELD_STRUCT_LENGTH_MISMATCH": { - "message": [ - "Length of object () does not match with length of fields ()." - ] - }, - "FIELD_STRUCT_LENGTH_MISMATCH_WITH_NAME": { - "message": [ - ": Length of object () does not match with length of fields ()." - ] - }, - "FIELD_TYPE_MISMATCH": { - "message": [ - " is not an instance of type ." - ] - }, - "FIELD_TYPE_MISMATCH_WITH_NAME": { - "message": [ - ": is not an instance of type ." - ] - }, - "HIGHER_ORDER_FUNCTION_SHOULD_RETURN_COLUMN": { - "message": [ - "Function `` should return Column, got ." - ] - }, - "INCORRECT_CONF_FOR_PROFILE": { - "message": [ - "`spark.python.profile` or `spark.python.profile.memory` configuration", - " must be set to `true` to enable Python profile." - ] - }, - "INDEX_NOT_POSITIVE": { - "message": [ - "Index must be positive, got ''." - ] - }, - "INDEX_OUT_OF_RANGE": { - "message": [ - " index out of range, got ''." - ] - }, - "INVALID_ARROW_UDTF_RETURN_TYPE": { - "message": [ - "The return type of the arrow-optimized Python UDTF should be of type 'pandas.DataFrame', but the '' method returned a value of type with value: ." - ] - }, - "INVALID_BROADCAST_OPERATION": { - "message": [ - "Broadcast can only be in driver." - ] - }, - "INVALID_CALL_ON_UNRESOLVED_OBJECT": { - "message": [ - "Invalid call to `` on unresolved object." - ] - }, - "INVALID_CONNECT_URL": { - "message": [ - "Invalid URL for Spark Connect: " - ] - }, - "INVALID_INTERVAL_CASTING": { - "message": [ - "Interval to is invalid." - ] - }, - "INVALID_ITEM_FOR_CONTAINER": { - "message": [ - "All items in `` should be in , got ." - ] - }, - "INVALID_MULTIPLE_ARGUMENT_CONDITIONS": { - "message": [ - "[{arg_names}] cannot be ." - ] - }, - "INVALID_NDARRAY_DIMENSION": { - "message": [ - "NumPy array input should be of dimensions." - ] - }, - "INVALID_NUMBER_OF_DATAFRAMES_IN_GROUP": { - "message": [ - "Invalid number of dataframes in group ." - ] - }, - "INVALID_PANDAS_UDF": { - "message": [ - "Invalid function: " - ] - }, - "INVALID_PANDAS_UDF_TYPE": { - "message": [ - "`` should be one of the values from PandasUDFType, got " - ] - }, - "INVALID_RETURN_TYPE_FOR_ARROW_UDF": { - "message": [ - "Grouped and Cogrouped map Arrow UDF should return StructType for , got ." - ] - }, - "INVALID_RETURN_TYPE_FOR_PANDAS_UDF": { - "message": [ - "Pandas UDF should return StructType for , got ." - ] - }, - "INVALID_SESSION_UUID_ID": { - "message": [ - "Parameter value must be a valid UUID format: " - ] - }, - "INVALID_TIMEOUT_TIMESTAMP": { - "message": [ - "Timeout timestamp () cannot be earlier than the current watermark ()." - ] - }, - "INVALID_TYPE": { - "message": [ - "Argument `` should not be a ." - ] - }, - "INVALID_TYPENAME_CALL": { - "message": [ - "StructField does not have typeName. Use typeName on its type explicitly instead." - ] - }, - "INVALID_TYPE_DF_EQUALITY_ARG": { - "message": [ - "Expected type for `` but got type ." - ] - }, - "INVALID_UDF_EVAL_TYPE": { - "message": [ - "Eval type for UDF must be ." - ] - }, - "INVALID_UDTF_BOTH_RETURN_TYPE_AND_ANALYZE": { - "message": [ - "The UDTF '' is invalid. It has both its return type and an 'analyze' attribute. Please make it have one of either the return type or the 'analyze' static method in '' and try again." - ] - }, - "INVALID_UDTF_EVAL_TYPE": { - "message": [ - "The eval type for the UDTF '' is invalid. It must be one of ." - ] - }, - "INVALID_UDTF_HANDLER_TYPE": { - "message": [ - "The UDTF is invalid. The function handler must be a class, but got ''. Please provide a class as the function handler." - ] - }, - "INVALID_UDTF_NO_EVAL": { - "message": [ - "The UDTF '' is invalid. It does not implement the required 'eval' method. Please implement the 'eval' method in '' and try again." - ] - }, - "INVALID_UDTF_RETURN_TYPE": { - "message": [ - "The UDTF '' is invalid. It does not specify its return type or implement the required 'analyze' static method. Please specify the return type or implement the 'analyze' static method in '' and try again." - ] - }, - "INVALID_WHEN_USAGE": { - "message": [ - "when() can only be applied on a Column previously generated by when() function, and cannot be applied once otherwise() is applied." - ] - }, - "INVALID_WINDOW_BOUND_TYPE": { - "message": [ - "Invalid window bound type: ." - ] - }, - "JAVA_GATEWAY_EXITED": { - "message": [ - "Java gateway process exited before sending its port number." - ] - }, - "JVM_ATTRIBUTE_NOT_SUPPORTED": { - "message": [ - "Attribute `` is not supported in Spark Connect as it depends on the JVM. If you need to use this attribute, do not use Spark Connect when creating your session. Visit https://spark.apache.org/docs/latest/sql-getting-started.html#starting-point-sparksession for creating regular Spark Session in detail." - ] - }, - "KEY_NOT_EXISTS": { - "message": [ - "Key `` is not exists." - ] - }, - "KEY_VALUE_PAIR_REQUIRED": { - "message": [ - "Key-value pair or a list of pairs is required." - ] - }, - "LENGTH_SHOULD_BE_THE_SAME": { - "message": [ - " and should be of the same length, got and ." - ] - }, - "MASTER_URL_NOT_SET": { - "message": [ - "A master URL must be set in your configuration." - ] - }, - "MISSING_LIBRARY_FOR_PROFILER": { - "message": [ - "Install the 'memory_profiler' library in the cluster to enable memory profiling." - ] - }, - "MISSING_VALID_PLAN": { - "message": [ - "Argument to does not contain a valid plan." - ] - }, - "MIXED_TYPE_REPLACEMENT": { - "message": [ - "Mixed type replacements are not supported." - ] - }, - "NEGATIVE_VALUE": { - "message": [ - "Value for `` must be greater than or equal to 0, got ''." - ] - }, - "NOT_BOOL": { - "message": [ - "Argument `` should be a bool, got ." - ] - }, - "NOT_BOOL_OR_DICT_OR_FLOAT_OR_INT_OR_LIST_OR_STR_OR_TUPLE": { - "message": [ - "Argument `` should be a bool, dict, float, int, str or tuple, got ." - ] - }, - "NOT_BOOL_OR_DICT_OR_FLOAT_OR_INT_OR_STR": { - "message": [ - "Argument `` should be a bool, dict, float, int or str, got ." - ] - }, - "NOT_BOOL_OR_FLOAT_OR_INT": { - "message": [ - "Argument `` should be a bool, float or int, got ." - ] - }, - "NOT_BOOL_OR_FLOAT_OR_INT_OR_LIST_OR_NONE_OR_STR_OR_TUPLE": { - "message": [ - "Argument `` should be a bool, float, int, list, None, str or tuple, got ." - ] - }, - "NOT_BOOL_OR_FLOAT_OR_INT_OR_STR": { - "message": [ - "Argument `` should be a bool, float, int or str, got ." - ] - }, - "NOT_BOOL_OR_LIST": { - "message": [ - "Argument `` should be a bool or list, got ." - ] - }, - "NOT_BOOL_OR_STR": { - "message": [ - "Argument `` should be a bool or str, got ." - ] - }, - "NOT_CALLABLE": { - "message": [ - "Argument `` should be a callable, got ." - ] - }, - "NOT_COLUMN": { - "message": [ - "Argument `` should be a Column, got ." - ] - }, - "NOT_COLUMN_OR_DATATYPE_OR_STR": { - "message": [ - "Argument `` should be a Column, str or DataType, but got ." - ] - }, - "NOT_COLUMN_OR_FLOAT_OR_INT_OR_LIST_OR_STR": { - "message": [ - "Argument `` should be a Column, float, integer, list or string, got ." - ] - }, - "NOT_COLUMN_OR_INT": { - "message": [ - "Argument `` should be a Column or int, got ." - ] - }, - "NOT_COLUMN_OR_INT_OR_LIST_OR_STR_OR_TUPLE": { - "message": [ - "Argument `` should be a Column, int, list, str or tuple, got ." - ] - }, - "NOT_COLUMN_OR_INT_OR_STR": { - "message": [ - "Argument `` should be a Column, int or str, got ." - ] - }, - "NOT_COLUMN_OR_LIST_OR_STR": { - "message": [ - "Argument `` should be a Column, list or str, got ." - ] - }, - "NOT_COLUMN_OR_STR": { - "message": [ - "Argument `` should be a Column or str, got ." - ] - }, - "NOT_COLUMN_OR_STR_OR_STRUCT": { - "message": [ - "Argument `` should be a StructType, Column or str, got ." - ] - }, - "NOT_DATAFRAME": { - "message": [ - "Argument `` should be a DataFrame, got ." - ] - }, - "NOT_DATATYPE_OR_STR": { - "message": [ - "Argument `` should be a DataType or str, got ." - ] - }, - "NOT_DICT": { - "message": [ - "Argument `` should be a dict, got ." - ] - }, - "NOT_EXPRESSION": { - "message": [ - "Argument `` should be an Expression, got ." - ] - }, - "NOT_FLOAT_OR_INT": { - "message": [ - "Argument `` should be a float or int, got ." - ] - }, - "NOT_FLOAT_OR_INT_OR_LIST_OR_STR": { - "message": [ - "Argument `` should be a float, int, list or str, got ." - ] - }, - "NOT_IMPLEMENTED": { - "message": [ - " is not implemented." - ] - }, - "NOT_INT": { - "message": [ - "Argument `` should be an int, got ." - ] - }, - "NOT_INT_OR_SLICE_OR_STR": { - "message": [ - "Argument `` should be an int, slice or str, got ." - ] - }, - "NOT_IN_BARRIER_STAGE": { - "message": [ - "It is not in a barrier stage." - ] - }, - "NOT_ITERABLE": { - "message": [ - " is not iterable." - ] - }, - "NOT_LIST": { - "message": [ - "Argument `` should be a list, got ." - ] - }, - "NOT_LIST_OF_COLUMN": { - "message": [ - "Argument `` should be a list[Column]." - ] - }, - "NOT_LIST_OF_COLUMN_OR_STR": { - "message": [ - "Argument `` should be a list[Column]." - ] - }, - "NOT_LIST_OF_FLOAT_OR_INT": { - "message": [ - "Argument `` should be a list[float, int], got ." - ] - }, - "NOT_LIST_OF_STR": { - "message": [ - "Argument `` should be a list[str], got ." - ] - }, - "NOT_LIST_OR_NONE_OR_STRUCT": { - "message": [ - "Argument `` should be a list, None or StructType, got ." - ] - }, - "NOT_LIST_OR_STR_OR_TUPLE": { - "message": [ - "Argument `` should be a list, str or tuple, got ." - ] - }, - "NOT_LIST_OR_TUPLE": { - "message": [ - "Argument `` should be a list or tuple, got ." - ] - }, - "NOT_NUMERIC_COLUMNS": { - "message": [ - "Numeric aggregation function can only be applied on numeric columns, got ." - ] - }, - "NOT_OBSERVATION_OR_STR": { - "message": [ - "Argument `` should be an Observation or str, got ." - ] - }, - "NOT_SAME_TYPE": { - "message": [ - "Argument `` and `` should be the same type, got and ." - ] - }, - "NOT_STR": { - "message": [ - "Argument `` should be a str, got ." - ] - }, - "NOT_STRUCT": { - "message": [ - "Argument `` should be a struct type, got ." - ] - }, - "NOT_STR_OR_LIST_OF_RDD": { - "message": [ - "Argument `` should be a str or list[RDD], got ." - ] - }, - "NOT_STR_OR_STRUCT": { - "message": [ - "Argument `` should be a str or struct type, got ." - ] - }, - "NOT_WINDOWSPEC": { - "message": [ - "Argument `` should be a WindowSpec, got ." - ] - }, - "NO_ACTIVE_EXCEPTION": { - "message": [ - "No active exception." - ] - }, - "NO_ACTIVE_OR_DEFAULT_SESSION": { - "message": [ - "No active or default Spark session found. Please create a new Spark session before running the code." - ] - }, - "NO_ACTIVE_SESSION": { - "message": [ - "No active Spark session found. Please create a new Spark session before running the code." - ] - }, - "NO_OBSERVE_BEFORE_GET": { - "message": [ - "Should observe by calling `DataFrame.observe` before `get`." - ] - }, - "NO_SCHEMA_AND_DRIVER_DEFAULT_SCHEME": { - "message": [ - "Only allows to be a path without scheme, and Spark Driver should use the default scheme to determine the destination file system." - ] - }, - "ONLY_ALLOWED_FOR_SINGLE_COLUMN": { - "message": [ - "Argument `` can only be provided for a single column." - ] - }, - "ONLY_ALLOW_SINGLE_TRIGGER": { - "message": [ - "Only a single trigger is allowed." - ] - }, - "ONLY_SUPPORTED_WITH_SPARK_CONNECT": { - "message": [ - " is only supported with Spark Connect; however, the current Spark session does not use Spark Connect." - ] - }, - "PACKAGE_NOT_INSTALLED": { - "message": [ - " >= must be installed; however, it was not found." - ] - }, - "PIPE_FUNCTION_EXITED": { - "message": [ - "Pipe function `` exited with error code ." - ] - }, - "PYTHON_HASH_SEED_NOT_SET": { - "message": [ - "Randomness of hash of string should be disabled via PYTHONHASHSEED." - ] - }, - "PYTHON_STREAMING_DATA_SOURCE_RUNTIME_ERROR": { - "message": [ - "Failed when running Python streaming data source: " - ] - }, - "PYTHON_VERSION_MISMATCH": { - "message": [ - "Python in worker has different version: than that in driver: , PySpark cannot run with different minor versions.", - "Please check environment variables PYSPARK_PYTHON and PYSPARK_DRIVER_PYTHON are correctly set." - ] - }, - "RDD_TRANSFORM_ONLY_VALID_ON_DRIVER": { - "message": [ - "It appears that you are attempting to broadcast an RDD or reference an RDD from an ", - "action or transformation. RDD transformations and actions can only be invoked by the ", - "driver, not inside of other transformations; for example, ", - "rdd1.map(lambda x: rdd2.values.count() * x) is invalid because the values ", - "transformation and count action cannot be performed inside of the rdd1.map ", - "transformation. For more information, see SPARK-5063." - ] - }, - "READ_ONLY": { - "message": [ - " is read-only." - ] - }, - "RESPONSE_ALREADY_RECEIVED": { - "message": [ - "OPERATION_NOT_FOUND on the server but responses were already received from it." - ] - }, - "RESULT_COLUMNS_MISMATCH_FOR_ARROW_UDF": { - "message": [ - "Column names of the returned pyarrow.Table do not match specified schema." - ] - }, - "RESULT_COLUMNS_MISMATCH_FOR_PANDAS_UDF": { - "message": [ - "Column names of the returned pandas.DataFrame do not match specified schema." - ] - }, - "RESULT_LENGTH_MISMATCH_FOR_PANDAS_UDF": { - "message": [ - "Number of columns of the returned pandas.DataFrame doesn't match specified schema. Expected: Actual: " - ] - }, - "RESULT_LENGTH_MISMATCH_FOR_SCALAR_ITER_PANDAS_UDF": { - "message": [ - "The length of output in Scalar iterator pandas UDF should be the same with the input's; however, the length of output was and the length of input was ." - ] - }, - "RESULT_TYPE_MISMATCH_FOR_ARROW_UDF": { - "message": [ - "Columns do not match in their data type: ." - ] - }, - "RETRIES_EXCEEDED": { - "message": [ - "The maximum number of retries has been exceeded." - ] - }, - "REUSE_OBSERVATION": { - "message": [ - "An Observation can be used with a DataFrame only once." - ] - }, - "SCHEMA_MISMATCH_FOR_PANDAS_UDF": { - "message": [ - "Result vector from pandas_udf was not the required length: expected , got ." - ] - }, - "SESSION_ALREADY_EXIST": { - "message": [ - "Cannot start a remote Spark session because there is a regular Spark session already running." - ] - }, - "SESSION_NEED_CONN_STR_OR_BUILDER": { - "message": [ - "Needs either connection string or channelBuilder (mutually exclusive) to create a new SparkSession." - ] - }, - "SESSION_NOT_SAME": { - "message": [ - "Both Datasets must belong to the same SparkSession." - ] - }, - "SESSION_OR_CONTEXT_EXISTS": { - "message": [ - "There should not be an existing Spark Session or Spark Context." - ] - }, - "SESSION_OR_CONTEXT_NOT_EXISTS": { - "message": [ - "SparkContext or SparkSession should be created first." - ] - }, - "SLICE_WITH_STEP": { - "message": [ - "Slice with step is not supported." - ] - }, - "STATE_NOT_EXISTS": { - "message": [ - "State is either not defined or has already been removed." - ] - }, - "STOP_ITERATION_OCCURRED": { - "message": [ - "Caught StopIteration thrown from user's code; failing the task: " - ] - }, - "STOP_ITERATION_OCCURRED_FROM_SCALAR_ITER_PANDAS_UDF": { - "message": [ - "pandas iterator UDF should exhaust the input iterator." - ] - }, - "STREAMING_CONNECT_SERIALIZATION_ERROR": { - "message": [ - "Cannot serialize the function ``. If you accessed the Spark session, or a DataFrame defined outside of the function, or any object that contains a Spark session, please be aware that they are not allowed in Spark Connect. For `foreachBatch`, please access the Spark session using `df.sparkSession`, where `df` is the first parameter in your `foreachBatch` function. For `StreamingQueryListener`, please access the Spark session using `self.spark`. For details please check out the PySpark doc for `foreachBatch` and `StreamingQueryListener`." - ] - }, - "TEST_CLASS_NOT_COMPILED": { - "message": [ - " doesn't exist. Spark sql test classes are not compiled." - ] - }, - "TOO_MANY_VALUES": { - "message": [ - "Expected values for ``, got ." - ] - }, - "TYPE_HINT_SHOULD_BE_SPECIFIED": { - "message": [ - "Type hints for should be specified; however, got ." - ] - }, - "UDF_RETURN_TYPE": { - "message": [ - "Return type of the user-defined function should be , but is ." - ] - }, - "UDTF_ARROW_TYPE_CAST_ERROR": { - "message": [ - "Cannot convert the output value of the column '' with type '' to the specified return type of the column: ''. Please check if the data types match and try again." - ] - }, - "UDTF_CONSTRUCTOR_INVALID_IMPLEMENTS_ANALYZE_METHOD": { - "message": [ - "Failed to evaluate the user-defined table function '' because its constructor is invalid: the function implements the 'analyze' method, but its constructor has more than two arguments (including the 'self' reference). Please update the table function so that its constructor accepts exactly one 'self' argument, or one 'self' argument plus another argument for the result of the 'analyze' method, and try the query again." - ] - }, - "UDTF_CONSTRUCTOR_INVALID_NO_ANALYZE_METHOD": { - "message": [ - "Failed to evaluate the user-defined table function '' because its constructor is invalid: the function does not implement the 'analyze' method, and its constructor has more than one argument (including the 'self' reference). Please update the table function so that its constructor accepts exactly one 'self' argument, and try the query again." - ] - }, - "UDTF_EVAL_METHOD_ARGUMENTS_DO_NOT_MATCH_SIGNATURE": { - "message": [ - "Failed to evaluate the user-defined table function '' because the function arguments did not match the expected signature of the 'eval' method (). Please update the query so that this table function call provides arguments matching the expected signature, or else update the table function so that its 'eval' method accepts the provided arguments, and then try the query again." - ] - }, - "UDTF_EXEC_ERROR": { - "message": [ - "User defined table function encountered an error in the '' method: " - ] - }, - "UDTF_INVALID_OUTPUT_ROW_TYPE": { - "message": [ - "The type of an individual output row in the '' method of the UDTF is invalid. Each row should be a tuple, list, or dict, but got ''. Please make sure that the output rows are of the correct type." - ] - }, - "UDTF_RETURN_NOT_ITERABLE": { - "message": [ - "The return value of the '' method of the UDTF is invalid. It should be an iterable (e.g., generator or list), but got ''. Please make sure that the UDTF returns one of these types." - ] - }, - "UDTF_RETURN_SCHEMA_MISMATCH": { - "message": [ - "The number of columns in the result does not match the specified schema. Expected column count: , Actual column count: . Please make sure the values returned by the '' method have the same number of columns as specified in the output schema." - ] - }, - "UDTF_RETURN_TYPE_MISMATCH": { - "message": [ - "Mismatch in return type for the UDTF ''. Expected a 'StructType', but got ''. Please ensure the return type is a correctly formatted StructType." - ] - }, - "UDTF_SERIALIZATION_ERROR": { - "message": [ - "Cannot serialize the UDTF '': " - ] - }, - "UNEXPECTED_RESPONSE_FROM_SERVER": { - "message": [ - "Unexpected response from iterator server." - ] - }, - "UNEXPECTED_TUPLE_WITH_STRUCT": { - "message": [ - "Unexpected tuple with StructType." - ] - }, - "UNKNOWN_EXPLAIN_MODE": { - "message": [ - "Unknown explain mode: ''. Accepted explain modes are 'simple', 'extended', 'codegen', 'cost', 'formatted'." - ] - }, - "UNKNOWN_INTERRUPT_TYPE": { - "message": [ - "Unknown interrupt type: ''. Accepted interrupt types are 'all'." - ] - }, - "UNKNOWN_RESPONSE": { - "message": [ - "Unknown response: ." - ] - }, - "UNKNOWN_VALUE_FOR": { - "message": [ - "Unknown value for ``." - ] - }, - "UNSUPPORTED_DATA_TYPE": { - "message": [ - "Unsupported DataType ``." - ] - }, - "UNSUPPORTED_DATA_TYPE_FOR_ARROW": { - "message": [ - "Single data type is not supported with Arrow." - ] - }, - "UNSUPPORTED_DATA_TYPE_FOR_ARROW_CONVERSION": { - "message": [ - " is not supported in conversion to Arrow." - ] - }, - "UNSUPPORTED_DATA_TYPE_FOR_ARROW_VERSION": { - "message": [ - " is only supported with pyarrow 2.0.0 and above." - ] - }, - "UNSUPPORTED_JOIN_TYPE": { - "message": [ - "Unsupported join type: . Supported join types include: 'inner', 'outer', 'full', 'fullouter', 'full_outer', 'leftouter', 'left', 'left_outer', 'rightouter', 'right', 'right_outer', 'leftsemi', 'left_semi', 'semi', 'leftanti', 'left_anti', 'anti', 'cross'." - ] - }, - "UNSUPPORTED_LITERAL": { - "message": [ - "Unsupported Literal ''." - ] - }, - "UNSUPPORTED_LOCAL_CONNECTION_STRING": { - "message": [ - "Creating new SparkSessions with `local` connection string is not supported." - ] - }, - "UNSUPPORTED_NUMPY_ARRAY_SCALAR": { - "message": [ - "The type of array scalar '' is not supported." - ] - }, - "UNSUPPORTED_OPERATION": { - "message": [ - " is not supported." - ] - }, - "UNSUPPORTED_PACKAGE_VERSION": { - "message": [ - " >= must be installed; however, your version is ." - ] - }, - "UNSUPPORTED_PARAM_TYPE_FOR_HIGHER_ORDER_FUNCTION": { - "message": [ - "Function `` should use only POSITIONAL or POSITIONAL OR KEYWORD arguments." - ] - }, - "UNSUPPORTED_SIGNATURE": { - "message": [ - "Unsupported signature: ." - ] - }, - "UNSUPPORTED_WITH_ARROW_OPTIMIZATION": { - "message": [ - " is not supported with Arrow optimization enabled in Python UDFs. Disable 'spark.sql.execution.pythonUDF.arrow.enabled' to workaround." - ] - }, - "VALUE_ALLOWED": { - "message": [ - "Value for `` does not allow ." - ] - }, - "VALUE_NOT_ACCESSIBLE": { - "message": [ - "Value `` cannot be accessed inside tasks." - ] - }, - "VALUE_NOT_ALLOWED": { - "message": [ - "Value for `` has to be amongst the following values: ." - ] - }, - "VALUE_NOT_ANY_OR_ALL": { - "message": [ - "Value for `` must be 'any' or 'all', got ''." - ] - }, - "VALUE_NOT_BETWEEN": { - "message": [ - "Value for `` must be between and ." - ] - }, - "VALUE_NOT_NON_EMPTY_STR": { - "message": [ - "Value for `` must be a non-empty string, got ''." - ] - }, - "VALUE_NOT_PEARSON": { - "message": [ - "Value for `` only supports the 'pearson', got ''." - ] - }, - "VALUE_NOT_PLAIN_COLUMN_REFERENCE": { - "message": [ - "Value `` in `` should be a plain column reference such as `df.col` or `col('column')`." - ] - }, - "VALUE_NOT_POSITIVE": { - "message": [ - "Value for `` must be positive, got ''." - ] - }, - "VALUE_NOT_TRUE": { - "message": [ - "Value for `` must be True, got ''." - ] - }, - "VALUE_OUT_OF_BOUNDS": { - "message": [ - "Value for `` must be between and (inclusive), got " - ] - }, - "WRONG_NUM_ARGS_FOR_HIGHER_ORDER_FUNCTION": { - "message": [ - "Function `` should take between 1 and 3 arguments, but the provided function takes ." - ] - }, - "WRONG_NUM_COLUMNS": { - "message": [ - "Function `` should take at least columns." - ] - }, - "ZERO_INDEX": { - "message": [ - "Index must be non-zero." - ] - } -} -''' - +# Note: Though we call them "error classes" here, the proper name is "error conditions", +# hence why the name of the JSON file different. +# For more information, please see: https://issues.apache.org/jira/browse/SPARK-46810 +# This discrepancy will be resolved as part of: https://issues.apache.org/jira/browse/SPARK-47429 +ERROR_CLASSES_JSON = ( + importlib.resources + .files("pyspark.errors") + .joinpath("error-conditions.json") + .read_text() +) ERROR_CLASSES_MAP = json.loads(ERROR_CLASSES_JSON) diff --git a/python/pyspark/errors/exceptions/__init__.py b/python/pyspark/errors/exceptions/__init__.py index 4fd16c6a2e1ad..c66f35958f8dd 100644 --- a/python/pyspark/errors/exceptions/__init__.py +++ b/python/pyspark/errors/exceptions/__init__.py @@ -18,39 +18,15 @@ def _write_self() -> None: import json + from pathlib import Path from pyspark.errors import error_classes - with open("python/pyspark/errors/error_classes.py", "w") as f: - error_class_py_file = """# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# NOTE: Automatically sort this file via -# - cd $SPARK_HOME -# - bin/pyspark -# - from pyspark.errors.exceptions import _write_self; _write_self() -import json - - -ERROR_CLASSES_JSON = ''' -%s -''' + ERRORS_DIR = Path(__file__).parents[1] -ERROR_CLASSES_MAP = json.loads(ERROR_CLASSES_JSON) -""" % json.dumps( - error_classes.ERROR_CLASSES_MAP, sort_keys=True, indent=2 + with open(ERRORS_DIR / "error-conditions.json", "w") as f: + json.dump( + error_classes.ERROR_CLASSES_MAP, + f, + sort_keys=True, + indent=2, ) - f.write(error_class_py_file) diff --git a/python/pyspark/errors_doc_gen.py b/python/pyspark/errors_doc_gen.py index ad32745348127..e1bd94dcec4d0 100644 --- a/python/pyspark/errors_doc_gen.py +++ b/python/pyspark/errors_doc_gen.py @@ -41,7 +41,7 @@ def generate_errors_doc(output_rst_file_path: str) -> None: Error classes in PySpark ======================== -This is a list of common, named error classes returned by PySpark which are defined at `error_classes.py `_. +This is a list of common, named error classes returned by PySpark which are defined at `error-conditions.json `_. When writing PySpark errors, developers must use an error class from the list. If an appropriate error class is not available, add a new one into the list. For more information, please refer to `Contributing Error and Exception `_. """ # noqa