phoenix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From JamesRTaylor <...@git.apache.org>
Subject [GitHub] phoenix pull request #229: PHOENIX-3572 Support FETCH NEXT|n ROWS query on c...
Date Wed, 05 Apr 2017 18:59:02 GMT
Github user JamesRTaylor commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/229#discussion_r110000317
  
    --- Diff: phoenix-core/src/it/java/org/apache/phoenix/end2end/CursorWithRowValueConstructorIT.java
---
    @@ -0,0 +1,687 @@
    +/*
    + * 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.
    + */
    +package org.apache.phoenix.end2end;
    +
    +import org.apache.commons.logging.Log;
    +import org.apache.commons.logging.LogFactory;
    +import org.apache.phoenix.util.*;
    +import org.junit.After;
    +import org.junit.Before;
    +import org.junit.BeforeClass;
    +import org.junit.Test;
    +
    +import java.math.BigDecimal;
    +import java.sql.*;
    +import java.util.Properties;
    +import java.util.Random;
    +
    +import static org.apache.phoenix.util.TestUtil.*;
    +import static org.junit.Assert.*;
    +
    +
    +public class CursorWithRowValueConstructorIT extends BaseClientManagedTimeIT {
    +    private static final String TABLE_NAME = "CursorRVCTestTable";
    +    protected static final Log LOG = LogFactory.getLog(CursorWithRowValueConstructorIT.class);
    +
    +    public void createAndInitializeTestTable() throws SQLException {
    +        Connection conn = DriverManager.getConnection(getUrl());
    +
    +        PreparedStatement stmt = conn.prepareStatement("CREATE TABLE IF NOT EXISTS "
+ TABLE_NAME +
    +                "(a_id INTEGER NOT NULL, " +
    +                "a_data INTEGER, " +
    +                "CONSTRAINT my_pk PRIMARY KEY (a_id))");
    +        stmt.execute();
    +        synchronized (conn){
    +            conn.commit();
    +        }
    +
    +        //Upsert test values into the test table
    +        Random rand = new Random();
    +        stmt = conn.prepareStatement("UPSERT INTO " + TABLE_NAME +
    +                "(a_id, a_data) VALUES (?,?)");
    +        int rowCount = 0;
    +        while(rowCount < 100){
    +            stmt.setInt(1, rowCount);
    +            stmt.setInt(2, rand.nextInt(501));
    +            stmt.execute();
    +            ++rowCount;
    +        }
    +        synchronized (conn){
    +            conn.commit();
    +        }
    +    }
    +
    +    public void deleteTestTable() throws SQLException {
    +        Connection conn = DriverManager.getConnection(getUrl());
    +        PreparedStatement stmt = conn.prepareStatement("DROP TABLE IF EXISTS " + TABLE_NAME);
    +        stmt.execute();
    +        synchronized (conn){
    +            conn.commit();
    +        }
    +    }
    +
    +    @Test
    +    public void testCursorsOnTestTablePK() throws SQLException {
    +        try{
    +            createAndInitializeTestTable();
    +            String querySQL = "SELECT a_id FROM " + TABLE_NAME;
    +
    +            //Test actual cursor implementation
    +            String cursorSQL = "DECLARE testCursor CURSOR FOR " + querySQL;
    +            DriverManager.getConnection(getUrl()).prepareStatement(cursorSQL).execute();
    +            cursorSQL = "OPEN testCursor";
    +            DriverManager.getConnection(getUrl()).prepareStatement(cursorSQL).execute();
    +            cursorSQL = "FETCH NEXT FROM testCursor";
    --- End diff --
    
    Is FETCH PRIOR tested at all? If not supported, should we remove it from the grammar for
now?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message