'Test to validate that exceptions in user defined function are correctly surfaced by the driver to us.
test_user_function_failure First creates a table to use for testing. Then creates a function that will throw an
exception when invoked. It then invokes the function and expects a FunctionException. Finally it preforms
cleanup operations.
@since 2.6.0
@jira_ticket PYTHON-238
@expected_result Function failures when UDF throws exception
@test_category queries:basic'

def test_user_function_failure(self):

    self._perform_cql_statement('\n                                                CREATE    FUNCTION    test3rf.test_failure(d    double)\n                                                RETURNS    NULL    ON    NULL    INPUT\n                                                RETURNS    double\n                                                LANGUAGE    java    AS    \'throw    new    RuntimeException("failure");\';\n                                                ', consistency_level=ConsistencyLevel.ALL, expected_exception=None)
    self._perform_cql_statement('\n                                                CREATE    TABLE        test3rf.d    (k    int    PRIMARY    KEY    ,    d    double);\n                                                ', consistency_level=ConsistencyLevel.ALL, expected_exception=None)
    self._perform_cql_statement('\n                                                INSERT    INTO    test3rf.d    (k,d)    VALUES    (0,    5.12);\n                                                ', consistency_level=ConsistencyLevel.ALL, expected_exception=None)
    self._perform_cql_statement('\n                                                SELECT    test_failure(d)    FROM    test3rf.d    WHERE    k    =    0;\n                                                ', consistency_level=ConsistencyLevel.ALL, expected_exception=FunctionFailure)
    self._perform_cql_statement('\n                                                DROP    FUNCTION    test3rf.test_failure;\n                                                ', consistency_level=ConsistencyLevel.ALL, expected_exception=None)
    self._perform_cql_statement('\n                                                DROP    TABLE    test3rf.d;\n                                                ', consistency_level=ConsistencyLevel.ALL, expected_exception=None)
