phoenix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (PHOENIX-3572) Support FETCH NEXT| n ROWS from Cursor
Date Mon, 24 Apr 2017 19:24:04 GMT

    [ https://issues.apache.org/jira/browse/PHOENIX-3572?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15981733#comment-15981733
] 

ASF GitHub Bot commented on PHOENIX-3572:
-----------------------------------------

Github user bijugs commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/229#discussion_r113034318
  
    --- 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 --
    
    Since this PR is for ``FETCH NEXT`` will remove the code related to ``FETCH PRIOR``. 


> Support FETCH NEXT| n ROWS from Cursor
> --------------------------------------
>
>                 Key: PHOENIX-3572
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-3572
>             Project: Phoenix
>          Issue Type: Sub-task
>            Reporter: Biju Nair
>            Assignee: Biju Nair
>
> Implement required changes to support 
> - {{DECLARE}} and {{OPEN}} a cursor
> - query {{FETCH NEXT | n ROWS}} from the cursor
> - {{CLOSE}} the cursor
> Based on the feedback in [PR #192|https://github.com/apache/phoenix/pull/192], implement
the changes using {{ResultSet}}.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message