Search in sources :

Example 61 with ProcCallException

use of org.voltdb.client.ProcCallException in project voltdb by VoltDB.

the class TestCRUDSuite method testPartitionedPkWithoutPartitionCol2.

public void testPartitionedPkWithoutPartitionCol2() throws Exception {
    Client client = getClient();
    try {
        client.callProcedure("P3.delete", 0, "ABC");
    } catch (ProcCallException e) {
        assertTrue(e.getMessage().contains("was not found"));
        return;
    }
    fail();
}
Also used : Client(org.voltdb.client.Client) ProcCallException(org.voltdb.client.ProcCallException)

Example 62 with ProcCallException

use of org.voltdb.client.ProcCallException in project voltdb by VoltDB.

the class TestAdHocPlannerCache method subtest2AdHocParameters.

public void subtest2AdHocParameters(Client client) throws IOException, ProcCallException {
    System.out.println("subtest2AdHocParameters...");
    String sql;
    String errorMsg = AdHocNTBase.AdHocErrorResponseMessage;
    //
    // Multiple AdHoc queries with question marks per procedure call
    //
    sql = "SELECT ID FROM R1 sub2 WHERE num = 0 and ID > ? order by ID;";
    try {
        client.callProcedure("@AdHoc", sql + sql, 0, 0);
        fail();
    } catch (Exception ex) {
        assertTrue(ex.getMessage().contains(errorMsg));
    }
    checkPlannerCache(client, CACHE_SKIPPED, CACHE_SKIPPED);
    // fewer parameters
    try {
        client.callProcedure("@AdHoc", sql + sql, 0);
        fail();
    } catch (Exception ex) {
        assertTrue(ex.getMessage().contains(errorMsg));
    }
    checkPlannerCache(client, CACHE_SKIPPED, CACHE_SKIPPED);
    try {
        client.callProcedure("@AdHoc", "select * from r1 sub2;" + sql, 0, 0);
        fail();
    } catch (Exception ex) {
        assertTrue(ex.getMessage().contains(errorMsg));
    }
    checkPlannerCache(client, CACHE_SKIPPED, CACHE_SKIPPED);
    // by pass the pre-planner check
    verifyAdHocFails(client, String.format(pattern, 1, 0), sql + sql);
    checkPlannerCache(client, CACHE_SKIPPED);
    // positive tests
    // multiple statements are not partition inferred, sent to every partitions.
    // not cacheable currently.
    sql = "SELECT ID FROM R1 sub2 order by ID;";
    VoltTable[] vts = client.callProcedure("@AdHoc", sql + sql).getResults();
    validateTableOfScalarLongs(vts[0], new long[] { 1, 2, 3 });
    validateTableOfScalarLongs(vts[1], new long[] { 1, 2, 3 });
    checkPlannerCache(client, CACHE_SKIPPED, CACHE_SKIPPED);
    //
    // Pass in incorrect number of parameters
    //
    verifyAdHocFails(client, String.format(pattern, 0, 1), sql, 1);
    checkPlannerCache(client, CACHE_PARAMS_EXCEPTION);
    sql = "SELECT ID FROM R1 sub2 WHERE num = 0 and ID > ? order by ID;";
    verifyAdHocFails(client, String.format(pattern, 1, 2), sql, 1, 500);
    checkPlannerCache(client, CACHE_PARAMS_EXCEPTION);
    verifyAdHocFails(client, String.format(pattern, 1, 0), sql);
    checkPlannerCache(client, CACHE_PARAMS_EXCEPTION);
    VoltTable vt;
    // rename table with "TB" to run it as a new query to the system
    sql = "SELECT ID FROM R1 sub2_TB WHERE ID > ? order by ID;";
    vt = client.callProcedure("@AdHoc", sql, 1).getResults()[0];
    validateTableOfScalarLongs(vt, new long[] { 2, 3 });
    checkPlannerCache(client, CACHE_MISS2);
    verifyAdHocFails(client, String.format(pattern, 1, 2), sql, 1, 500);
    checkPlannerCache(client, CACHE_PARAMS_EXCEPTION);
    verifyAdHocFails(client, String.format(pattern, 1, 0), sql);
    checkPlannerCache(client, CACHE_PARAMS_EXCEPTION);
    // no parameters passed in for multiple adhoc queries
    verifyAdHocFails(client, String.format(pattern, 1, 0), sql + sql);
    checkPlannerCache(client, CACHE_SKIPPED);
}
Also used : VoltTable(org.voltdb.VoltTable) ProcCallException(org.voltdb.client.ProcCallException) NoConnectionsException(org.voltdb.client.NoConnectionsException) IOException(java.io.IOException)

