o
    i                     @   s  d dl 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    )cast   )ErrorClassesReaderc                	   @   s   e Zd ZdZ			ddedB dedB deeef dB ddfddZdedB fd	d
Zdeeef dB fddZdddZ	defddZ
dS )PySparkExceptionz:Base Exception for handling errors generated from PySpark.Nmessageerror_classmessage_parametersreturnc                 C   sx   |d ur|d u r|d u s|d u r|d ur|d usJ t  | _|d u r1| jtd|td|| _n|| _|| _|| _d S )Nstrzdict[str, str])r   error_readerget_error_messager   r   r   r   )selfr   r   r    r   d/home/ubuntu/.local/lib/python3.10/site-packages/duckdb/experimental/spark/errors/exceptions/base.py__init__	   s   	
zPySparkException.__init__c                 C      | j S )zReturns 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   )zReturns a message parameters as a dictionary.

        .. versionadded:: 3.4.0

        See Also:
        --------
        :meth:`PySparkException.getErrorClass`
        :meth:`PySparkException.getSqlState`
        )r   r   r   r   r   getMessageParameters.   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__H   s   zPySparkException.__str__)NNN)r	   N)__name__
__module____qualname____doc__r
   dictr   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   O       r   c                   @   r   )SessionNotSameExceptionz7Performed the same operation on different SparkSession.Nr    r   r   r   r   r"   S   r!   r"   c                   @   r   )TempTableAlreadyExistsExceptionz6Failed to create temp view since it is already exists.Nr    r   r   r   r   r#   W   r!   r#   c                   @   r   )ParseExceptionzFailed to parse a SQL command.Nr    r   r   r   r   r$   [   r!   r$   c                   @   r   )IllegalArgumentExceptionz,Passed an illegal or inappropriate argument.Nr    r   r   r   r   r%   _   r!   r%   c                   @   r   )ArithmeticExceptionz;Arithmetic exception thrown from Spark with an error class.Nr    r   r   r   r   r&   c   r!   r&   c                   @   r   )UnsupportedOperationExceptionzFUnsupported operation exception thrown from Spark with an error class.Nr    r   r   r   r   r'   g   r!   r'   c                   @   r   )ArrayIndexOutOfBoundsExceptionzJArray index out of bounds exception thrown from Spark with an error class.Nr    r   r   r   r   r(   k   r!   r(   c                   @   r   )DateTimeExceptionz9Datetime exception thrown from Spark with an error class.Nr    r   r   r   r   r)   o   r!   r)   c                   @   r   )NumberFormatExceptionz>Number format exception thrown from Spark with an error class.Nr    r   r   r   r   r*   s   r!   r*   c                   @   r   )StreamingQueryExceptionz1Exception that stopped a :class:`StreamingQuery`.Nr    r   r   r   r   r+   w   r!   r+   c                   @   r   )QueryExecutionExceptionzFailed to execute a query.Nr    r   r   r   r   r,   {   r!   r,   c                   @   r   )PythonExceptionz&Exceptions thrown from Python workers.Nr    r   r   r   r   r-      r!   r-   c                   @   r   )SparkRuntimeExceptionz8Runtime exception thrown from Spark with an error class.Nr    r   r   r   r   r.      r!   r.   c                   @   r   )SparkUpgradeExceptionz*Exception thrown because of Spark upgrade.Nr    r   r   r   r   r/      r!   r/   c                   @   r   )UnknownExceptionzNone of the above exceptions.Nr    r   r   r   r   r0      r!   r0   c                   @   r   )PySparkValueErrorz6Wrapper class for ValueError to support error classes.Nr    r   r   r   r   r1      r!   r1   c                   @   r   )PySparkIndexErrorz6Wrapper class for IndexError to support error classes.Nr    r   r   r   r   r2      r!   r2   c                   @   r   )PySparkTypeErrorz5Wrapper class for TypeError to support error classes.Nr    r   r   r   r   r3      r!   r3   c                   @   r   )PySparkAttributeErrorz:Wrapper class for AttributeError to support error classes.Nr    r   r   r   r   r4      r!   r4   c                   @   r   )PySparkRuntimeErrorz8Wrapper class for RuntimeError to support error classes.Nr    r   r   r   r   r5      r!   r5   c                   @   r   )PySparkAssertionErrorz:Wrapper class for AssertionError to support error classes.Nr    r   r   r   r   r6      r!   r6   c                   @   r   )PySparkNotImplementedErrorz?Wrapper class for NotImplementedError to support error classes.Nr    r   r   r   r   r7      r!   r7   N)$typingr   utilsr   	Exceptionr   r   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   
ValueErrorr1   
IndexErrorr2   	TypeErrorr3   AttributeErrorr4   RuntimeErrorr5   AssertionErrorr6   NotImplementedErrorr7   r   r   r   r   <module>   s4    I