o
    ?Di                     @   s  d dl mZmZmZ ddlmZ G dd deZG dd deZG dd	 d	eZ	G d
d deZ
G dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG d d! d!eZG d"d# d#eZG d$d% d%eZG d&d' d'eeZG d(d) d)eeZG d*d+ d+eeZG d,d- d-eeZG d.d/ d/ee Z!G d0d1 d1ee"Z#G d2d3 d3ee$Z%d4S )5    )DictOptionalcast   )ErrorClassesReaderc                
   @   s   e Zd ZdZ			ddee dee deeeef  fddZdee fd	d
Zdeeeef  fddZ	dddZ
defddZdS )PySparkExceptionzD
    Base Exception for handling errors generated from PySpark.
    Nmessageerror_classmessage_parametersc                 C   s   |d ur|d u r|d u s|d u r|d ur|d usJ t  | _|d u r5| jtt|ttttf || _n|| _|| _|| _d S )N)	r   error_readerget_error_messager   strr   r   r	   r
   )selfr   r	   r
    r   i/var/www/Datamplify/venv/lib/python3.10/site-packages/duckdb/experimental/spark/errors/exceptions/base.py__init__
   s   	
zPySparkException.__init__returnc                 C      | j S )z
        Returns an error class as a string.

        .. versionadded:: 3.4.0

        See Also
        --------
        :meth:`PySparkException.getMessageParameters`
        :meth:`PySparkException.getSqlState`
        )r	   r   r   r   r   getErrorClass#      zPySparkException.getErrorClassc                 C   r   )z
        Returns a message parameters as a dictionary.

        .. versionadded:: 3.4.0

        See Also
        --------
        :meth:`PySparkException.getErrorClass`
        :meth:`PySparkException.getSqlState`
        )r
   r   r   r   r   getMessageParameters0   r   z%PySparkException.getMessageParametersc                 C   s   dS )a,  
        Returns an SQLSTATE as a string.

        Errors generated in Python have no SQLSTATE, so it always returns None.

        .. versionadded:: 3.4.0

        See Also
        --------
        :meth:`PySparkException.getErrorClass`
        :meth:`PySparkException.getMessageParameters`
        Nr   r   r   r   r   getSqlState=   s   zPySparkException.getSqlStatec                 C   s(   |   d urd|    d| j S | jS )N[z] )r   r   r   r   r   r   __str__L   s   zPySparkException.__str__)NNN)r   N)__name__
__module____qualname____doc__r   r   r   r   r   r   r   r   r   r   r   r   r      s     

r   c                   @      e Zd ZdZdS )AnalysisExceptionz-
    Failed to analyze a SQL query plan.
    Nr   r   r   r   r   r   r   r   r    R       r    c                   @   r   )SessionNotSameExceptionzA
    Performed the same operation on different SparkSession.
    Nr!   r   r   r   r   r#   X   r"   r#   c                   @   r   )TempTableAlreadyExistsExceptionz@
    Failed to create temp view since it is already exists.
    Nr!   r   r   r   r   r$   ^   r"   r$   c                   @   r   )ParseExceptionz(
    Failed to parse a SQL command.
    Nr!   r   r   r   r   r%   d   r"   r%   c                   @   r   )IllegalArgumentExceptionz6
    Passed an illegal or inappropriate argument.
    Nr!   r   r   r   r   r&   j   r"   r&   c                   @   r   )ArithmeticExceptionzE
    Arithmetic exception thrown from Spark with an error class.
    Nr!   r   r   r   r   r'   p   r"   r'   c                   @   r   )UnsupportedOperationExceptionzP
    Unsupported operation exception thrown from Spark with an error class.
    Nr!   r   r   r   r   r(   v   r"   r(   c                   @   r   )ArrayIndexOutOfBoundsExceptionzT
    Array index out of bounds exception thrown from Spark with an error class.
    Nr!   r   r   r   r   r)   |   r"   r)   c                   @   r   )DateTimeExceptionzC
    Datetime exception thrown from Spark with an error class.
    Nr!   r   r   r   r   r*      r"   r*   c                   @   r   )NumberFormatExceptionzH
    Number format exception thrown from Spark with an error class.
    Nr!   r   r   r   r   r+      r"   r+   c                   @   r   )StreamingQueryExceptionz;
    Exception that stopped a :class:`StreamingQuery`.
    Nr!   r   r   r   r   r,      r"   r,   c                   @   r   )QueryExecutionExceptionz$
    Failed to execute a query.
    Nr!   r   r   r   r   r-      r"   r-   c                   @   r   )PythonExceptionz0
    Exceptions thrown from Python workers.
    Nr!   r   r   r   r   r.      r"   r.   c                   @   r   )SparkRuntimeExceptionzB
    Runtime exception thrown from Spark with an error class.
    Nr!   r   r   r   r   r/      r"   r/   c                   @   r   )SparkUpgradeExceptionz4
    Exception thrown because of Spark upgrade.
    Nr!   r   r   r   r   r0      r"   r0   c                   @   r   )UnknownExceptionz'
    None of the above exceptions.
    Nr!   r   r   r   r   r1      r"   r1   c                   @   r   )PySparkValueErrorz@
    Wrapper class for ValueError to support error classes.
    Nr!   r   r   r   r   r2      r"   r2   c                   @   r   )PySparkIndexErrorz@
    Wrapper class for IndexError to support error classes.
    Nr!   r   r   r   r   r3      r"   r3   c                   @   r   )PySparkTypeErrorz?
    Wrapper class for TypeError to support error classes.
    Nr!   r   r   r   r   r4      r"   r4   c                   @   r   )PySparkAttributeErrorzD
    Wrapper class for AttributeError to support error classes.
    Nr!   r   r   r   r   r5      r"   r5   c                   @   r   )PySparkRuntimeErrorzB
    Wrapper class for RuntimeError to support error classes.
    Nr!   r   r   r   r   r6      r"   r6   c                   @   r   )PySparkAssertionErrorzD
    Wrapper class for AssertionError to support error classes.
    Nr!   r   r   r   r   r7      r"   r7   c                   @   r   )PySparkNotImplementedErrorzI
    Wrapper class for NotImplementedError to support error classes.
    Nr!   r   r   r   r   r8      r"   r8   N)&typingr   r   r   utilsr   	Exceptionr   r    r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   
ValueErrorr2   
IndexErrorr3   	TypeErrorr4   AttributeErrorr5   RuntimeErrorr6   AssertionErrorr7   NotImplementedErrorr8   r   r   r   r   <module>   s4    M