Example 63 with ProcCallException

use of org.voltdb.client.ProcCallException in project voltdb by VoltDB.

the class TestFunctionsSuite method subtestOverlay.

public void subtestOverlay(Client client, String overlayProc, String overlayFullLengthProc) throws NoConnectionsException, IOException, ProcCallException {
    ClientResponse cr;
    VoltTable result;
    String overlayFailed = overlayProc + " got a wrong answer";
    String overlayFullLengthFailed = overlayFullLengthProc + " got a wrong answer";
    cr = client.callProcedure("@AdHoc", "TRUNCATE TABLE P1;");
    assertEquals(ClientResponse.SUCCESS, cr.getStatus());
    cr = client.callProcedure("P1.insert", 1, "Xin@VoltDB", 1, 1.0, new Timestamp(1000000000000L));
    assertEquals(ClientResponse.SUCCESS, cr.getStatus());
    result = client.callProcedure(overlayProc, "Jia", 4, 7, 1).getResults()[0];
    assertTrue(result.advanceRow());
    assertEquals(overlayFailed, "XinJia", result.getString(1));
    result = client.callProcedure(overlayProc, "Jia_", 4, 1, 1).getResults()[0];
    assertTrue(result.advanceRow());
    assertEquals(overlayFailed, "XinJia_VoltDB", result.getString(1));
    try {
        result = client.callProcedure(overlayProc, "Jia", 4.2, 7, 1).getResults()[0];
    } catch (Exception ex) {
        assertTrue(ex.getMessage().contains("The provided value: (4.2) of type: java.lang.Double " + "is not a match or is out of range for the target parameter type: long"));
    }
    // Test NULL results
    result = client.callProcedure(overlayProc, null, 4, 7, 1).getResults()[0];
    assertTrue(result.advanceRow());
    assertEquals(overlayFailed, null, result.getString(1));
    result = client.callProcedure(overlayProc, "Jia", 4, null, 1).getResults()[0];
    assertTrue(result.advanceRow());
    assertEquals(overlayFailed, null, result.getString(1));
    result = client.callProcedure(overlayProc, "Jia", null, 7, 1).getResults()[0];
    assertTrue(result.advanceRow());
    assertEquals(overlayFailed, null, result.getString(1));
    result = client.callProcedure(overlayFullLengthProc, "Jia", 4, 1).getResults()[0];
    assertTrue(result.advanceRow());
    assertEquals(overlayFullLengthFailed, "XinJialtDB", result.getString(1));
    result = client.callProcedure(overlayFullLengthProc, "J", 4, 1).getResults()[0];
    assertTrue(result.advanceRow());
    assertEquals(overlayFullLengthFailed, "XinJVoltDB", result.getString(1));
    // Test UTF-8 OVERLAY
    cr = client.callProcedure("P1.insert", 2, "贾鑫@VoltDB", 1, 1.0, new Timestamp(1000000000000L));
    assertEquals(ClientResponse.SUCCESS, cr.getStatus());
    result = client.callProcedure(overlayProc, "XinJia", 1, 2, 2).getResults()[0];
    assertTrue(result.advanceRow());
    assertEquals(overlayFailed, "XinJia@VoltDB", result.getString(1));
    result = client.callProcedure(overlayProc, "XinJia", 8, 2, 2).getResults()[0];
    assertTrue(result.advanceRow());
    assertEquals(overlayFailed, "贾鑫@VoltXinJia", result.getString(1));
    result = client.callProcedure(overlayProc, "XinJia", 1, 9, 2).getResults()[0];
    assertTrue(result.advanceRow());
    assertEquals(overlayFailed, "XinJia", result.getString(1));
    result = client.callProcedure(overlayProc, "XinJia", 2, 7, 2).getResults()[0];
    assertTrue(result.advanceRow());
    assertEquals(overlayFailed, "贾XinJiaB", result.getString(1));
    result = client.callProcedure(overlayProc, "XinJia", 2, 8, 2).getResults()[0];
    assertTrue(result.advanceRow());
    assertEquals(overlayFailed, "贾XinJia", result.getString(1));
    result = client.callProcedure(overlayFullLengthProc, "_", 3, 2).getResults()[0];
    assertTrue(result.advanceRow());
    assertEquals(overlayFullLengthFailed, "贾鑫_VoltDB", result.getString(1));
    result = client.callProcedure(overlayFullLengthProc, " at ", 2, 2).getResults()[0];
    assertTrue(result.advanceRow());
    assertEquals(overlayFullLengthFailed, "贾 at ltDB", result.getString(1));
    result = client.callProcedure(overlayProc, "XinJia", 9, 1, 2).getResults()[0];
    assertTrue(result.advanceRow());
    assertEquals(overlayFailed, "贾鑫@VoltDXinJia", result.getString(1));
    result = client.callProcedure(overlayProc, "石宁", 9, 1, 2).getResults()[0];
    assertTrue(result.advanceRow());
    assertEquals(overlayFailed, "贾鑫@VoltD石宁", result.getString(1));
    // Hsql has bugs on string(substring) index
    if (!isHSQL()) {
        result = client.callProcedure(overlayProc, "XinJia", 9, 2, 2).getResults()[0];
        assertTrue(result.advanceRow());
        assertEquals(overlayFailed, "贾鑫@VoltDXinJia", result.getString(1));
        result = client.callProcedure(overlayProc, "石宁", 9, 2, 2).getResults()[0];
        assertTrue(result.advanceRow());
        assertEquals(overlayFailed, "贾鑫@VoltD石宁", result.getString(1));
        result = client.callProcedure(overlayProc, "XinJia", 10, 2, 2).getResults()[0];
        assertTrue(result.advanceRow());
        assertEquals(overlayFailed, "贾鑫@VoltDBXinJia", result.getString(1));
        result = client.callProcedure(overlayProc, "石宁", 10, 2, 2).getResults()[0];
        assertTrue(result.advanceRow());
        assertEquals(overlayFailed, "贾鑫@VoltDB石宁", result.getString(1));
        // various start argument tests
        // start from 0, not 1, but treat it at least 1
        result = client.callProcedure(overlayProc, "XinJia", 100, 2, 2).getResults()[0];
        assertTrue(result.advanceRow());
        assertEquals(overlayFailed, "贾鑫@VoltDBXinJia", result.getString(1));
        // various length argument
        result = client.callProcedure(overlayProc, "XinJia", 2, 0, 2).getResults()[0];
        assertTrue(result.advanceRow());
        assertEquals(overlayFailed, "贾XinJia鑫@VoltDB", result.getString(1));
        result = client.callProcedure(overlayProc, "XinJia", 1, 10, 2).getResults()[0];
        assertTrue(result.advanceRow());
        assertEquals(overlayFailed, "XinJia", result.getString(1));
        result = client.callProcedure(overlayProc, "XinJia", 1, 100, 2).getResults()[0];
        assertTrue(result.advanceRow());
        assertEquals(overlayFailed, "XinJia", result.getString(1));
        result = client.callProcedure(overlayProc, "XinJia", 2, 100, 2).getResults()[0];
        assertTrue(result.advanceRow());
        assertEquals(overlayFailed, "贾XinJia", result.getString(1));
        // Negative tests
        try {
            result = client.callProcedure(overlayProc, "XinJia", -10, 2, 2).getResults()[0];
            fail();
        } catch (Exception ex) {
            assertTrue(ex.getMessage().contains("data exception -- OVERLAY error, not positive start argument -10"));
        }
        try {
            result = client.callProcedure(overlayProc, "XinJia", 0, 2, 2).getResults()[0];
            fail();
        } catch (Exception ex) {
            assertTrue(ex.getMessage().contains("data exception -- OVERLAY error, not positive start argument 0"));
        }
        try {
            result = client.callProcedure(overlayProc, "XinJia", 1, -1, 2).getResults()[0];
            fail();
        } catch (Exception ex) {
            assertTrue(ex.getMessage().contains("data exception -- OVERLAY error, negative length argument -1"));
        }
    }
}
Also used : ClientResponse(org.voltdb.client.ClientResponse) VoltTable(org.voltdb.VoltTable) Timestamp(java.sql.Timestamp) IOException(java.io.IOException) ProcCallException(org.voltdb.client.ProcCallException) NoConnectionsException(org.voltdb.client.NoConnectionsException)

Example 64 with ProcCallException

use of org.voltdb.client.ProcCallException in project voltdb by VoltDB.

the class TestFunctionsSuite method testSubstring.

public void testSubstring() throws Exception {
    System.out.println("STARTING testSubstring");
    Client client = getClient();
    initialLoad(client, "P1");
    ClientResponse cr = null;
    VoltTable r = null;
    // test where support
    cr = client.callProcedure("WHERE_SUBSTRING2");
    assertEquals(ClientResponse.SUCCESS, cr.getStatus());
    r = cr.getResults()[0];
    assertEquals(5, r.asScalarLong());
    // Test that commas work just like keyword separators
    cr = client.callProcedure("ALT_WHERE_SUBSTRING2");
    assertEquals(ClientResponse.SUCCESS, cr.getStatus());
    r = cr.getResults()[0];
    assertEquals(5, r.asScalarLong());
    cr = client.callProcedure("WHERE_SUBSTRING3");
    assertEquals(ClientResponse.SUCCESS, cr.getStatus());
    r = cr.getResults()[0];
    assertEquals(5, r.asScalarLong());
    // Test that commas work just like keyword separators
    cr = client.callProcedure("ALT_WHERE_SUBSTRING3");
    assertEquals(ClientResponse.SUCCESS, cr.getStatus());
    r = cr.getResults()[0];
    assertEquals(5, r.asScalarLong());
    // Test select support
    cr = client.callProcedure("DISPLAY_SUBSTRING");
    assertEquals(ClientResponse.SUCCESS, cr.getStatus());
    r = cr.getResults()[0];
    r.advanceRow();
    assertEquals("12" + paddedToNonInlineLength, r.getString(0));
    cr = client.callProcedure("DISPLAY_SUBSTRING2");
    assertEquals(ClientResponse.SUCCESS, cr.getStatus());
    r = cr.getResults()[0];
    r.advanceRow();
    assertEquals("12", r.getString(0));
    // Test ORDER BY by support
    cr = client.callProcedure("ORDER_SUBSTRING");
    assertEquals(ClientResponse.SUCCESS, cr.getStatus());
    r = cr.getResults()[0];
    r.advanceRow();
    long value = r.getLong(0);
    assertEquals(5, value);
    // Test GROUP BY by support
    cr = client.callProcedure("AGG_OF_SUBSTRING");
    assertEquals(ClientResponse.SUCCESS, cr.getStatus());
    r = cr.getResults()[0];
    r.advanceRow();
    assertEquals("10" + paddedToNonInlineLength, r.getString(0));
    cr = client.callProcedure("AGG_OF_SUBSTRING2");
    assertEquals(ClientResponse.SUCCESS, cr.getStatus());
    r = cr.getResults()[0];
    r.advanceRow();
    assertEquals("10", r.getString(0));
    // Test null propagation
    cr = client.callProcedure("INSERT_NULL", 99);
    assertEquals(ClientResponse.SUCCESS, cr.getStatus());
    cr = client.callProcedure("INSERT_NULL", 98);
    assertEquals(ClientResponse.SUCCESS, cr.getStatus());
    cr = client.callProcedure("INSERT_NULL", 97);
    assertEquals(ClientResponse.SUCCESS, cr.getStatus());
    cr = client.callProcedure("INSERT_NULL", 96);
    assertEquals(ClientResponse.SUCCESS, cr.getStatus());
    cr = client.callProcedure("INSERT_NULL", 95);
    assertEquals(ClientResponse.SUCCESS, cr.getStatus());
    long resultA;
    long resultB;
    cr = client.callProcedure("@AdHoc", "select count(*) from P1 where DESC >= 'X11'");
    assertEquals(ClientResponse.SUCCESS, cr.getStatus());
    r = cr.getResults()[0];
    resultA = r.asScalarLong();
    cr = client.callProcedure("@AdHoc", "select count(*) from P1 where SUBSTRING (DESC FROM 2) >= '11'");
    assertEquals(ClientResponse.SUCCESS, cr.getStatus());
    r = cr.getResults()[0];
    resultB = r.asScalarLong();
    assertEquals(resultA, resultB);
    cr = client.callProcedure("@AdHoc", "select count(*) from P1 where not DESC >= 'X12'");
    assertEquals(ClientResponse.SUCCESS, cr.getStatus());
    r = cr.getResults()[0];
    resultA = r.asScalarLong();
    cr = client.callProcedure("@AdHoc", "select count(*) from P1 where not SUBSTRING( DESC FROM 2) >= '12'");
    assertEquals(ClientResponse.SUCCESS, cr.getStatus());
    r = cr.getResults()[0];
    resultB = r.asScalarLong();
    assertEquals(resultA, resultB);
    cr = client.callProcedure("@AdHoc", "select count(*) from P1 where DESC >= 'X2'");
    assertEquals(ClientResponse.SUCCESS, cr.getStatus());
    r = cr.getResults()[0];
    resultA = r.asScalarLong();
    cr = client.callProcedure("@AdHoc", "select count(*) from P1 where SUBSTRING(DESC FROM 2 FOR 1) >= '2'");
    assertEquals(ClientResponse.SUCCESS, cr.getStatus());
    r = cr.getResults()[0];
    resultB = r.asScalarLong();
    assertEquals(resultA, resultB);
    cr = client.callProcedure("@AdHoc", "select count(*) from P1 where not SUBSTRING( SUBSTRING (DESC FROM 2) FROM 1 FOR 1) < '2'");
    assertEquals(ClientResponse.SUCCESS, cr.getStatus());
    r = cr.getResults()[0];
    resultB = r.asScalarLong();
    assertEquals(resultA, resultB);
    boolean caught = false;
    caught = false;
    try {
        cr = client.callProcedure("@AdHoc", "select count(*) from P1 where not SUBSTRING( DESC FROM 2) > 9");
        assertTrue(cr.getStatus() != ClientResponse.SUCCESS);
    } catch (ProcCallException e) {
        String msg = e.getMessage();
        assertTrue(msg.indexOf("incompatible data type") != -1);
        caught = true;
    }
    assertTrue(caught);
    caught = false;
    try {
        cr = client.callProcedure("@AdHoc", "select count(*) from P1 where not SUBSTRING (1 FROM 2) > 9");
        assertTrue(cr.getStatus() != ClientResponse.SUCCESS);
    } catch (ProcCallException e) {
        String msg = e.getMessage();
        assertTrue(msg.indexOf("incompatible data type") != -1);
        caught = true;
    }
    assertTrue(caught);
    caught = false;
    try {
        cr = client.callProcedure("@AdHoc", "select count(*) from P1 where not SUBSTRING (1 FROM DESC) > '9'");
        assertTrue(cr.getStatus() != ClientResponse.SUCCESS);
    } catch (ProcCallException e) {
        String msg = e.getMessage();
        assertTrue(msg.indexOf("incompatible data type") != -1);
        caught = true;
    }
    assertTrue(caught);
    caught = false;
    try {
        cr = client.callProcedure("@AdHoc", "select count(*) from P1 where not SUBSTRING (DESC FROM DESC) > 'ABC'");
        assertTrue(cr.getStatus() != ClientResponse.SUCCESS);
    } catch (ProcCallException e) {
        String msg = e.getMessage();
        assertTrue(msg.indexOf("incompatible data type") != -1);
        caught = true;
    }
    assertTrue(caught);
}
Also used : ClientResponse(org.voltdb.client.ClientResponse) Client(org.voltdb.client.Client) VoltTable(org.voltdb.VoltTable) ProcCallException(org.voltdb.client.ProcCallException)

Example 65 with ProcCallException

use of org.voltdb.client.ProcCallException in project voltdb by VoltDB.

the class TestFunctionsSuite method subtestNaturalLog.

public void subtestNaturalLog() throws Exception {
    final String[] fname = { "LOG", "LN" };
    final double[] resultValues = new double[nonnegnonzeros.length];
    final Set<Double> filters = new HashSet<>();
    for (int kk = 0; kk < resultValues.length; ++kk) {
        resultValues[kk] = Math.log(nonnegnonzeros[kk]);
        filters.add(resultValues[kk]);
    }
    final boolean monotonic = true;
    final boolean ascending = true;
    final String expectedFormat = "DOUBLE";
    for (String log : fname) {
        functionTest(log, nonnegnonzeros, resultValues, filters, monotonic, ascending, expectedFormat);
    }
    // Adhoc Queries
    Client client = getClient();
    client.callProcedure("@AdHoc", "INSERT INTO P1 VALUES (5, 'wEoiXIuJwSIKBujWv', -405636, 1.38145922788945552107e-01, NULL)");
    client.callProcedure("@AdHoc", "INSERT INTO P1 VALUES (2, 'wEoiXIuJwSIKBujWv', -29914, 8.98500019539639316335e-01, NULL)");
    client.callProcedure("@AdHoc", "INSERT INTO P1 VALUES (4, 'WCfDDvZBPoqhanfGN', -1309657, 9.34160160574919795629e-01, NULL)");
    // valid adhoc SQL query
    String sql = "select * from P1 where ID > LOG(1)";
    client.callProcedure("@AdHoc", sql);
    // execute Log() with invalid arguments
    try {
        sql = "select LOG(0) from P1";
        client.callProcedure("@AdHoc", sql);
        fail("Expected for Log(zero) result: invalid result value (-inf)");
    } catch (ProcCallException excp) {
        if (isHSQL()) {
            assertTrue(excp.getMessage().contains("invalid argument for natural logarithm"));
        } else {
            assertTrue(excp.getMessage().contains("Invalid result value (-inf)"));
        }
    }
    try {
        sql = "select LOG(-10) from P1";
        client.callProcedure("@AdHoc", sql);
        fail("Expected resultfor Log(negative #): invalid result value (nan)");
    } catch (ProcCallException excp) {
        if (isHSQL()) {
            assertTrue(excp.getMessage().contains("invalid argument for natural logarithm"));
        } else {
            assertTrue(excp.getMessage().contains("Invalid result value (nan)"));
        }
    }
}
Also used : Client(org.voltdb.client.Client) ProcCallException(org.voltdb.client.ProcCallException) HashSet(java.util.HashSet)

Aggregations

ProcCallException (org.voltdb.client.ProcCallException)240 Client (org.voltdb.client.Client)151 VoltTable (org.voltdb.VoltTable)120 ClientResponse (org.voltdb.client.ClientResponse)92 IOException (java.io.IOException)82 NoConnectionsException (org.voltdb.client.NoConnectionsException)55 Test (org.junit.Test)44 Configuration (org.voltdb.VoltDB.Configuration)41 VoltProjectBuilder (org.voltdb.compiler.VoltProjectBuilder)36 File (java.io.File)21 InMemoryJarfile (org.voltdb.utils.InMemoryJarfile)19 VoltCompiler (org.voltdb.compiler.VoltCompiler)15 VoltDB (org.voltdb.VoltDB)10 VoltTableRow (org.voltdb.VoltTableRow)10 Timestamp (java.sql.Timestamp)5 TimestampType (org.voltdb.types.TimestampType)5 BigDecimal (java.math.BigDecimal)4 Date (java.util.Date)4 HashSet (java.util.HashSet)3 ClientResponseImpl (org.voltdb.ClientResponseImpl)3