phoenix git commit: PHOENIX-1696 Selecting column more than once fails (Maryann Xue, Samarth Jain)

2015-03-04 Thread jamestaylor
Repository: phoenix
Updated Branches:
  refs/heads/4.0 193622e53 -> 1c33da317


PHOENIX-1696 Selecting column more than once fails (Maryann Xue, Samarth Jain)


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/1c33da31
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/1c33da31
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/1c33da31

Branch: refs/heads/4.0
Commit: 1c33da31721d3d5a9b5c50e5e55a3404bfb4abdc
Parents: 193622e
Author: James Taylor 
Authored: Wed Mar 4 08:27:51 2015 -0800
Committer: James Taylor 
Committed: Wed Mar 4 08:34:07 2015 -0800

--
 .../java/org/apache/phoenix/end2end/QueryMoreIT.java  | 14 ++
 .../java/org/apache/phoenix/compile/RowProjector.java |  3 ---
 2 files changed, 14 insertions(+), 3 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/1c33da31/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java
index af5e6fa..e725376 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java
@@ -18,6 +18,8 @@
 package org.apache.phoenix.end2end;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
 import java.sql.Connection;
 import java.sql.Date;
@@ -33,6 +35,7 @@ import java.util.Properties;
 import org.apache.hadoop.hbase.util.Base64;
 import org.apache.hadoop.hbase.util.Pair;
 import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.TestUtil;
 import org.junit.Test;
 
 import com.google.common.collect.Lists;
@@ -314,4 +317,15 @@ public class QueryMoreIT extends BaseHBaseManagedTimeIT {
 sb.append(")");
 return sb.toString();
 }
+
+@Test // see - https://issues.apache.org/jira/browse/PHOENIX-1696
+public void testSelectColumnMoreThanOnce() throws Exception {
+Date date = new Date(System.currentTimeMillis());
+initEntityHistoryTableValues("abcd", getDefaultSplits("abcd"), date, 
100l);
+String query = "SELECT NEW_VALUE, NEW_VALUE FROM " + 
TestUtil.ENTITY_HISTORY_TABLE_NAME + " LIMIT 1";
+ResultSet rs = 
DriverManager.getConnection(getUrl()).createStatement().executeQuery(query);
+assertTrue(rs.next());
+rs.getObject("NEW_VALUE");
+assertFalse(rs.next());
+}
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/1c33da31/phoenix-core/src/main/java/org/apache/phoenix/compile/RowProjector.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/RowProjector.java 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/RowProjector.java
index 364ebd6..1b35e92 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/RowProjector.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/RowProjector.java
@@ -139,9 +139,6 @@ public class RowProjector {
 throw new ColumnNotFoundException(name);
 }
 }
-if (index.size() > 1) {
-throw new AmbiguousColumnException(name);
-}
 
 return index.get(0);
 }



phoenix git commit: PHOENIX-1696 Selecting column more than once fails (Maryann Xue, Samarth Jain)

2015-03-04 Thread jamestaylor
Repository: phoenix
Updated Branches:
  refs/heads/3.0 dd22ccd94 -> 1c0d30eab


PHOENIX-1696 Selecting column more than once fails (Maryann Xue, Samarth Jain)


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/1c0d30ea
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/1c0d30ea
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/1c0d30ea

Branch: refs/heads/3.0
Commit: 1c0d30eab028f762597a2ce17740ccf5ac545df9
Parents: dd22ccd
Author: James Taylor 
Authored: Wed Mar 4 08:27:51 2015 -0800
Committer: James Taylor 
Committed: Wed Mar 4 08:34:46 2015 -0800

--
 .../java/org/apache/phoenix/end2end/QueryMoreIT.java  | 14 ++
 .../java/org/apache/phoenix/compile/RowProjector.java |  5 +
 2 files changed, 15 insertions(+), 4 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/1c0d30ea/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java
index af5e6fa..e725376 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java
@@ -18,6 +18,8 @@
 package org.apache.phoenix.end2end;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
 import java.sql.Connection;
 import java.sql.Date;
@@ -33,6 +35,7 @@ import java.util.Properties;
 import org.apache.hadoop.hbase.util.Base64;
 import org.apache.hadoop.hbase.util.Pair;
 import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.TestUtil;
 import org.junit.Test;
 
 import com.google.common.collect.Lists;
@@ -314,4 +317,15 @@ public class QueryMoreIT extends BaseHBaseManagedTimeIT {
 sb.append(")");
 return sb.toString();
 }
+
+@Test // see - https://issues.apache.org/jira/browse/PHOENIX-1696
+public void testSelectColumnMoreThanOnce() throws Exception {
+Date date = new Date(System.currentTimeMillis());
+initEntityHistoryTableValues("abcd", getDefaultSplits("abcd"), date, 
100l);
+String query = "SELECT NEW_VALUE, NEW_VALUE FROM " + 
TestUtil.ENTITY_HISTORY_TABLE_NAME + " LIMIT 1";
+ResultSet rs = 
DriverManager.getConnection(getUrl()).createStatement().executeQuery(query);
+assertTrue(rs.next());
+rs.getObject("NEW_VALUE");
+assertFalse(rs.next());
+}
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/1c0d30ea/phoenix-core/src/main/java/org/apache/phoenix/compile/RowProjector.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/RowProjector.java 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/RowProjector.java
index 63051d0..58e18db 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/RowProjector.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/RowProjector.java
@@ -101,9 +101,6 @@ public class RowProjector {
 throw new ColumnNotFoundException(name);
 }
 }
-if (index.size() > 1) {
-throw new AmbiguousColumnException(name);
-}
 
 return index.get(0);
 }
@@ -133,4 +130,4 @@ public class RowProjector {
 public int getEstimatedRowByteSize() {
 return estimatedSize;
 }
-}
\ No newline at end of file
+}



phoenix git commit: PHOENIX-1696 Selecting column more than once fails (Maryann Xue, Samarth Jain)

2015-03-04 Thread jamestaylor
Repository: phoenix
Updated Branches:
  refs/heads/master 49f06b331 -> 9a546b9c8


PHOENIX-1696 Selecting column more than once fails (Maryann Xue, Samarth Jain)


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/9a546b9c
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/9a546b9c
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/9a546b9c

Branch: refs/heads/master
Commit: 9a546b9c89a3920345ea35ad503dfb360d4c34a5
Parents: 49f06b3
Author: James Taylor 
Authored: Wed Mar 4 08:27:51 2015 -0800
Committer: James Taylor 
Committed: Wed Mar 4 08:27:51 2015 -0800

--
 .../java/org/apache/phoenix/end2end/QueryMoreIT.java  | 14 ++
 .../java/org/apache/phoenix/compile/RowProjector.java |  3 ---
 2 files changed, 14 insertions(+), 3 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/9a546b9c/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java
index af5e6fa..e725376 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java
@@ -18,6 +18,8 @@
 package org.apache.phoenix.end2end;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
 import java.sql.Connection;
 import java.sql.Date;
@@ -33,6 +35,7 @@ import java.util.Properties;
 import org.apache.hadoop.hbase.util.Base64;
 import org.apache.hadoop.hbase.util.Pair;
 import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.TestUtil;
 import org.junit.Test;
 
 import com.google.common.collect.Lists;
@@ -314,4 +317,15 @@ public class QueryMoreIT extends BaseHBaseManagedTimeIT {
 sb.append(")");
 return sb.toString();
 }
+
+@Test // see - https://issues.apache.org/jira/browse/PHOENIX-1696
+public void testSelectColumnMoreThanOnce() throws Exception {
+Date date = new Date(System.currentTimeMillis());
+initEntityHistoryTableValues("abcd", getDefaultSplits("abcd"), date, 
100l);
+String query = "SELECT NEW_VALUE, NEW_VALUE FROM " + 
TestUtil.ENTITY_HISTORY_TABLE_NAME + " LIMIT 1";
+ResultSet rs = 
DriverManager.getConnection(getUrl()).createStatement().executeQuery(query);
+assertTrue(rs.next());
+rs.getObject("NEW_VALUE");
+assertFalse(rs.next());
+}
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/9a546b9c/phoenix-core/src/main/java/org/apache/phoenix/compile/RowProjector.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/RowProjector.java 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/RowProjector.java
index 364ebd6..1b35e92 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/RowProjector.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/RowProjector.java
@@ -139,9 +139,6 @@ public class RowProjector {
 throw new ColumnNotFoundException(name);
 }
 }
-if (index.size() > 1) {
-throw new AmbiguousColumnException(name);
-}
 
 return index.get(0);
 }



phoenix git commit: PHOENIX-1696 Selecting column more than once fails (Maryann Xue, Samarth Jain)

2015-03-04 Thread jamestaylor
Repository: phoenix
Updated Branches:
  refs/heads/4.3 90cd05e8f -> 97c4015a4


PHOENIX-1696 Selecting column more than once fails (Maryann Xue, Samarth Jain)


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/97c4015a
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/97c4015a
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/97c4015a

Branch: refs/heads/4.3
Commit: 97c4015a4aba172f50f4472436db739a62d66915
Parents: 90cd05e
Author: James Taylor 
Authored: Wed Mar 4 08:27:51 2015 -0800
Committer: James Taylor 
Committed: Wed Mar 4 08:34:28 2015 -0800

--
 .../java/org/apache/phoenix/end2end/QueryMoreIT.java  | 14 ++
 .../java/org/apache/phoenix/compile/RowProjector.java |  3 ---
 2 files changed, 14 insertions(+), 3 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/97c4015a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java
index af5e6fa..e725376 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java
@@ -18,6 +18,8 @@
 package org.apache.phoenix.end2end;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
 import java.sql.Connection;
 import java.sql.Date;
@@ -33,6 +35,7 @@ import java.util.Properties;
 import org.apache.hadoop.hbase.util.Base64;
 import org.apache.hadoop.hbase.util.Pair;
 import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.TestUtil;
 import org.junit.Test;
 
 import com.google.common.collect.Lists;
@@ -314,4 +317,15 @@ public class QueryMoreIT extends BaseHBaseManagedTimeIT {
 sb.append(")");
 return sb.toString();
 }
+
+@Test // see - https://issues.apache.org/jira/browse/PHOENIX-1696
+public void testSelectColumnMoreThanOnce() throws Exception {
+Date date = new Date(System.currentTimeMillis());
+initEntityHistoryTableValues("abcd", getDefaultSplits("abcd"), date, 
100l);
+String query = "SELECT NEW_VALUE, NEW_VALUE FROM " + 
TestUtil.ENTITY_HISTORY_TABLE_NAME + " LIMIT 1";
+ResultSet rs = 
DriverManager.getConnection(getUrl()).createStatement().executeQuery(query);
+assertTrue(rs.next());
+rs.getObject("NEW_VALUE");
+assertFalse(rs.next());
+}
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/97c4015a/phoenix-core/src/main/java/org/apache/phoenix/compile/RowProjector.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/RowProjector.java 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/RowProjector.java
index 364ebd6..1b35e92 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/RowProjector.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/RowProjector.java
@@ -139,9 +139,6 @@ public class RowProjector {
 throw new ColumnNotFoundException(name);
 }
 }
-if (index.size() > 1) {
-throw new AmbiguousColumnException(name);
-}
 
 return index.get(0);
 }



phoenix git commit: Revert "PHOENIX-1489 Access column values positionally from client"

2015-03-04 Thread maryannxue
Repository: phoenix
Updated Branches:
  refs/heads/calcite a2ee0efc9 -> 679571b19


Revert "PHOENIX-1489 Access column values positionally from client"

This reverts commit a2ee0efc9aa07940de6affacca67dd7b937504d2.


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/679571b1
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/679571b1
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/679571b1

Branch: refs/heads/calcite
Commit: 679571b19e171cd67fc024023538242fa8a21b2c
Parents: a2ee0ef
Author: maryannxue 
Authored: Wed Mar 4 12:29:15 2015 -0500
Committer: maryannxue 
Committed: Wed Mar 4 12:29:15 2015 -0500

--
 .../org/apache/phoenix/calcite/CalciteTest.java |   2 +-
 .../apache/phoenix/calcite/PhoenixProject.java  |   2 +-
 .../org/apache/phoenix/calcite/PhoenixRel.java  |   3 -
 .../calcite/PhoenixRelImplementorImpl.java  | 155 ++-
 .../apache/phoenix/compile/FromCompiler.java|   5 +-
 .../apache/phoenix/compile/JoinCompiler.java|   4 +-
 .../apache/phoenix/compile/OrderByCompiler.java |   3 +-
 .../TrackOrderPreservingExpressionCompiler.java |   2 +-
 .../apache/phoenix/compile/UpsertCompiler.java  |   2 +-
 .../apache/phoenix/compile/WhereCompiler.java   |   2 +-
 .../org/apache/phoenix/schema/ColumnRef.java|   2 +-
 .../org/apache/phoenix/schema/PTableImpl.java   |   8 -
 .../org/apache/phoenix/schema/PTableType.java   |   3 +-
 .../org/apache/phoenix/schema/TableRef.java |   2 +-
 14 files changed, 63 insertions(+), 132 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/679571b1/phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteTest.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteTest.java 
b/phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteTest.java
index a723303..9bce0a3 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteTest.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteTest.java
@@ -182,7 +182,7 @@ public class CalciteTest extends BaseClientManagedTimeIT {
 new PhoenixSchema(phoenixConnection));
 calciteConnection.setSchema("phoenix");
 final Statement statement = calciteConnection.createStatement();
-final ResultSet resultSet = statement.executeQuery("select 
organization_id, entity_id, a_string from aTable where a_string = 'a'");
+final ResultSet resultSet = statement.executeQuery("select * from 
aTable where a_string = 'a'");
 while (resultSet.next()) {
 System.out.println("org_id=" + resultSet.getObject(1) + 
",entity_id=" + resultSet.getObject(2) + ",a_string=" + 
resultSet.getObject("A_STRING"));
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/679571b1/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixProject.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixProject.java 
b/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixProject.java
index aa37471..2e90397 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixProject.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixProject.java
@@ -34,7 +34,7 @@ public class PhoenixProject extends Project implements 
PhoenixRel {
 
 @Override
 public void implement(Implementor implementor, PhoenixConnection conn) {
-   implementor.setProjects(getProjects());
 implementor.visitInput(0, (PhoenixRel) getInput());
+throw new UnsupportedOperationException();
 }
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/679571b1/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixRel.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixRel.java 
b/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixRel.java
index 9bd4d70..c255e90 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixRel.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixRel.java
@@ -1,7 +1,5 @@
 package org.apache.phoenix.calcite;
 
-import java.util.List;
-
 import org.apache.calcite.plan.Convention;
 import org.apache.calcite.rel.RelNode;
 import org.apache.calcite.rex.RexNode;
@@ -36,7 +34,6 @@ public interface PhoenixRel extends RelNode {
 void visitInput(int i, PhoenixRel input);
 ColumnExpression newColumnExpression(int index);
 void setContext(PhoenixConnection conn, PTable pTable, RexNode filter);
-void setProjects(List projects);
 QueryPlan makePlan();
   }
 }

http://git-wip-us.apache.org/repos/asf/phoenix/

Apache-Phoenix | Master | Build Successful

2015-03-04 Thread Apache Jenkins Server
Master branch build status Successful
Source repository https://git-wip-us.apache.org/repos/asf/phoenix.git

Last Successful Compiled Artifacts https://builds.apache.org/job/Phoenix-master/lastSuccessfulBuild/artifact/

Last Complete Test Report https://builds.apache.org/job/Phoenix-master/lastCompletedBuild/testReport/

Changes
[jtaylor] PHOENIX-1696 Selecting column more than once fails (Maryann Xue, Samarth Jain)



Build times for last couple of runsLatest build time is the right most | Legend blue: normal, red: test failure, gray: timeout


Apache-Phoenix | 4.0 | Build Successful

2015-03-04 Thread Apache Jenkins Server
4.0 branch build status Successful

Source repository https://git-wip-us.apache.org/repos/asf/incubator-phoenix.git

Compiled Artifacts https://builds.apache.org/job/Phoenix-4.0/lastSuccessfulBuild/artifact/

Test Report https://builds.apache.org/job/Phoenix-4.0/lastCompletedBuild/testReport/

Changes
[jtaylor] PHOENIX-1696 Selecting column more than once fails (Maryann Xue, Samarth Jain)



Build times for last couple of runsLatest build time is the right most | Legend blue: normal, red: test failure, gray: timeout


Apache-Phoenix | 3.0 | Hadoop1 | Build Successful

2015-03-04 Thread Apache Jenkins Server
3.0 branch build status Successful
Source repository https://git-wip-us.apache.org/repos/asf/phoenix.git

Last Successful Compiled Artifacts https://builds.apache.org/job/Phoenix-3.0-hadoop1/lastSuccessfulBuild/artifact/

Last Complete Test Report https://builds.apache.org/job/Phoenix-3.0-hadoop1/lastCompletedBuild/testReport/

Changes
[jtaylor] PHOENIX-1696 Selecting column more than once fails (Maryann Xue, Samarth Jain)



Build times for last couple of runsLatest build time is the right most | Legend blue: normal, red: test failure, gray: timeout


[35/50] [abbrv] phoenix git commit: PHOENIX-1669 Views are not always properly updated with physical table indexes when cached

2015-03-04 Thread maryannxue
PHOENIX-1669 Views are not always properly updated with physical table indexes 
when cached


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/c633151d
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/c633151d
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/c633151d

Branch: refs/heads/calcite
Commit: c633151dafcaf703c8daa5f92dbaddd7eeb89891
Parents: 2e5a630
Author: James Taylor 
Authored: Tue Feb 17 19:37:02 2015 -0800
Committer: James Taylor 
Committed: Tue Feb 17 19:37:02 2015 -0800

--
 .../end2end/index/IndexExpressionIT.java|  3 --
 .../apache/phoenix/schema/MetaDataClient.java   | 39 
 .../org/apache/phoenix/schema/PTableImpl.java   |  2 +-
 3 files changed, 24 insertions(+), 20 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/c633151d/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexExpressionIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexExpressionIT.java
 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexExpressionIT.java
index 5c51bda..1e3733b 100644
--- 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexExpressionIT.java
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexExpressionIT.java
@@ -1220,8 +1220,6 @@ public class IndexExpressionIT extends 
BaseHBaseManagedTimeIT {
 assertEquals(1, rs.getLong(1));
 assertFalse(rs.next());
 
-conn.createStatement().execute("CREATE INDEX vi1 on v(k2)");
-
 //i2 should be used since it contains s3||'_'||s4 i
 String query = "SELECT s2||'_'||s3 FROM v WHERE k2=1 AND 
(s2||'_'||s3)='abc_cab'";
 rs = conn.createStatement(  ).executeQuery("EXPLAIN " + query);
@@ -1235,7 +1233,6 @@ public class IndexExpressionIT extends 
BaseHBaseManagedTimeIT {
 assertFalse(rs.next());
 
 conn.createStatement().execute("ALTER VIEW v DROP COLUMN s4");
-conn.createStatement().execute("CREATE INDEX vi2 on v(k2)");
 //i2 cannot be used since s4 has been dropped from the view, so i1 
will be used 
 rs = conn.createStatement().executeQuery("EXPLAIN " + query);
 queryPlan = QueryUtil.getExplainPlan(rs);

http://git-wip-us.apache.org/repos/asf/phoenix/blob/c633151d/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java 
b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
index 64e62f5..831616b 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
@@ -360,8 +360,7 @@ public class MetaDataClient {
 // Otherwise, a tenant would be required to create a VIEW first
 // which is not really necessary unless you want to filter or 
add
 // columns
-addIndexesFromPhysicalTable(result);
-connection.addTable(result.getTable());
+addTableToCache(result);
 return result;
 } else {
 // if (result.getMutationCode() == 
MutationCode.NEWER_TABLE_FOUND) {
@@ -369,16 +368,20 @@ public class MetaDataClient {
 // Since we disallow creation or modification of a table 
earlier than the latest
 // timestamp, we can handle this such that we don't ask the
 // server again.
-// If table was not found at the current time stamp and we 
have one cached, remove it.
-// Otherwise, we're up to date, so there's nothing to do.
 if (table != null) {
+// Ensures that table in result is set to table found in 
our cache.
 result.setTable(table);
 if (code == MutationCode.TABLE_ALREADY_EXISTS) {
+// Although this table is up-to-date, the parent table 
may not be.
+// In this case, we update the parent table which may 
in turn pull
+// in indexes to add to this table.
 if (addIndexesFromPhysicalTable(result)) {
 connection.addTable(result.getTable());
 }
 return result;
 }
+// If table was not found at the current time stamp and we 
have one cached, remove it.
+// Otherwise, we're up to date, so there's nothing to do.
 if (code == M

[43/50] [abbrv] phoenix git commit: PHOENIX-1489 Access column values positionally from client

2015-03-04 Thread maryannxue
http://git-wip-us.apache.org/repos/asf/phoenix/blob/3f829751/phoenix-core/src/main/java/org/apache/phoenix/compile/ProjectionCompiler.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/ProjectionCompiler.java 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/ProjectionCompiler.java
index 27fe0f9..e84ca2a 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/ProjectionCompiler.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/ProjectionCompiler.java
@@ -62,6 +62,7 @@ import org.apache.phoenix.parse.TableName;
 import org.apache.phoenix.parse.TableWildcardParseNode;
 import org.apache.phoenix.parse.WildcardParseNode;
 import org.apache.phoenix.query.QueryConstants;
+import org.apache.phoenix.schema.AmbiguousColumnException;
 import org.apache.phoenix.schema.ArgumentTypeMismatchException;
 import org.apache.phoenix.schema.ColumnFamilyNotFoundException;
 import org.apache.phoenix.schema.ColumnNotFoundException;
@@ -144,12 +145,21 @@ public class ProjectionCompiler {
 }
 ColumnRef ref = new ColumnRef(tableRef,i);
 String colName = ref.getColumn().getName().getString();
+String tableAlias = tableRef.getTableAlias();
 if (resolveColumn) {
-if (tableRef.getTableAlias() != null) {
-ref = resolver.resolveColumn(null, 
tableRef.getTableAlias(), colName);
-} else {
-String schemaName = table.getSchemaName().getString();
-ref = resolver.resolveColumn(schemaName.length() == 0 ? 
null : schemaName, table.getTableName().getString(), colName);
+try {
+if (tableAlias != null) {
+ref = resolver.resolveColumn(null, tableAlias, 
colName);
+} else {
+String schemaName = table.getSchemaName().getString();
+ref = resolver.resolveColumn(schemaName.length() == 0 
? null : schemaName, table.getTableName().getString(), colName);
+}
+} catch (AmbiguousColumnException e) {
+if (column.getFamilyName() != null) {
+ref = resolver.resolveColumn(tableAlias != null ? 
tableAlias : table.getTableName().getString(), 
column.getFamilyName().getString(), colName);
+} else {
+throw e;
+}
 }
 }
 Expression expression = ref.newColumnExpression();
@@ -219,12 +229,21 @@ public class ProjectionCompiler {
 }
 }
 String colName = tableColumn.getName().getString();
+String tableAlias = tableRef.getTableAlias();
 if (resolveColumn) {
-if (tableRef.getTableAlias() != null) {
-ref = resolver.resolveColumn(null, 
tableRef.getTableAlias(), indexColName);
-} else {
-String schemaName = index.getSchemaName().getString();
-ref = resolver.resolveColumn(schemaName.length() == 0 ? 
null : schemaName, index.getTableName().getString(), indexColName);
+try {
+if (tableAlias != null) {
+ref = resolver.resolveColumn(null, tableAlias, 
indexColName);
+} else {
+String schemaName = index.getSchemaName().getString();
+ref = resolver.resolveColumn(schemaName.length() == 0 
? null : schemaName, index.getTableName().getString(), indexColName);
+}
+} catch (AmbiguousColumnException e) {
+if (indexColumn.getFamilyName() != null) {
+ref = resolver.resolveColumn(tableAlias != null ? 
tableAlias : index.getTableName().getString(), 
indexColumn.getFamilyName().getString(), indexColName);
+} else {
+throw e;
+}
 }
 }
 Expression expression = ref.newColumnExpression();
@@ -238,11 +257,14 @@ public class ProjectionCompiler {
 }
 }
 
-private static void projectTableColumnFamily(StatementContext context, 
String cfName, TableRef tableRef, List projectedExpressions, 
List projectedColumns) throws SQLException {
+private static void projectTableColumnFamily(StatementContext context, 
String cfName, TableRef tableRef, boolean resolveColumn, List 
projectedExpressions, List projectedColumns) throws 
SQLException {
 PTable table = tableRef.getTable();
 PColumnFamily pfamily = table.getColumnFamily(cfName);
 for (PColumn column : pfamily.getColumns()) {
 ColumnRef ref = new ColumnRef(tableRef, column.getPosition());
+if (resolveColumn) {
+ref = 
context.getResolve

[22/50] [abbrv] phoenix git commit: PHOENIX-1646 Views and functional index expressions may lose information when stringified

2015-03-04 Thread maryannxue
PHOENIX-1646 Views and functional index expressions may lose information when 
stringified


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/abeaa74a
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/abeaa74a
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/abeaa74a

Branch: refs/heads/calcite
Commit: abeaa74ad35e145fcae40f239437e1b5964bcd72
Parents: 2d5913b
Author: James Taylor 
Authored: Mon Feb 9 16:36:34 2015 -0800
Committer: James Taylor 
Committed: Mon Feb 9 18:37:14 2015 -0800

--
 .../java/org/apache/phoenix/end2end/ViewIT.java |  27 ++
 .../phoenix/compile/CreateTableCompiler.java|   4 +-
 .../phoenix/compile/ExpressionCompiler.java |  22 +-
 .../expression/ComparisonExpression.java|  12 +-
 .../phoenix/jdbc/PhoenixDatabaseMetaData.java   |  37 +--
 .../org/apache/phoenix/parse/AddParseNode.java  |   6 +
 .../AggregateFunctionWithinGroupParseNode.java  |  52 +++
 .../org/apache/phoenix/parse/AliasedNode.java   |  35 ++
 .../org/apache/phoenix/parse/AndParseNode.java  |  14 +
 .../phoenix/parse/ArithmeticParseNode.java  |  15 +
 .../parse/ArrayAllAnyComparisonNode.java|  49 +++
 .../phoenix/parse/ArrayAllComparisonNode.java   |   3 +-
 .../phoenix/parse/ArrayAnyComparisonNode.java   |   3 +-
 .../phoenix/parse/ArrayConstructorNode.java |  17 +
 .../apache/phoenix/parse/ArrayElemRefNode.java  |  11 +
 .../apache/phoenix/parse/BetweenParseNode.java  |  18 +-
 .../org/apache/phoenix/parse/BindParseNode.java |  12 +-
 .../org/apache/phoenix/parse/BindTableNode.java |   8 +
 .../org/apache/phoenix/parse/CaseParseNode.java |  20 ++
 .../org/apache/phoenix/parse/CastParseNode.java |  58 ++--
 .../org/apache/phoenix/parse/ColumnDef.java |  26 +-
 .../apache/phoenix/parse/ColumnParseNode.java   |  47 ++-
 .../phoenix/parse/ComparisonParseNode.java  |  10 +
 .../apache/phoenix/parse/CompoundParseNode.java |   5 -
 .../apache/phoenix/parse/ConcreteTableNode.java |  19 ++
 .../apache/phoenix/parse/DerivedTableNode.java  |  27 ++
 .../phoenix/parse/DistinctCountParseNode.java   |  16 +
 .../apache/phoenix/parse/DivideParseNode.java   |   7 +
 .../apache/phoenix/parse/ExistsParseNode.java   |   9 +
 .../phoenix/parse/FamilyWildcardParseNode.java  |   8 +
 .../apache/phoenix/parse/FunctionParseNode.java |  36 ++-
 .../java/org/apache/phoenix/parse/HintNode.java |  36 +++
 .../apache/phoenix/parse/InListParseNode.java   |  19 ++
 .../org/apache/phoenix/parse/InParseNode.java   |  11 +
 .../apache/phoenix/parse/IsNullParseNode.java   |  10 +
 .../org/apache/phoenix/parse/JoinTableNode.java |  51 +++
 .../org/apache/phoenix/parse/LikeParseNode.java |  12 +
 .../org/apache/phoenix/parse/LimitNode.java |  29 ++
 .../apache/phoenix/parse/LiteralParseNode.java  |  28 +-
 .../apache/phoenix/parse/ModulusParseNode.java  |   6 +
 .../apache/phoenix/parse/MultiplyParseNode.java |   6 +
 .../org/apache/phoenix/parse/NamedNode.java |   6 +-
 .../apache/phoenix/parse/NamedParseNode.java|  17 +-
 .../apache/phoenix/parse/NamedTableNode.java|  38 +++
 .../org/apache/phoenix/parse/NotParseNode.java  |   9 +
 .../org/apache/phoenix/parse/OrParseNode.java   |  15 +
 .../org/apache/phoenix/parse/OrderByNode.java   |  34 +-
 .../phoenix/parse/OuterJoinParseNode.java   |  47 ---
 .../org/apache/phoenix/parse/ParseNode.java |  11 +
 .../apache/phoenix/parse/ParseNodeFactory.java  |  34 +-
 .../parse/RowValueConstructorParseNode.java |  16 +
 .../apache/phoenix/parse/SelectStatement.java   |  99 ++
 .../phoenix/parse/SequenceValueParseNode.java   |  10 +
 .../phoenix/parse/StringConcatParseNode.java|  14 +
 .../apache/phoenix/parse/SubqueryParseNode.java |   8 +
 .../apache/phoenix/parse/SubtractParseNode.java |   7 +
 .../org/apache/phoenix/parse/TableName.java |   4 +-
 .../org/apache/phoenix/parse/TableNode.java |  10 +
 .../phoenix/parse/TableWildcardParseNode.java   |   7 +
 .../apache/phoenix/parse/WildcardParseNode.java |  16 +-
 .../apache/phoenix/schema/MetaDataClient.java   |  10 +-
 .../org/apache/phoenix/schema/types/PDate.java  |   5 +-
 .../apache/phoenix/schema/types/PVarchar.java   |   3 +-
 .../java/org/apache/phoenix/util/IndexUtil.java |   7 +-
 .../java/org/apache/phoenix/util/QueryUtil.java |  19 +-
 .../org/apache/phoenix/util/StringUtil.java |   5 +
 .../phoenix/compile/WhereCompilerTest.java  |  84 ++---
 .../phoenix/compile/WhereOptimizerTest.java |   3 +-
 .../apache/phoenix/parse/QueryParserTest.java   | 318 +++
 .../query/BaseConnectionlessQueryTest.java  |  23 ++
 .../phoenix/schema/types/PDataTypeTest.java |   7 +
 71 files changed, 1357 insertions(+), 370 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/abeaa74a/phoenix-core/src/it/java/org/apa

[38/50] [abbrv] phoenix git commit: PHOENIX-1078 Unable to run pig script with Phoenix in a secure HBase cluster

2015-03-04 Thread maryannxue
PHOENIX-1078 Unable to run pig script with Phoenix in a secure HBase cluster


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/dab9d51b
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/dab9d51b
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/dab9d51b

Branch: refs/heads/calcite
Commit: dab9d51bf5805e4f123e6095444d690f79250253
Parents: 05723b1
Author: Jeffrey Zhong 
Authored: Thu Feb 12 19:22:17 2015 -0800
Committer: Jeffrey Zhong 
Committed: Wed Feb 25 14:44:01 2015 -0800

--
 .../phoenix/mapreduce/util/ConnectionUtil.java |  9 +
 .../mapreduce/util/PhoenixConfigurationUtil.java   | 17 +
 .../org/apache/phoenix/pig/PhoenixHBaseLoader.java |  9 ++---
 .../apache/phoenix/pig/PhoenixHBaseStorage.java|  2 ++
 4 files changed, 34 insertions(+), 3 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/dab9d51b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/util/ConnectionUtil.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/util/ConnectionUtil.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/util/ConnectionUtil.java
index 0864cba..364baf7 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/util/ConnectionUtil.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/util/ConnectionUtil.java
@@ -20,6 +20,8 @@ package org.apache.phoenix.mapreduce.util;
 import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.SQLException;
+import java.util.Iterator;
+import java.util.Map;
 import java.util.Properties;
 
 import org.apache.hadoop.conf.Configuration;
@@ -42,6 +44,13 @@ public class ConnectionUtil {
 public static Connection getConnection(final Configuration configuration) 
throws SQLException {
 Preconditions.checkNotNull(configuration);
 final Properties props = new Properties();
+Iterator> iterator = 
configuration.iterator();
+if(iterator != null) {
+while (iterator.hasNext()) {
+Map.Entry entry = iterator.next();
+props.setProperty(entry.getKey(), entry.getValue());
+}
+}
 final Connection conn = 
DriverManager.getConnection(QueryUtil.getUrl(configuration.get(HConstants.ZOOKEEPER_QUORUM)),
 props);
 return conn;
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/dab9d51b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/util/PhoenixConfigurationUtil.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/util/PhoenixConfigurationUtil.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/util/PhoenixConfigurationUtil.java
index 83a606b..4d025ee 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/util/PhoenixConfigurationUtil.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/util/PhoenixConfigurationUtil.java
@@ -19,13 +19,18 @@ package org.apache.phoenix.mapreduce.util;
 
 import static org.apache.commons.lang.StringUtils.isNotEmpty;
 
+import java.io.IOException;
 import java.sql.Connection;
 import java.sql.SQLException;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.mapreduce.TableMapReduceUtil;
+import org.apache.hadoop.mapreduce.Job;
 import org.apache.hadoop.mapreduce.lib.db.DBInputFormat.NullDBWritable;
 import org.apache.hadoop.mapreduce.lib.db.DBWritable;
 import org.apache.phoenix.jdbc.PhoenixConnection;
@@ -296,4 +301,16 @@ public final class PhoenixConfigurationUtil {
 Preconditions.checkNotNull(configuration);
 return configuration.get(OUTPUT_TABLE_NAME);
 }
+
+public static void loadHBaseConfiguration(Job job) throws IOException {
+// load hbase-site.xml
+Configuration hbaseConf = HBaseConfiguration.create();
+for (Map.Entry entry : hbaseConf) {
+if (job.getConfiguration().get(entry.getKey()) == null) {
+job.getConfiguration().set(entry.getKey(), entry.getValue());
+}
+}
+//In order to have phoenix working on a secured cluster
+TableMapReduceUtil.initCredentials(job);
+}
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/dab9d51b/phoenix-pig/src/main/java/org/apache/phoenix/pig/PhoenixHBaseLoader.java
--
diff --git 
a/phoenix-pig/src/main/java/org/apache/phoenix/pig/PhoenixHBaseLoader.java 
b/

[19/50] [abbrv] phoenix git commit: PHOENIX-1641 Addendum to the previous commit

2015-03-04 Thread maryannxue
PHOENIX-1641 Addendum to the previous commit


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/78d91d11
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/78d91d11
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/78d91d11

Branch: refs/heads/calcite
Commit: 78d91d11e52acf54486c94ad8a0ec7dda2c9eb21
Parents: 2b8e663
Author: Samarth 
Authored: Sat Feb 7 10:42:44 2015 -0800
Committer: Samarth 
Committed: Sat Feb 7 10:42:44 2015 -0800

--
 .../phoenix/coprocessor/MetaDataProtocol.java   | 10 ++--
 .../query/ConnectionQueryServicesImpl.java  | 49 +++-
 .../org/apache/phoenix/util/UpgradeUtil.java| 12 +++--
 3 files changed, 42 insertions(+), 29 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/78d91d11/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataProtocol.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataProtocol.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataProtocol.java
index 357ebdd..be5fb4d 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataProtocol.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataProtocol.java
@@ -60,13 +60,17 @@ public abstract class MetaDataProtocol extends 
MetaDataService {
 
 public static final long MIN_TABLE_TIMESTAMP = 0;
 
-// Incremented from 3 to 4 to salt the sequence table in 3.2/4.2
-// Incremented from 5 to 6 with the addition of the STORE_NULLS table 
option
+// Incremented from 5 to 6 with the addition of the STORE_NULLS table 
option in 4.3
 public static final long MIN_SYSTEM_TABLE_TIMESTAMP = MIN_TABLE_TIMESTAMP 
+ 6;
 public static final int DEFAULT_MAX_META_DATA_VERSIONS = 1000;
 public static final int DEFAULT_MAX_STAT_DATA_VERSIONS = 3;
 public static final boolean DEFAULT_META_DATA_KEEP_DELETED_CELLS = true;
-
+
+// Min system table timestamps for every release.
+public static final long MIN_SYSTEM_TABLE_TIMESTAMP_4_1_0 = 
MIN_TABLE_TIMESTAMP + 3;
+public static final long MIN_SYSTEM_TABLE_TIMESTAMP_4_2_0 = 
MIN_TABLE_TIMESTAMP + 4;
+public static final long MIN_SYSTEM_TABLE_TIMESTAMP_4_2_1 = 
MIN_TABLE_TIMESTAMP + 5;
+
 // TODO: pare this down to minimum, as we don't need duplicates for both 
table and column errors, nor should we need
 // a different code for every type of error.
 // ENTITY_ALREADY_EXISTS, ENTITY_NOT_FOUND, NEWER_ENTITY_FOUND, 
ENTITY_NOT_IN_REGION, CONCURRENT_MODIFICATION

http://git-wip-us.apache.org/repos/asf/phoenix/blob/78d91d11/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
index 4a9eac0..2b508b5 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
@@ -1847,20 +1847,20 @@ public class ConnectionQueryServicesImpl extends 
DelegateQueryServices implement
 // This will occur if we have an older 
SYSTEM.CATALOG and we need to update it to include
 // any new columns we've added.
 long currentServerSideTableTimeStamp = 
e.getTable().getTimeStamp();
-
+
 // We know that we always need to add the 
STORE_NULLS column for 4.3 release
 String columnsToAdd = 
PhoenixDatabaseMetaData.STORE_NULLS + " " + PBoolean.INSTANCE.getSqlTypeName();
-
-// If the server side schema is 4 versions 
behind then we need to add INDEX_TYPE
-// and INDEX_DISABLE_TIMESTAMP columns too.
+
+// If the server side schema is at before 
MIN_SYSTEM_TABLE_TIMESTAMP_4_1_0 then 
+// we need to add INDEX_TYPE and 
INDEX_DISABLE_TIMESTAMP columns too.
 // TODO: Once 
https://issues.apache.org/jira/browse/PHOENIX-1614 is fixed,
 // we should just have a ALTER TABLE ADD IF 
NOT EXISTS statement with all
 // the column names that have been added to 
SYSTEM.CATALOG since 4.0.
-if (currentServerSideTableTimeStamp < 
MetaDataProtocol.MIN_SYSTEM_TABLE_

[26/50] [abbrv] phoenix git commit: PHOENIX-1646 Views and functional index expressions may lose information when stringified

2015-03-04 Thread maryannxue
PHOENIX-1646 Views and functional index expressions may lose information when 
stringified


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/acb87990
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/acb87990
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/acb87990

Branch: refs/heads/calcite
Commit: acb87990d81bfc60bba0f511957c18e1a12b4da3
Parents: 2730e87
Author: James Taylor 
Authored: Tue Feb 10 01:58:29 2015 -0800
Committer: James Taylor 
Committed: Tue Feb 10 01:58:29 2015 -0800

--
 .../apache/phoenix/end2end/index/GlobalIndexOptimizationIT.java  | 4 ++--
 .../it/java/org/apache/phoenix/end2end/index/LocalIndexIT.java   | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/acb87990/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/GlobalIndexOptimizationIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/GlobalIndexOptimizationIT.java
 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/GlobalIndexOptimizationIT.java
index 932c68b..e4ba2c6 100644
--- 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/GlobalIndexOptimizationIT.java
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/GlobalIndexOptimizationIT.java
@@ -322,8 +322,8 @@ public class GlobalIndexOptimizationIT extends 
BaseHBaseManagedTimeIT {
 "SERVER FILTER BY V1 = 'a'\n" +
 "SKIP-SCAN-JOIN TABLE 0\n" +
 "CLIENT PARALLEL 1-WAY SKIP SCAN ON 2 KEYS OVER 
_IDX_T \\[-32768,1\\] - \\[-32768,2\\]\n" +
-"SERVER FILTER BY FIRST KEY ONLY AND \"K2\" IN 
(3,4)\n" +
-"DYNAMIC SERVER FILTER BY (\"T_ID\", \"K1\", \"K2\") 
IN \\(\\(\\$\\d+.\\$\\d+, \\$\\d+.\\$\\d+, \\$\\d+.\\$\\d+\\)\\)";
+"SERVER FILTER BY FIRST KEY ONLY AND \"K2\" IN 
\\(3,4\\)\n" +
+"DYNAMIC SERVER FILTER BY \\(\"T_ID\", \"K1\", 
\"K2\"\\) IN \\(\\(\\$\\d+.\\$\\d+, \\$\\d+.\\$\\d+, \\$\\d+.\\$\\d+\\)\\)";
 assertTrue("Expected:\n" + expected + "\ndid not match\n" + 
actual, Pattern.matches(expected,actual));
 
 rs = conn1.createStatement().executeQuery(query);

http://git-wip-us.apache.org/repos/asf/phoenix/blob/acb87990/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/LocalIndexIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/LocalIndexIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/LocalIndexIT.java
index 9e66bbf..4080730 100644
--- 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/LocalIndexIT.java
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/LocalIndexIT.java
@@ -471,7 +471,7 @@ public class LocalIndexIT extends BaseHBaseManagedTimeIT {
 "CLIENT PARALLEL " + numRegions + "-WAY RANGE SCAN OVER "
 + 
MetaDataUtil.getLocalIndexTableName(TestUtil.DEFAULT_DATA_TABLE_NAME)+" 
[-32768,*] - [-32768,'z']\n"
 + "SERVER FILTER BY FIRST KEY ONLY\n"
-+ "SERVER AGGREGATE INTO DISTINCT ROWS BY [\"V1\", 
\"T_ID\", \"K3\"]\n" + "CLIENT MERGE SORT",
++ "SERVER AGGREGATE INTO DISTINCT ROWS BY [\"V1\", 
\"T_ID\", K3]\n" + "CLIENT MERGE SORT",
 QueryUtil.getExplainPlan(rs));
 
 rs = conn1.createStatement().executeQuery(query);



[21/50] [abbrv] phoenix git commit: PHOENIX-1646 Views and functional index expressions may lose information when stringified

2015-03-04 Thread maryannxue
http://git-wip-us.apache.org/repos/asf/phoenix/blob/abeaa74a/phoenix-core/src/main/java/org/apache/phoenix/parse/OuterJoinParseNode.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/parse/OuterJoinParseNode.java 
b/phoenix-core/src/main/java/org/apache/phoenix/parse/OuterJoinParseNode.java
deleted file mode 100644
index 97f636b..000
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/parse/OuterJoinParseNode.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.parse;
-
-import java.sql.SQLException;
-import java.util.Collections;
-import java.util.List;
-
-
-
-/**
- * 
- * Node representing an outer join qualifier (+) in SQL
- * TODO: remove Oracle specific syntax
- *
- * 
- * @since 0.1
- */
-public class OuterJoinParseNode extends UnaryParseNode{
-OuterJoinParseNode(ParseNode node) {
-super(node);
-}
-
-@Override
-public  T accept(ParseNodeVisitor visitor) throws SQLException {
-List l = Collections.emptyList();
-if (visitor.visitEnter(this)) {
-l = acceptChildren(visitor);
-}
-return visitor.visitLeave(this, l);
-}
-}

http://git-wip-us.apache.org/repos/asf/phoenix/blob/abeaa74a/phoenix-core/src/main/java/org/apache/phoenix/parse/ParseNode.java
--
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/ParseNode.java 
b/phoenix-core/src/main/java/org/apache/phoenix/parse/ParseNode.java
index 2ee8a83..b32674e 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/parse/ParseNode.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/ParseNode.java
@@ -20,6 +20,8 @@ package org.apache.phoenix.parse;
 import java.sql.SQLException;
 import java.util.List;
 
+import org.apache.phoenix.compile.ColumnResolver;
+
 
 
 
@@ -47,4 +49,13 @@ public abstract class ParseNode {
 public String getAlias() {
 return null;
 }
+
+@Override
+public final String toString() {
+StringBuilder buf = new StringBuilder();
+toSQL(null, buf);
+return buf.toString();
+}
+
+public abstract void toSQL(ColumnResolver resolver, StringBuilder buf);
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/abeaa74a/phoenix-core/src/main/java/org/apache/phoenix/parse/ParseNodeFactory.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/parse/ParseNodeFactory.java 
b/phoenix-core/src/main/java/org/apache/phoenix/parse/ParseNodeFactory.java
index c92dbb6..ddfaa03 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/parse/ParseNodeFactory.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/ParseNodeFactory.java
@@ -19,7 +19,6 @@ package org.apache.phoenix.parse;
 
 import java.lang.reflect.Constructor;
 import java.sql.SQLException;
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
@@ -52,6 +51,7 @@ import org.apache.phoenix.schema.types.PTimestamp;
 import org.apache.phoenix.util.SchemaUtil;
 
 import com.google.common.collect.ListMultimap;
+import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 
 /**
@@ -391,12 +391,22 @@ public class ParseNodeFactory {
 public FunctionParseNode function(String name, List valueNodes,
 List columnNodes, boolean isAscending) {
 
-List children = new ArrayList();
-children.addAll(columnNodes);
-children.add(new LiteralParseNode(Boolean.valueOf(isAscending)));
-children.addAll(valueNodes);
+List args = 
Lists.newArrayListWithExpectedSize(columnNodes.size() + valueNodes.size() + 1);
+args.addAll(columnNodes);
+args.add(new LiteralParseNode(Boolean.valueOf(isAscending)));
+args.addAll(valueNodes);
 
-return function(name, children);
+BuiltInFunctionInfo info = getInfo(name, args);
+Constructor ctor = info.getNodeCtor();
+if (ctor == null) {
+return new AggregateFunctionWithinGroupParseNod

[06/50] [abbrv] phoenix git commit: PHOENIX-1613 Allow old commons-collections version

2015-03-04 Thread maryannxue
PHOENIX-1613 Allow old commons-collections version

Handle an IllegalAccessError while initializing tracing, in order
to allow Phoenix to be used (without tracing) together with
SquirrelSQL. The IllegalAccessError occurs because SquirrelSQL
uses an old (2.x) version of commons-collections, while tracing
depends on a 3.x version.


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/3f48938d
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/3f48938d
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/3f48938d

Branch: refs/heads/calcite
Commit: 3f48938d5d5a67d59129eb90295894cc76e58508
Parents: 03a5d7e
Author: Gabriel Reid 
Authored: Sun Feb 1 07:10:24 2015 +0100
Committer: Gabriel Reid 
Committed: Sun Feb 1 07:55:12 2015 +0100

--
 .../src/main/java/org/apache/phoenix/trace/util/Tracing.java   | 6 ++
 1 file changed, 6 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/3f48938d/phoenix-core/src/main/java/org/apache/phoenix/trace/util/Tracing.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/trace/util/Tracing.java 
b/phoenix-core/src/main/java/org/apache/phoenix/trace/util/Tracing.java
index 7e1df72..a46d4e8 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/trace/util/Tracing.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/trace/util/Tracing.java
@@ -254,6 +254,12 @@ public class Tracing {
 } catch (RuntimeException e) {
 LOG.warn("Tracing will outputs will not be written to any metrics 
sink! No "
 + "TraceMetricsSink found on the classpath", e);
+} catch (IllegalAccessError e) {
+// This is an issue when we have a class incompatibility error, 
such as when running
+// within SquirrelSQL which uses an older incompatible version of 
commons-collections.
+// Seeing as this only results in disabling tracing, we swallow 
this exception and just
+// continue on without tracing.
+LOG.warn("Class incompatibility while initializing metrics, 
metrics will be disabled", e);
 }
 initialized = true;
 }



[44/50] [abbrv] phoenix git commit: PHOENIX-1489 Access column values positionally from client

2015-03-04 Thread maryannxue
PHOENIX-1489 Access column values positionally from client


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/3f829751
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/3f829751
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/3f829751

Branch: refs/heads/calcite
Commit: 3f829751dd5158c526e5c5bd3da61dde1c6e4194
Parents: 0440aca
Author: maryannxue 
Authored: Tue Mar 3 12:12:49 2015 -0500
Committer: maryannxue 
Committed: Tue Mar 3 12:12:49 2015 -0500

--
 .../org/apache/phoenix/end2end/HashJoinIT.java  |  55 ++--
 .../phoenix/end2end/HashJoinLocalIndexIT.java   |   6 +-
 .../org/apache/phoenix/end2end/SubqueryIT.java  |  30 +--
 .../end2end/SubqueryUsingSortMergeJoinIT.java   |  32 +--
 .../index/GlobalIndexOptimizationIT.java|  22 +-
 .../phoenix/end2end/index/LocalIndexIT.java |   4 +-
 .../phoenix/compile/ExpressionCompiler.java |   2 +-
 .../apache/phoenix/compile/FromCompiler.java|  87 ++-
 .../apache/phoenix/compile/JoinCompiler.java| 258 ---
 .../apache/phoenix/compile/OrderByCompiler.java |   2 +-
 .../phoenix/compile/ProjectionCompiler.java |  58 +++--
 .../apache/phoenix/compile/QueryCompiler.java   | 115 +
 .../compile/TupleProjectionCompiler.java| 214 +++
 .../apache/phoenix/compile/UpsertCompiler.java  |   4 +-
 .../apache/phoenix/compile/WhereCompiler.java   |   2 +-
 .../coprocessor/BaseScannerRegionObserver.java  |  21 +-
 .../GroupedAggregateRegionObserver.java |  11 +-
 .../coprocessor/HashJoinRegionScanner.java  |  72 +++---
 .../phoenix/coprocessor/ScanRegionObserver.java |   9 +-
 .../UngroupedAggregateRegionObserver.java   |  10 +-
 .../apache/phoenix/execute/TupleProjector.java  |  18 +-
 .../org/apache/phoenix/join/HashJoinInfo.java   |  25 +-
 .../apache/phoenix/optimize/QueryOptimizer.java |  19 +-
 .../org/apache/phoenix/schema/ColumnRef.java|   2 +-
 .../phoenix/schema/LocalIndexDataColumnRef.java |   9 +-
 .../apache/phoenix/schema/MetaDataClient.java   |   2 +-
 .../org/apache/phoenix/schema/PTableType.java   |   2 +-
 .../apache/phoenix/schema/ProjectedColumn.java  |  59 +
 .../org/apache/phoenix/schema/TableRef.java |   8 +-
 .../phoenix/compile/WhereCompilerTest.java  |   6 +-
 30 files changed, 691 insertions(+), 473 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/3f829751/phoenix-core/src/it/java/org/apache/phoenix/end2end/HashJoinIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/HashJoinIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/HashJoinIT.java
index e915b36..596e5e9 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/HashJoinIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/HashJoinIT.java
@@ -219,7 +219,7 @@ public class HashJoinIT extends BaseHBaseManagedTimeIT {
 "SERVER FILTER BY QUANTITY < 5000\n" +
 "PARALLEL INNER-JOIN TABLE 1\n" +
 "CLIENT PARALLEL 1-WAY FULL SCAN OVER " + 
JOIN_SUPPLIER_TABLE_DISPLAY_NAME + "\n" +
-"DYNAMIC SERVER FILTER BY \"item_id\" IN (\"O.item_id\")",
+"DYNAMIC SERVER FILTER BY \"I.item_id\" IN 
(\"O.item_id\")",
 /*
  * testSelfJoin()
  * SELECT i2.item_id, i1.name FROM joinItemTable i1 
@@ -230,7 +230,7 @@ public class HashJoinIT extends BaseHBaseManagedTimeIT {
 "PARALLEL INNER-JOIN TABLE 0\n" +
 "CLIENT PARALLEL 1-WAY FULL SCAN OVER " + 
JOIN_ITEM_TABLE_DISPLAY_NAME + "\n" +
 "SERVER FILTER BY FIRST KEY ONLY\n" +
-"DYNAMIC SERVER FILTER BY \"item_id\" IN (\"I2.item_id\")",
+"DYNAMIC SERVER FILTER BY \"I1.item_id\" IN 
(\"I2.item_id\")",
 /*
  * testSelfJoin()
  * SELECT i1.name, i2.name FROM joinItemTable i1 
@@ -242,7 +242,7 @@ public class HashJoinIT extends BaseHBaseManagedTimeIT {
 "CLIENT MERGE SORT\n" +
 "PARALLEL INNER-JOIN TABLE 0\n" +
 "CLIENT PARALLEL 1-WAY FULL SCAN OVER " + 
JOIN_ITEM_TABLE_DISPLAY_NAME + "\n" +
-"DYNAMIC SERVER FILTER BY \"item_id\" IN 
(\"I2.supplier_id\")",
+"DYNAMIC SERVER FILTER BY \"I1.item_id\" IN 
(\"I2.supplier_id\")",
 /*
  * testStarJoin()
  * SELECT order_id, c.name, i.name iname, quantity, o.date 
@@ -271,7 +271,7 @@ public class HashJoinIT extends BaseHBaseManagedTimeIT {
 "CLIENT PARALLEL 1-WAY FULL SCAN OVE

[28/50] [abbrv] phoenix git commit: PHOENIX-1650 Possible resource leak in upsert select query (Rajeshbabu)

2015-03-04 Thread maryannxue
PHOENIX-1650 Possible resource leak in upsert select query (Rajeshbabu)


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/e0a81a09
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/e0a81a09
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/e0a81a09

Branch: refs/heads/calcite
Commit: e0a81a09ec7aeab44a2bce597d19850e7c6a7846
Parents: 7dc3d84
Author: James Taylor 
Authored: Tue Feb 10 16:51:10 2015 -0800
Committer: James Taylor 
Committed: Tue Feb 10 16:53:26 2015 -0800

--
 .../apache/phoenix/compile/UpsertCompiler.java  | 26 +++-
 1 file changed, 15 insertions(+), 11 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/e0a81a09/phoenix-core/src/main/java/org/apache/phoenix/compile/UpsertCompiler.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/UpsertCompiler.java 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/UpsertCompiler.java
index 2ac075e..b21cc2f 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/UpsertCompiler.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/UpsertCompiler.java
@@ -670,18 +670,22 @@ public class UpsertCompiler {
 if (parallelIteratorFactory == null) {
 return upsertSelect(statement, tableRef, projector, 
iterator, columnIndexes, pkSlotIndexes);
 }
-parallelIteratorFactory.setRowProjector(projector);
-parallelIteratorFactory.setColumnIndexes(columnIndexes);
-parallelIteratorFactory.setPkSlotIndexes(pkSlotIndexes);
-Tuple tuple;
-long totalRowCount = 0;
-while ((tuple=iterator.next()) != null) {// Runs query
-Cell kv = tuple.getValue(0);
-totalRowCount += 
PLong.INSTANCE.getCodec().decodeLong(kv.getValueArray(), kv.getValueOffset(), 
SortOrder.getDefault());
+try {
+parallelIteratorFactory.setRowProjector(projector);
+
parallelIteratorFactory.setColumnIndexes(columnIndexes);
+
parallelIteratorFactory.setPkSlotIndexes(pkSlotIndexes);
+Tuple tuple;
+long totalRowCount = 0;
+while ((tuple=iterator.next()) != null) {// Runs query
+Cell kv = tuple.getValue(0);
+totalRowCount += 
PLong.INSTANCE.getCodec().decodeLong(kv.getValueArray(), kv.getValueOffset(), 
SortOrder.getDefault());
+}
+// Return total number of rows that have been updated. 
In the case of auto commit being off
+// the mutations will all be in the mutation state of 
the current connection.
+return new MutationState(maxSize, 
statement.getConnection(), totalRowCount);
+} finally {
+iterator.close();
 }
-// Return total number of rows that have been updated. In 
the case of auto commit being off
-// the mutations will all be in the mutation state of the 
current connection.
-return new MutationState(maxSize, 
statement.getConnection(), totalRowCount);
 }
 
 @Override



[02/50] [abbrv] phoenix git commit: PHOENIX-1610 Incorrect subquery results caused by unpaired contextStack push/pop

2015-03-04 Thread maryannxue
PHOENIX-1610 Incorrect subquery results caused by unpaired contextStack push/pop


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/1c58f442
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/1c58f442
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/1c58f442

Branch: refs/heads/calcite
Commit: 1c58f442dea6c19745a119f53e47e78ce9e2ef76
Parents: d058a41
Author: maryannxue 
Authored: Thu Jan 29 11:42:24 2015 -0500
Committer: maryannxue 
Committed: Thu Jan 29 11:42:24 2015 -0500

--
 .../apache/phoenix/end2end/DerivedTableIT.java  |  9 +++
 .../org/apache/phoenix/end2end/HashJoinIT.java  | 52 
 .../org/apache/phoenix/end2end/SubqueryIT.java  | 10 ++--
 .../end2end/SubqueryUsingSortMergeJoinIT.java   | 10 ++--
 phoenix-core/src/main/antlr3/PhoenixSQL.g   |  6 +-
 .../apache/phoenix/compile/QueryCompiler.java   | 12 ++--
 .../apache/phoenix/execute/HashJoinPlan.java| 63 
 .../phoenix/expression/InListExpression.java|  9 +--
 .../apache/phoenix/join/HashCacheClient.java| 58 +++---
 .../apache/phoenix/optimize/QueryOptimizer.java |  2 +-
 .../java/org/apache/phoenix/parse/HintNode.java |  8 +--
 11 files changed, 120 insertions(+), 119 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/1c58f442/phoenix-core/src/it/java/org/apache/phoenix/end2end/DerivedTableIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DerivedTableIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DerivedTableIT.java
index 727293f..7a418bd 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DerivedTableIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DerivedTableIT.java
@@ -667,6 +667,15 @@ public class DerivedTableIT extends 
BaseClientManagedTimeIT {
 assertEquals(2,rs.getInt(1));
 
 assertFalse(rs.next());
+
+// count (subquery)
+query = "SELECT count(*) FROM (SELECT * FROM aTable WHERE 
(organization_id, entity_id) in (SELECT organization_id, entity_id FROM aTable 
WHERE a_byte != 8)) AS t";
+statement = conn.prepareStatement(query);
+rs = statement.executeQuery();
+assertTrue (rs.next());
+assertEquals(8,rs.getInt(1));
+
+assertFalse(rs.next());
 } finally {
 conn.close();
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/1c58f442/phoenix-core/src/it/java/org/apache/phoenix/end2end/HashJoinIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/HashJoinIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/HashJoinIT.java
index 9a95ea4..a699d48 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/HashJoinIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/HashJoinIT.java
@@ -229,7 +229,7 @@ public class HashJoinIT extends BaseHBaseManagedTimeIT {
 "PARALLEL INNER-JOIN TABLE 0\n" +
 "CLIENT PARALLEL 1-WAY FULL SCAN OVER " + 
JOIN_ITEM_TABLE_DISPLAY_NAME + "\n" +
 "SERVER FILTER BY FIRST KEY ONLY\n" +
-"DYNAMIC SERVER FILTER BY item_id BETWEEN MIN/MAX OF 
(I2.item_id)",
+"DYNAMIC SERVER FILTER BY item_id IN (I2.item_id)",
 /*
  * testSelfJoin()
  * SELECT i1.name, i2.name FROM joinItemTable i1 
@@ -241,7 +241,7 @@ public class HashJoinIT extends BaseHBaseManagedTimeIT {
 "CLIENT MERGE SORT\n" +
 "PARALLEL INNER-JOIN TABLE 0\n" +
 "CLIENT PARALLEL 1-WAY FULL SCAN OVER " + 
JOIN_ITEM_TABLE_DISPLAY_NAME + "\n" +
-"DYNAMIC SERVER FILTER BY item_id BETWEEN MIN/MAX OF 
(I2.supplier_id)",
+"DYNAMIC SERVER FILTER BY item_id IN (I2.supplier_id)",
 /*
  * testStarJoin()
  * SELECT order_id, c.name, i.name iname, quantity, o.date 
@@ -270,7 +270,7 @@ public class HashJoinIT extends BaseHBaseManagedTimeIT {
 "CLIENT PARALLEL 1-WAY FULL SCAN OVER " + 
JOIN_ORDER_TABLE_DISPLAY_NAME + "\n" +
 "PARALLEL INNER-JOIN TABLE 0\n" +
 "CLIENT PARALLEL 1-WAY FULL SCAN OVER " + 
JOIN_CUSTOMER_TABLE_DISPLAY_NAME + "\n" +
-"DYNAMIC SERVER FILTER BY item_id BETWEEN MIN/MAX OF 
(O.item_id)",
+"DYNAMIC SERVER FILTER BY item_id IN (O.item_id)",
 /*
  * testSubJoin()
  * SELECT * F

[27/50] [abbrv] phoenix git commit: PHOENIX-1649 Remove System.out/System.err debugging messages (Rajeshbabu)

2015-03-04 Thread maryannxue
PHOENIX-1649 Remove System.out/System.err debugging messages (Rajeshbabu)


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/7dc3d842
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/7dc3d842
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/7dc3d842

Branch: refs/heads/calcite
Commit: 7dc3d84218bdcc9a9d408283f3badab9230b1ad9
Parents: acb8799
Author: James Taylor 
Authored: Tue Feb 10 09:50:42 2015 -0800
Committer: James Taylor 
Committed: Tue Feb 10 09:50:42 2015 -0800

--
 .../wal/WALReplayWithIndexWritesAndCompressedWALIT.java   | 2 +-
 .../src/main/java/org/apache/phoenix/schema/MetaDataClient.java   | 3 ---
 .../test/java/org/apache/phoenix/schema/types/PDataTypeTest.java  | 1 -
 .../src/it/java/org/apache/phoenix/pig/PhoenixHBaseLoaderIT.java  | 3 +--
 4 files changed, 2 insertions(+), 7 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/7dc3d842/phoenix-core/src/it/java/org/apache/hadoop/hbase/regionserver/wal/WALReplayWithIndexWritesAndCompressedWALIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/hadoop/hbase/regionserver/wal/WALReplayWithIndexWritesAndCompressedWALIT.java
 
b/phoenix-core/src/it/java/org/apache/hadoop/hbase/regionserver/wal/WALReplayWithIndexWritesAndCompressedWALIT.java
index b3a980e..8cf8a8a 100644
--- 
a/phoenix-core/src/it/java/org/apache/hadoop/hbase/regionserver/wal/WALReplayWithIndexWritesAndCompressedWALIT.java
+++ 
b/phoenix-core/src/it/java/org/apache/hadoop/hbase/regionserver/wal/WALReplayWithIndexWritesAndCompressedWALIT.java
@@ -293,7 +293,7 @@ private int getKeyValueCount(HTable table) throws 
IOException {
 int count = 0;
 for (Result res : results) {
   count += res.list().size();
-  System.out.println(count + ") " + res);
+  LOG.debug(count + ") " + res);
 }
 results.close();
 

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7dc3d842/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java 
b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
index 2722cb6..61ee081 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
@@ -332,9 +332,6 @@ public class MetaDataClient {
 table = connection.getMetaDataCache().getTable(new 
PTableKey(tenantId, fullTableName));
 tableTimestamp = table.getTimeStamp();
 } catch (TableNotFoundException e) {
-System.err.println(e);
-// TODO: Try again on services cache, as we may be looking for
-// a global multi-tenant table
 }
 // Don't bother with server call: we can't possibly find a newer table
 if (table != null && !alwaysHitServer && (systemTable || 
tableTimestamp == clientTimeStamp - 1)) {

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7dc3d842/phoenix-core/src/test/java/org/apache/phoenix/schema/types/PDataTypeTest.java
--
diff --git 
a/phoenix-core/src/test/java/org/apache/phoenix/schema/types/PDataTypeTest.java 
b/phoenix-core/src/test/java/org/apache/phoenix/schema/types/PDataTypeTest.java
index 90730bc..b2e6e0b 100644
--- 
a/phoenix-core/src/test/java/org/apache/phoenix/schema/types/PDataTypeTest.java
+++ 
b/phoenix-core/src/test/java/org/apache/phoenix/schema/types/PDataTypeTest.java
@@ -1011,7 +1011,6 @@ public class PDataTypeTest {
 byte[] bytes = Bytes.toBytesBinary(str);
 Object o = PDecimal.INSTANCE.toObject(bytes);
 assertNotNull(o);
-//System.out.println(o.getClass() +" " + bytesToHex(bytes)+" " 
+ o+" ");
 }
 }
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/7dc3d842/phoenix-pig/src/it/java/org/apache/phoenix/pig/PhoenixHBaseLoaderIT.java
--
diff --git 
a/phoenix-pig/src/it/java/org/apache/phoenix/pig/PhoenixHBaseLoaderIT.java 
b/phoenix-pig/src/it/java/org/apache/phoenix/pig/PhoenixHBaseLoaderIT.java
index 51b2478..594abe6 100644
--- a/phoenix-pig/src/it/java/org/apache/phoenix/pig/PhoenixHBaseLoaderIT.java
+++ b/phoenix-pig/src/it/java/org/apache/phoenix/pig/PhoenixHBaseLoaderIT.java
@@ -520,8 +520,7 @@ public class PhoenixHBaseLoaderIT {
 Iterator iterator = pigServer.openIterator("A");
 int recordsRead = 0;
 while (iterator.hasNext()) {
-Tuple tuple = iterator.next();
-System.out.pr

[41/50] [abbrv] phoenix git commit: PHOENIX-1686 Data length should be checked in KeyValueSchema.next() and maxOffset should be set correctly by the caller

2015-03-04 Thread maryannxue
PHOENIX-1686 Data length should be checked in KeyValueSchema.next() and 
maxOffset should be set correctly by the caller


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/93f56057
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/93f56057
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/93f56057

Branch: refs/heads/calcite
Commit: 93f560575319b7f26f5fc5db618bc2d8a09be930
Parents: 569469a
Author: maryannxue 
Authored: Fri Feb 27 16:43:13 2015 -0500
Committer: maryannxue 
Committed: Fri Feb 27 16:43:13 2015 -0500

--
 .../phoenix/expression/ProjectedColumnExpression.java |  2 +-
 .../org/apache/phoenix/schema/KeyValueSchema.java | 14 +-
 2 files changed, 10 insertions(+), 6 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/93f56057/phoenix-core/src/main/java/org/apache/phoenix/expression/ProjectedColumnExpression.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/expression/ProjectedColumnExpression.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/expression/ProjectedColumnExpression.java
index d090203..97d1aff 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/expression/ProjectedColumnExpression.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/expression/ProjectedColumnExpression.java
@@ -106,9 +106,9 @@ public class ProjectedColumnExpression extends 
ColumnExpression {
 try {
 KeyValueSchema schema = getSchema();
 TupleProjector.decodeProjectedValue(tuple, ptr);
-int maxOffset = ptr.getOffset() + ptr.getLength();
 bitSet.clear();
 bitSet.or(ptr);
+int maxOffset = ptr.getOffset() + ptr.getLength() - 
bitSet.getEstimatedLength();
 schema.iterator(ptr, position, bitSet);
 Boolean hasValue = schema.next(ptr, position, maxOffset, bitSet);
 if (hasValue == null || !hasValue.booleanValue())

http://git-wip-us.apache.org/repos/asf/phoenix/blob/93f56057/phoenix-core/src/main/java/org/apache/phoenix/schema/KeyValueSchema.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/schema/KeyValueSchema.java 
b/phoenix-core/src/main/java/org/apache/phoenix/schema/KeyValueSchema.java
index 595103f..1ab8c86 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/KeyValueSchema.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/KeyValueSchema.java
@@ -22,6 +22,8 @@ import java.util.List;
 import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
 import org.apache.hadoop.io.WritableUtils;
 import org.apache.http.annotation.Immutable;
+import org.apache.phoenix.exception.SQLExceptionCode;
+import org.apache.phoenix.exception.SQLExceptionInfo;
 import org.apache.phoenix.expression.Expression;
 import org.apache.phoenix.schema.tuple.Tuple;
 import org.apache.phoenix.schema.types.PDataType;
@@ -203,12 +205,14 @@ public class KeyValueSchema extends ValueSchema {
 ptr.set(ptr.get(), ptr.getOffset() + ptr.getLength(), 0);
 if (!isNull(position, valueSet)) {
 Field field = this.getField(position);
-if (field.getDataType().isFixedWidth()) {
-ptr.set(ptr.get(),ptr.getOffset(), field.getByteSize());
-} else {
-int length = ByteUtil.vintFromBytes(ptr);
-ptr.set(ptr.get(),ptr.getOffset(),length);
+int length = field.getDataType().isFixedWidth() ? 
+field.getByteSize() : ByteUtil.vintFromBytes(ptr);
+if (ptr.getOffset() + length > maxOffset) {
+throw new RuntimeException(new 
SQLExceptionInfo.Builder(SQLExceptionCode.ILLEGAL_DATA)
+.setMessage("Expected length of at least " + length + " 
bytes, but had " + (maxOffset
+- 
ptr.getOffset())).build().buildException());
 }
+ptr.set(ptr.get(),ptr.getOffset(),length);
 return ptr.getLength() > 0;
 }
 return false;



[16/50] [abbrv] phoenix git commit: PHOENIX-1641 Make the upgrade from 4.x to 4.3 work for SYSTEM.CATALOG and SYSTEM.SEQUENCE

2015-03-04 Thread maryannxue
PHOENIX-1641 Make the upgrade from 4.x to 4.3 work for  SYSTEM.CATALOG and 
SYSTEM.SEQUENCE


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/eaa7fbfd
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/eaa7fbfd
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/eaa7fbfd

Branch: refs/heads/calcite
Commit: eaa7fbfde9f45c635cc11d524977d54485c9ea8d
Parents: 9db37bd
Author: Samarth 
Authored: Fri Feb 6 16:29:09 2015 -0800
Committer: Samarth 
Committed: Fri Feb 6 16:29:09 2015 -0800

--
 .../query/ConnectionQueryServicesImpl.java  |  69 +--
 .../org/apache/phoenix/util/UpgradeUtil.java| 179 ++-
 2 files changed, 146 insertions(+), 102 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/eaa7fbfd/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
index 6d58f57..7763a0a 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
@@ -136,6 +136,7 @@ import org.apache.phoenix.schema.stats.StatisticsUtil;
 import org.apache.phoenix.schema.types.PBoolean;
 import org.apache.phoenix.schema.types.PDataType;
 import org.apache.phoenix.schema.types.PLong;
+import org.apache.phoenix.schema.types.PUnsignedTinyint;
 import org.apache.phoenix.util.ByteUtil;
 import org.apache.phoenix.util.Closeables;
 import org.apache.phoenix.util.ConfigUtil;
@@ -1757,8 +1758,10 @@ public class ConnectionQueryServicesImpl extends 
DelegateQueryServices implement
 
 }
 
-// Keeping this to use for further upgrades
-protected PhoenixConnection addColumnsIfNotExists(PhoenixConnection 
oldMetaConnection,
+/** 
+ * Keeping this to use for further upgrades. This method closes the 
oldMetaConnection.
+ */
+private PhoenixConnection addColumnsIfNotExists(PhoenixConnection 
oldMetaConnection,
 String tableName, long timestamp, String columns) throws SQLException {
 
 Properties props = new Properties(oldMetaConnection.getClientInfo());
@@ -1826,7 +1829,29 @@ public class ConnectionQueryServicesImpl extends 
DelegateQueryServices implement
 } catch (NewerTableAlreadyExistsException ignore) {
 // Ignore, as this will happen if the 
SYSTEM.CATALOG already exists at this fixed timestamp.
 // A TableAlreadyExistsException is not 
thrown, since the table only exists *after* this fixed timestamp.
-} catch (TableAlreadyExistsException ignore) {
+} catch (TableAlreadyExistsException e) {
+// This will occur if we have an older 
SYSTEM.CATALOG and we need to update it to include
+// any new columns we've added.
+long currentServerSideTableTimeStamp = 
e.getTable().getTimeStamp();
+
+// We know that we always need to add the 
STORE_NULLS column for 4.3 release
+String columnsToAdd = 
PhoenixDatabaseMetaData.STORE_NULLS + " " + PBoolean.INSTANCE.getSqlTypeName();
+
+// If the server side schema is 4 versions 
behind then we need to add INDEX_TYPE
+// and INDEX_DISABLE_TIMESTAMP columns too.
+// TODO: Once 
https://issues.apache.org/jira/browse/PHOENIX-1614 is fixed,
+// we should just have a ALTER TABLE ADD IF 
NOT EXISTS statement with all
+// the column names that have been added to 
SYSTEM.CATALOG since 4.0.
+if (currentServerSideTableTimeStamp < 
MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP - 4) {
+columnsToAdd += ", " + 
PhoenixDatabaseMetaData.INDEX_TYPE + " " + 
PUnsignedTinyint.INSTANCE.getSqlTypeName()
++ ", " + 
PhoenixDatabaseMetaData.INDEX_DISABLE_TIMESTAMP + " " + 
PLong.INSTANCE.getSqlTypeName();
+}
+
+// Ugh..need to assign to another local 
variable to keep eclipse happy.
+PhoenixConnection newMetaConnection = 
addColumnsIfNotExists(metaConnection,
+

[05/50] [abbrv] phoenix git commit: PHOENIX-1616 Creating a View with a case sensitive column name does not work (Thomas D'Silva)

2015-03-04 Thread maryannxue
PHOENIX-1616 Creating a View with a case sensitive column name does not work 
(Thomas D'Silva)


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/03a5d7ef
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/03a5d7ef
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/03a5d7ef

Branch: refs/heads/calcite
Commit: 03a5d7ef198f059b289a7195613db8d375b88e46
Parents: a1baf2a
Author: James Taylor 
Authored: Sat Jan 31 11:17:46 2015 -0800
Committer: James Taylor 
Committed: Sat Jan 31 11:17:46 2015 -0800

--
 .../org/apache/phoenix/end2end/HashJoinIT.java  | 84 -
 .../phoenix/end2end/HashJoinLocalIndexIT.java   |  4 +-
 .../apache/phoenix/end2end/SortMergeJoinIT.java | 22 ++---
 .../org/apache/phoenix/end2end/SubqueryIT.java  | 70 +++---
 .../end2end/SubqueryUsingSortMergeJoinIT.java   | 96 ++--
 .../java/org/apache/phoenix/end2end/ViewIT.java | 27 ++
 .../index/GlobalIndexOptimizationIT.java| 18 ++--
 .../phoenix/compile/ExpressionCompiler.java |  2 +-
 .../apache/phoenix/parse/ColumnParseNode.java   |  4 +
 .../org/apache/phoenix/parse/TableName.java | 24 +++--
 .../org/apache/phoenix/schema/ColumnRef.java|  8 +-
 .../phoenix/schema/LocalIndexDataColumnRef.java |  2 +-
 .../org/apache/phoenix/schema/TableRef.java | 37 
 .../java/org/apache/phoenix/util/IndexUtil.java |  3 +-
 .../org/apache/phoenix/util/SchemaUtil.java |  8 +-
 15 files changed, 225 insertions(+), 184 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/03a5d7ef/phoenix-core/src/it/java/org/apache/phoenix/end2end/HashJoinIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/HashJoinIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/HashJoinIT.java
index a699d48..781bfea 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/HashJoinIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/HashJoinIT.java
@@ -127,7 +127,7 @@ public class HashJoinIT extends BaseHBaseManagedTimeIT {
  * GROUP BY i.item_id ORDER BY q DESC"
  */ 
 "CLIENT PARALLEL 1-WAY FULL SCAN OVER " + 
JOIN_ORDER_TABLE_DISPLAY_NAME + "\n" +
-"SERVER AGGREGATE INTO DISTINCT ROWS BY [I.item_id]\n" +
+"SERVER AGGREGATE INTO DISTINCT ROWS BY [\"I.item_id\"]\n" 
+
 "CLIENT MERGE SORT\n" +
 "CLIENT SORTED BY [SUM(O.QUANTITY) DESC]\n" +
 "PARALLEL LEFT-JOIN TABLE 0\n" +
@@ -141,9 +141,9 @@ public class HashJoinIT extends BaseHBaseManagedTimeIT {
  */ 
 "CLIENT PARALLEL 1-WAY FULL SCAN OVER " + 
JOIN_ITEM_TABLE_DISPLAY_NAME + "\n" +
 "SERVER FILTER BY FIRST KEY ONLY\n" +
-"SERVER AGGREGATE INTO ORDERED DISTINCT ROWS BY 
[I.item_id]\n" +
+"SERVER AGGREGATE INTO ORDERED DISTINCT ROWS BY 
[\"I.item_id\"]\n" +
 "CLIENT MERGE SORT\n" +
-"CLIENT SORTED BY [SUM(O.QUANTITY) DESC NULLS LAST, 
I.item_id]\n" +
+"CLIENT SORTED BY [SUM(O.QUANTITY) DESC NULLS LAST, 
\"I.item_id\"]\n" +
 "PARALLEL LEFT-JOIN TABLE 0\n" +
 "CLIENT PARALLEL 1-WAY FULL SCAN OVER " + 
JOIN_ORDER_TABLE_DISPLAY_NAME,
 /* 
@@ -166,9 +166,9 @@ public class HashJoinIT extends BaseHBaseManagedTimeIT {
  */
 "CLIENT PARALLEL 1-WAY FULL SCAN OVER " + 
JOIN_ITEM_TABLE_DISPLAY_NAME + "\n" +
 "SERVER FILTER BY FIRST KEY ONLY\n" +
-"SERVER AGGREGATE INTO ORDERED DISTINCT ROWS BY 
[I.item_id]\n" +
+"SERVER AGGREGATE INTO ORDERED DISTINCT ROWS BY 
[\"I.item_id\"]\n" +
 "CLIENT MERGE SORT\n" +
-"CLIENT SORTED BY [SUM(O.QUANTITY) DESC NULLS LAST, 
I.item_id]\n" +
+"CLIENT SORTED BY [SUM(O.QUANTITY) DESC NULLS LAST, 
\"I.item_id\"]\n" +
 "PARALLEL LEFT-JOIN TABLE 0\n" +
 "CLIENT PARALLEL 1-WAY FULL SCAN OVER " + 
JOIN_ORDER_TABLE_DISPLAY_NAME,
 /*
@@ -218,7 +218,7 @@ public class HashJoinIT extends BaseHBaseManagedTimeIT {
 "SERVER FILTER BY QUANTITY < 5000\n" +
 "PARALLEL INNER-JOIN TABLE 1\n" +
 "CLIENT PARALLEL 1-WAY FULL SCAN OVER " + 
JOIN_SUPPLIER_TABLE_DISPLAY_NAME + "\n" +
-"DYNAMIC SERVER FILTER BY item_id IN (O.item_id)",
+"DYNAMIC SERVER FILTER BY \"item_id\" IN (\"O.item_id\")",
 /*
  * testSelfJoin()
  

[34/50] [abbrv] phoenix git commit: PHOENIX-1639 Enhance function/expression index tests

2015-03-04 Thread maryannxue
PHOENIX-1639 Enhance function/expression index tests


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/2e5a6308
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/2e5a6308
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/2e5a6308

Branch: refs/heads/calcite
Commit: 2e5a63089f98c21e8556fae0ec80988079e3ca55
Parents: b8c0559
Author: Thomas D'Silva 
Authored: Tue Feb 17 12:32:55 2015 -0800
Committer: Thomas D'Silva 
Committed: Tue Feb 17 12:32:55 2015 -0800

--
 .../apache/phoenix/end2end/AlterTableIT.java|  58 +-
 .../org/apache/phoenix/end2end/BaseViewIT.java  |   4 +-
 .../java/org/apache/phoenix/end2end/ViewIT.java |   5 +
 .../end2end/index/IndexExpressionIT.java| 714 +++
 .../coprocessor/MetaDataEndpointImpl.java   |   5 +-
 .../phoenix/exception/SQLExceptionCode.java |   5 +-
 .../apache/phoenix/index/IndexMaintainer.java   |   4 +-
 .../apache/phoenix/schema/MetaDataClient.java   |  33 +-
 .../phoenix/compile/QueryCompilerTest.java  |  72 ++
 9 files changed, 715 insertions(+), 185 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/2e5a6308/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java
index 7f5649b..59698d6 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java
@@ -308,7 +308,6 @@ public class AlterTableIT extends 
BaseOwnClusterHBaseManagedTimeIT {
 
 @Test
 public void testDropCoveredColumn() throws Exception {
-String query;
 ResultSet rs;
 PreparedStatement stmt;
 
@@ -320,19 +319,21 @@ public class AlterTableIT extends 
BaseOwnClusterHBaseManagedTimeIT {
 conn.createStatement().execute(
   "CREATE TABLE " + DATA_TABLE_FULL_NAME
   + " (k VARCHAR NOT NULL PRIMARY KEY, v1 VARCHAR, v2 VARCHAR, v3 
VARCHAR)");
-query = "SELECT * FROM " + DATA_TABLE_FULL_NAME;
-rs = conn.createStatement().executeQuery(query);
+String dataTableQuery = "SELECT * FROM " + DATA_TABLE_FULL_NAME;
+rs = conn.createStatement().executeQuery(dataTableQuery);
 assertFalse(rs.next());
 
 conn.createStatement().execute(
   "CREATE INDEX " + INDEX_TABLE_NAME + " ON " + DATA_TABLE_FULL_NAME + 
" (v1) include (v2, v3)");
 conn.createStatement().execute(
 "CREATE LOCAL INDEX " + LOCAL_INDEX_TABLE_NAME + " ON " + 
DATA_TABLE_FULL_NAME + " (v1) include (v2, v3)");
-query = "SELECT * FROM " + INDEX_TABLE_FULL_NAME;
-rs = conn.createStatement().executeQuery(query);
+rs = conn.createStatement().executeQuery(dataTableQuery);
 assertFalse(rs.next());
-query = "SELECT * FROM " + LOCAL_INDEX_TABLE_FULL_NAME;
-rs = conn.createStatement().executeQuery(query);
+String indexTableQuery = "SELECT * FROM " + INDEX_TABLE_NAME;
+rs = conn.createStatement().executeQuery(indexTableQuery);
+assertFalse(rs.next());
+String localIndexTableQuery = "SELECT * FROM " + 
LOCAL_INDEX_TABLE_FULL_NAME;
+rs = conn.createStatement().executeQuery(localIndexTableQuery);
 assertFalse(rs.next());
 
 // load some data into the table
@@ -346,16 +347,31 @@ public class AlterTableIT extends 
BaseOwnClusterHBaseManagedTimeIT {
 
 assertIndexExists(conn,true);
 conn.createStatement().execute("ALTER TABLE " + DATA_TABLE_FULL_NAME + 
" DROP COLUMN v2");
-// TODO: verify meta data that we get back to confirm our column was 
dropped
 assertIndexExists(conn,true);
 
-query = "SELECT * FROM " + DATA_TABLE_FULL_NAME;
-rs = conn.createStatement().executeQuery(query);
+// verify data table rows
+rs = conn.createStatement().executeQuery(dataTableQuery);
 assertTrue(rs.next());
 assertEquals("a",rs.getString(1));
 assertEquals("x",rs.getString(2));
 assertEquals("j",rs.getString(3));
 assertFalse(rs.next());
+
+// verify index table rows
+rs = conn.createStatement().executeQuery(indexTableQuery);
+assertTrue(rs.next());
+assertEquals("x",rs.getString(1));
+assertEquals("a",rs.getString(2));
+assertEquals("j",rs.getString(3));
+assertFalse(rs.next());
+
+// verify local index table rows
+rs = conn.createStatement().executeQuery(localIndexTableQuery);
+assertTrue(rs.next());
+assertEquals("x",rs.getString(1));
+a

[18/50] [abbrv] phoenix git commit: PHOENIX-1644 Check for min HBase version before creating local index and provide means of disabling usage

2015-03-04 Thread maryannxue
PHOENIX-1644 Check for min HBase version before creating local index and 
provide means of disabling usage


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/2b8e6634
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/2b8e6634
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/2b8e6634

Branch: refs/heads/calcite
Commit: 2b8e66346d2c890ff664c9f2f826acb77a7ac950
Parents: 47ca595
Author: James Taylor 
Authored: Fri Feb 6 18:26:57 2015 -0800
Committer: James Taylor 
Committed: Fri Feb 6 18:26:57 2015 -0800

--
 .../phoenix/exception/SQLExceptionCode.java |  3 ++-
 .../phoenix/jdbc/PhoenixDatabaseMetaData.java   |  3 ++-
 .../phoenix/query/ConnectionQueryServices.java  |  2 +-
 .../query/ConnectionQueryServicesImpl.java  | 24 
 .../query/ConnectionlessQueryServicesImpl.java  |  2 +-
 .../apache/phoenix/schema/MetaDataClient.java   |  3 ++-
 6 files changed, 28 insertions(+), 9 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/2b8e6634/phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionCode.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionCode.java 
b/phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionCode.java
index 19e7cdf..b2ca979 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionCode.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionCode.java
@@ -236,7 +236,8 @@ public enum SQLExceptionCode {
 CANNOT_SET_PROPERTY_FOR_COLUMN_NOT_ADDED(1052, "43A09", "Property cannot 
be specified for a column family that is not being added or modified"),
 CANNOT_SET_TABLE_PROPERTY_ADD_COLUMN(1053, "43A10", "Table level property 
cannot be set when adding a column"),
 
-NO_LOCAL_INDEXES(1054, "43A11", "Local secondary indexes are only 
supported for HBase version " + 
MetaDataUtil.decodeHBaseVersionAsString(PhoenixDatabaseMetaData.LOCAL_SI_VERSION_THRESHOLD)
 + " and above."),
+NO_LOCAL_INDEXES(1054, "43A11", "Local secondary indexes are not supported 
for HBase versions " + 
+
MetaDataUtil.decodeHBaseVersionAsString(PhoenixDatabaseMetaData.MIN_LOCAL_SI_VERSION_DISALLOW)
 + " through " + 
MetaDataUtil.decodeHBaseVersionAsString(PhoenixDatabaseMetaData.MAX_LOCAL_SI_VERSION_DISALLOW)
 + " inclusive."),
 UNALLOWED_LOCAL_INDEXES(1055, "43A12", "Local secondary indexes are 
configured to not be allowed."),
 
 /** Sequence related */

http://git-wip-us.apache.org/repos/asf/phoenix/blob/2b8e6634/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixDatabaseMetaData.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixDatabaseMetaData.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixDatabaseMetaData.java
index 7ac2bb6..034c40a 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixDatabaseMetaData.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixDatabaseMetaData.java
@@ -269,12 +269,13 @@ public class PhoenixDatabaseMetaData implements 
DatabaseMetaData, org.apache.pho
 
 private final PhoenixConnection connection;
 private final ResultSet emptyResultSet;
+public static final int MAX_LOCAL_SI_VERSION_DISALLOW = 
VersionUtil.encodeVersion("0", "98", "8");
+public static final int MIN_LOCAL_SI_VERSION_DISALLOW = 
VersionUtil.encodeVersion("0", "98", "6");
 
 // Version below which we should turn off essential column family.
 public static final int ESSENTIAL_FAMILY_VERSION_THRESHOLD = 
VersionUtil.encodeVersion("0", "94", "7");
 // Version below which we should disallow usage of mutable secondary 
indexing.
 public static final int MUTABLE_SI_VERSION_THRESHOLD = 
VersionUtil.encodeVersion("0", "94", "10");
-public static final int LOCAL_SI_VERSION_THRESHOLD = 
VersionUtil.encodeVersion("0", "98", "9");
 /** Version below which we fall back on the generic KeyValueBuilder */
 public static final int CLIENT_KEY_VALUE_BUILDER_THRESHOLD = 
VersionUtil.encodeVersion("0", "94", "14");
 

http://git-wip-us.apache.org/repos/asf/phoenix/blob/2b8e6634/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServices.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServices.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServices.java
index fa44835..09705c6 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServices.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/que

[50/50] [abbrv] phoenix git commit: Fix compilation errors and ToExpressionTest after merge

2015-03-04 Thread maryannxue
Fix compilation errors and ToExpressionTest after merge


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/026f60b1
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/026f60b1
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/026f60b1

Branch: refs/heads/calcite
Commit: 026f60b12764e68f8e60922c276a44c6543f27ce
Parents: b9d24a9
Author: maryannxue 
Authored: Wed Mar 4 17:40:22 2015 -0500
Committer: maryannxue 
Committed: Wed Mar 4 17:40:22 2015 -0500

--
 .../apache/phoenix/calcite/PhoenixTable.java|  2 +-
 .../calcite/PhoenixToEnumerableConverter.java   |  2 +-
 .../apache/phoenix/compile/FromCompiler.java|  3 +--
 .../phoenix/calcite/ToExpressionTest.java   | 25 
 4 files changed, 7 insertions(+), 25 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/026f60b1/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixTable.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixTable.java 
b/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixTable.java
index 9b58d68..730f642 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixTable.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixTable.java
@@ -14,8 +14,8 @@ import org.apache.calcite.sql.type.SqlTypeName;
 import org.apache.calcite.util.ImmutableBitSet;
 import org.apache.phoenix.jdbc.PhoenixConnection;
 import org.apache.phoenix.schema.PColumn;
-import org.apache.phoenix.schema.PDataType;
 import org.apache.phoenix.schema.PTable;
+import org.apache.phoenix.schema.types.PDataType;
 
 /**
  * Implementation of Calcite {@link org.apache.calcite.schema.Table} SPI for

http://git-wip-us.apache.org/repos/asf/phoenix/blob/026f60b1/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixToEnumerableConverter.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixToEnumerableConverter.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixToEnumerableConverter.java
index fc2af9c..e8949d8 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixToEnumerableConverter.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixToEnumerableConverter.java
@@ -62,7 +62,7 @@ public class PhoenixToEnumerableConverter extends 
ConverterImpl implements Enume
 }
 
 static Expression stash(EnumerableRelImplementor implementor, Object o, 
Class clazz) {
-ParameterExpression x = implementor.register(o, clazz);
+ParameterExpression x = (ParameterExpression) implementor.stash(o, 
clazz);
 MethodCallExpression e =
 Expressions.call(implementor.getRootExpression(),
 org.apache.calcite.util.BuiltInMethod.DATA_CONTEXT_GET.method,

http://git-wip-us.apache.org/repos/asf/phoenix/blob/026f60b1/phoenix-core/src/main/java/org/apache/phoenix/compile/FromCompiler.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/FromCompiler.java 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/FromCompiler.java
index 64024c4..977a3f8 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/FromCompiler.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/FromCompiler.java
@@ -26,7 +26,6 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
-import com.google.common.base.Preconditions;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.client.HTableInterface;
 import org.apache.phoenix.coprocessor.MetaDataProtocol;
@@ -327,7 +326,7 @@ public class FromCompiler {
 private final int tsAddition;
 
 private BaseColumnResolver(PhoenixConnection connection, int 
tsAddition) {
-this.connection = Preconditions.checkNotNull(connection);
+this.connection = connection;
 this.client = connection == null ? null : new 
MetaDataClient(connection);
 this.tsAddition = tsAddition;
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/026f60b1/phoenix-core/src/test/java/org/apache/phoenix/calcite/ToExpressionTest.java
--
diff --git 
a/phoenix-core/src/test/java/org/apache/phoenix/calcite/ToExpressionTest.java 
b/phoenix-core/src/test/java/org/apache/phoenix/calcite/ToExpressionTest.java
index 91628ff..50ac2a8 100644
--- 
a/phoenix-core/src/test/java/org/apache/phoenix/calcite/ToExpressionTest.java
+++ 
b/phoenix-core/src/test/java/org/apache/phoenix/calcite/ToExpressionTest.java
@@ -1,41 +1,30

[45/50] [abbrv] phoenix git commit: PHOENIX-1690 IndexOutOfBoundsException during SkipScanFilter interesect

2015-03-04 Thread maryannxue
http://git-wip-us.apache.org/repos/asf/phoenix/blob/49f06b33/phoenix-core/src/test/java/org/apache/phoenix/filter/SkipScanFilterIntersectTest.java
--
diff --git 
a/phoenix-core/src/test/java/org/apache/phoenix/filter/SkipScanFilterIntersectTest.java
 
b/phoenix-core/src/test/java/org/apache/phoenix/filter/SkipScanFilterIntersectTest.java
index a2b6115..fea1d91 100644
--- 
a/phoenix-core/src/test/java/org/apache/phoenix/filter/SkipScanFilterIntersectTest.java
+++ 
b/phoenix-core/src/test/java/org/apache/phoenix/filter/SkipScanFilterIntersectTest.java
@@ -26,13 +26,13 @@ import java.util.List;
 
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.phoenix.query.KeyRange;
-import org.apache.phoenix.schema.types.PChar;
-import org.apache.phoenix.schema.types.PDataType;
 import org.apache.phoenix.schema.PDatum;
-import org.apache.phoenix.schema.types.PVarchar;
 import org.apache.phoenix.schema.RowKeySchema;
 import org.apache.phoenix.schema.RowKeySchema.RowKeySchemaBuilder;
 import org.apache.phoenix.schema.SortOrder;
+import org.apache.phoenix.schema.types.PChar;
+import org.apache.phoenix.schema.types.PDataType;
+import org.apache.phoenix.schema.types.PVarchar;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
@@ -92,7 +92,8 @@ public class SkipScanFilterIntersectTest {
 @Parameters(name="{0} {4}")
 public static Collection data() {
 List testCases = Lists.newArrayList();
-// Causes increment of slot 2 to increment slot 1
+// Both ranges in second slot are required b/c first slot contains 
range and upper/lower
+// values differ in this slot position.
 testCases.addAll(foreach(
 new KeyRange[][] {{
 PChar.INSTANCE.getKeyRange(Bytes.toBytes("b"), true, 
Bytes.toBytes("e"), false),
@@ -109,10 +110,70 @@ public class SkipScanFilterIntersectTest {
 new KeyRange[][] {{
 PChar.INSTANCE.getKeyRange(Bytes.toBytes("j"), true, 
Bytes.toBytes("m"), false),
 }, {
+PChar.INSTANCE.getKeyRange(Bytes.toBytes("1"), true, 
Bytes.toBytes("1"), true),
 PChar.INSTANCE.getKeyRange(Bytes.toBytes("2"), true, 
Bytes.toBytes("4"), true),
 }, {
 PChar.INSTANCE.getKeyRange(Bytes.toBytes("B"), true, 
Bytes.toBytes("B"), true),
 }}));
+// Only second range in second slot is required b/c though first slot 
contains range,
+// upper/lower values do not differ in this slot position.
+testCases.addAll(foreach(
+new KeyRange[][] {{
+PChar.INSTANCE.getKeyRange(Bytes.toBytes("b"), true, 
Bytes.toBytes("e"), false),
+PChar.INSTANCE.getKeyRange(Bytes.toBytes("j"), true, 
Bytes.toBytes("m"), false),
+}, {
+PChar.INSTANCE.getKeyRange(Bytes.toBytes("1"), true, 
Bytes.toBytes("1"), true),
+PChar.INSTANCE.getKeyRange(Bytes.toBytes("2"), true, 
Bytes.toBytes("4"), true),
+}, {
+PChar.INSTANCE.getKeyRange(Bytes.toBytes("B"), true, 
Bytes.toBytes("B"), true),
+}},
+new int[] {1,1,1},
+Bytes.toBytes("j3A"),
+Bytes.toBytes("j4C"),
+new KeyRange[][] {{
+PChar.INSTANCE.getKeyRange(Bytes.toBytes("j"), true, 
Bytes.toBytes("m"), false),
+}, {
+PChar.INSTANCE.getKeyRange(Bytes.toBytes("2"), true, 
Bytes.toBytes("4"), true),
+}, {
+PChar.INSTANCE.getKeyRange(Bytes.toBytes("B"), true, 
Bytes.toBytes("B"), true),
+}}));
+// Test case exercising repositioning multiple times (initially to 
slot #2 and then again
+// to slot #4). Because there's a range for slot #4 and the 
lower/upper values are different,
+// all slot #5 ranges are part of the intersection.
+testCases.addAll(foreach(
+new KeyRange[][] {{
+PChar.INSTANCE.getKeyRange(Bytes.toBytes("b"), true, 
Bytes.toBytes("b"), true),
+PChar.INSTANCE.getKeyRange(Bytes.toBytes("d"), true, 
Bytes.toBytes("d"), true),
+}, {
+PChar.INSTANCE.getKeyRange(Bytes.toBytes("j"), true, 
Bytes.toBytes("m"), false),
+}, {
+PChar.INSTANCE.getKeyRange(Bytes.toBytes("C"), true, 
Bytes.toBytes("C"), true),
+}, {
+PChar.INSTANCE.getKeyRange(Bytes.toBytes("m"), true, 
Bytes.toBytes("u"), false),
+PChar.INSTANCE.getKeyRange(Bytes.toBytes("z"), true, 
Bytes.toBytes("z"), true),
+}, {
+PChar.INSTANCE.getKeyRange(Bytes.toBytes("A"), true, 
Bytes.toByte

[30/50] [abbrv] phoenix git commit: PHOENIX-1656 - Add release dir to gitignore

2015-03-04 Thread maryannxue
PHOENIX-1656 - Add release dir to gitignore


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/f925a403
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/f925a403
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/f925a403

Branch: refs/heads/calcite
Commit: f925a4034b7b78f8e9d15539cdd7b0cc8a54e59b
Parents: fc299d5
Author: Mujtaba 
Authored: Thu Feb 12 13:00:51 2015 -0800
Committer: Mujtaba 
Committed: Thu Feb 12 13:00:51 2015 -0800

--
 .gitignore | 1 +
 1 file changed, 1 insertion(+)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/f925a403/.gitignore
--
diff --git a/.gitignore b/.gitignore
index 21a2c92..5f0dab5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,3 +15,4 @@
 
 #maven stuffs
 target/
+release/



[32/50] [abbrv] phoenix git commit: PHOENIX-1634 LocalIndexSplitter prevents region from auto split(Rajeshbabu)

2015-03-04 Thread maryannxue
PHOENIX-1634 LocalIndexSplitter prevents region from auto split(Rajeshbabu)


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/e09a8f8d
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/e09a8f8d
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/e09a8f8d

Branch: refs/heads/calcite
Commit: e09a8f8de715ec17fbdedb28b9b4153b5886d85e
Parents: d4f7b71
Author: Rajeshbabu Chintaguntla 
Authored: Mon Feb 16 23:22:57 2015 +0530
Committer: Rajeshbabu Chintaguntla 
Committed: Mon Feb 16 23:22:57 2015 +0530

--
 .../phoenix/coprocessor/MetaDataProtocol.java   |  5 ++-
 .../hbase/index/master/IndexMasterObserver.java | 47 
 .../query/ConnectionQueryServicesImpl.java  | 33 +++---
 3 files changed, 78 insertions(+), 7 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/e09a8f8d/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataProtocol.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataProtocol.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataProtocol.java
index be5fb4d..cf0aabb 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataProtocol.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataProtocol.java
@@ -60,8 +60,8 @@ public abstract class MetaDataProtocol extends 
MetaDataService {
 
 public static final long MIN_TABLE_TIMESTAMP = 0;
 
-// Incremented from 5 to 6 with the addition of the STORE_NULLS table 
option in 4.3
-public static final long MIN_SYSTEM_TABLE_TIMESTAMP = MIN_TABLE_TIMESTAMP 
+ 6;
+// Incremented from 5 to 7 with the addition of the STORE_NULLS table 
option in 4.3
+public static final long MIN_SYSTEM_TABLE_TIMESTAMP = MIN_TABLE_TIMESTAMP 
+ 7;
 public static final int DEFAULT_MAX_META_DATA_VERSIONS = 1000;
 public static final int DEFAULT_MAX_STAT_DATA_VERSIONS = 3;
 public static final boolean DEFAULT_META_DATA_KEEP_DELETED_CELLS = true;
@@ -70,6 +70,7 @@ public abstract class MetaDataProtocol extends 
MetaDataService {
 public static final long MIN_SYSTEM_TABLE_TIMESTAMP_4_1_0 = 
MIN_TABLE_TIMESTAMP + 3;
 public static final long MIN_SYSTEM_TABLE_TIMESTAMP_4_2_0 = 
MIN_TABLE_TIMESTAMP + 4;
 public static final long MIN_SYSTEM_TABLE_TIMESTAMP_4_2_1 = 
MIN_TABLE_TIMESTAMP + 5;
+public static final long MIN_SYSTEM_TABLE_TIMESTAMP_4_3_0 = 
MIN_TABLE_TIMESTAMP + 7;
 
 // TODO: pare this down to minimum, as we don't need duplicates for both 
table and column errors, nor should we need
 // a different code for every type of error.

http://git-wip-us.apache.org/repos/asf/phoenix/blob/e09a8f8d/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/master/IndexMasterObserver.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/master/IndexMasterObserver.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/master/IndexMasterObserver.java
index dfb2c62..1da5aff 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/master/IndexMasterObserver.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/master/IndexMasterObserver.java
@@ -18,15 +18,22 @@
 package org.apache.phoenix.hbase.index.master;
 
 import java.io.IOException;
+import java.util.List;
 
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.HTableDescriptor;
+import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.coprocessor.BaseMasterObserver;
 import org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment;
 import org.apache.hadoop.hbase.coprocessor.ObserverContext;
+import org.apache.hadoop.hbase.master.AssignmentManager;
 import org.apache.hadoop.hbase.master.LoadBalancer;
+import org.apache.hadoop.hbase.master.RegionPlan;
+import org.apache.hadoop.hbase.master.RegionStates;
+import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.phoenix.hbase.index.balancer.IndexLoadBalancer;
+import org.apache.phoenix.util.MetaDataUtil;
 
 /**
  * Defines of coprocessor hooks(to support secondary indexing) of operations on
@@ -60,6 +67,46 @@ public class IndexMasterObserver extends BaseMasterObserver {
 }
 
 @Override
+public void 
preModifyTableHandler(ObserverContext ctx,
+TableName tableName, HTableDescriptor htd) throws IOException {
+HTableDescriptor oldDesc =
+
ctx.getEnvironment().getMasterServices().getTableDescriptors().get(tableName);
+if (oldDesc.getValue(IndexLoadBalancer.PARENT_TABLE_KEY) == null
+&& htd.g

[11/50] [abbrv] phoenix git commit: PHOENIX-514 Support functional indexes (Thomas D'Silva)

2015-03-04 Thread maryannxue
PHOENIX-514 Support functional indexes (Thomas D'Silva)


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/8c340f5a
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/8c340f5a
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/8c340f5a

Branch: refs/heads/calcite
Commit: 8c340f5a6c030d009a4fa75444096a1999aea5c5
Parents: d6e7846
Author: James Taylor 
Authored: Wed Feb 4 12:30:51 2015 -0800
Committer: James Taylor 
Committed: Wed Feb 4 12:30:51 2015 -0800

--
 .../org/apache/phoenix/end2end/HashJoinIT.java  |  12 +-
 .../apache/phoenix/end2end/PercentileIT.java|   7 +-
 .../java/org/apache/phoenix/end2end/ViewIT.java |   2 +-
 .../phoenix/end2end/index/ImmutableIndexIT.java |  76 +-
 .../end2end/index/IndexExpressionIT.java| 866 +++
 .../phoenix/end2end/index/IndexMetadataIT.java  |  20 +-
 phoenix-core/src/main/antlr3/PhoenixSQL.g   |  32 +-
 .../IndexHalfStoreFileReaderGenerator.java  |   4 +-
 .../apache/phoenix/compile/DeleteCompiler.java  |   4 +-
 .../phoenix/compile/ExpressionCompiler.java |   9 +-
 .../apache/phoenix/compile/FromCompiler.java|   6 +-
 .../apache/phoenix/compile/HavingCompiler.java  |   4 +-
 .../compile/IndexExpressionCompiler.java|  53 ++
 .../apache/phoenix/compile/JoinCompiler.java|   8 +-
 .../phoenix/compile/PostIndexDDLCompiler.java   |  47 +-
 .../apache/phoenix/compile/UpsertCompiler.java  |   2 +-
 .../apache/phoenix/compile/WhereCompiler.java   |   4 +-
 .../coprocessor/MetaDataEndpointImpl.java   |  44 +-
 .../UngroupedAggregateRegionObserver.java   |   3 +-
 .../coprocessor/generated/PTableProtos.java | 215 -
 .../phoenix/exception/SQLExceptionCode.java |   6 +
 .../apache/phoenix/execute/BaseQueryPlan.java   |   2 +-
 .../apache/phoenix/execute/MutationState.java   |   4 +-
 .../phoenix/expression/CoerceExpression.java|  10 +-
 .../expression/RowKeyColumnExpression.java  |   6 +-
 .../apache/phoenix/hbase/index/ValueGetter.java |   2 +
 .../index/covered/data/LazyValueGetter.java |   5 +
 .../hbase/index/util/IndexManagementUtil.java   |  18 -
 .../apache/phoenix/index/IndexMaintainer.java   | 333 ---
 .../apache/phoenix/index/PhoenixIndexCodec.java |   2 +-
 .../index/PhoenixIndexFailurePolicy.java|  21 +-
 .../phoenix/jdbc/PhoenixDatabaseMetaData.java   |   1 +
 .../apache/phoenix/jdbc/PhoenixStatement.java   |   9 +-
 .../apache/phoenix/optimize/QueryOptimizer.java |  12 +-
 .../apache/phoenix/parse/BetweenParseNode.java  |  22 +
 .../org/apache/phoenix/parse/BindParseNode.java |  22 +
 .../org/apache/phoenix/parse/CastParseNode.java |  38 +
 .../org/apache/phoenix/parse/ColumnDef.java |  14 +-
 .../org/apache/phoenix/parse/ColumnName.java|   2 +-
 .../apache/phoenix/parse/ColumnParseNode.java   |   1 +
 .../apache/phoenix/parse/CompoundParseNode.java |  32 +-
 .../phoenix/parse/CreateIndexStatement.java |  10 +-
 .../apache/phoenix/parse/ExistsParseNode.java   |  22 +
 .../phoenix/parse/FamilyWildcardParseNode.java  |  22 +
 .../apache/phoenix/parse/FunctionParseNode.java |  31 +
 .../apache/phoenix/parse/InListParseNode.java   |  22 +
 .../org/apache/phoenix/parse/InParseNode.java   |  25 +
 .../parse/IndexExpressionParseNodeRewriter.java | 104 +++
 .../phoenix/parse/IndexKeyConstraint.java   |  12 +-
 .../apache/phoenix/parse/IsNullParseNode.java   |  22 +
 .../org/apache/phoenix/parse/LikeParseNode.java |  26 +
 .../apache/phoenix/parse/LiteralParseNode.java  |  21 +
 .../org/apache/phoenix/parse/NamedNode.java |   2 +-
 .../apache/phoenix/parse/NamedParseNode.java|  30 +
 .../apache/phoenix/parse/ParseNodeFactory.java  |  34 +-
 .../phoenix/parse/SequenceValueParseNode.java   |  29 +
 .../apache/phoenix/parse/SubqueryParseNode.java |  28 +
 .../org/apache/phoenix/parse/TableName.java |   3 +-
 .../phoenix/parse/TableWildcardParseNode.java   |  29 +
 .../apache/phoenix/parse/WildcardParseNode.java |  24 +-
 .../apache/phoenix/schema/DelegateColumn.java   |   6 +
 .../apache/phoenix/schema/DelegateTable.java|   9 +-
 .../apache/phoenix/schema/MetaDataClient.java   | 173 ++--
 .../java/org/apache/phoenix/schema/PColumn.java |   3 +
 .../org/apache/phoenix/schema/PColumnImpl.java  |  26 +-
 .../apache/phoenix/schema/PMetaDataImpl.java|   2 +-
 .../java/org/apache/phoenix/schema/PTable.java  |   7 +-
 .../org/apache/phoenix/schema/PTableImpl.java   |  27 +-
 .../org/apache/phoenix/schema/SaltingUtil.java  |   2 +-
 .../phoenix/schema/tuple/ValueGetterTuple.java  |  93 ++
 .../java/org/apache/phoenix/util/IndexUtil.java |  15 +-
 .../expression/ColumnExpressionTest.java|   8 +-
 .../phoenix/index/IndexMaintainerTest.java  |  14 +-
 .../iterate/AggregateResultScannerTest.java |   5 +
 .../java/org/apache/phoenix/query/BaseTest.java |  26 +-
 phoenix-protocol/src/main/

[33/50] [abbrv] phoenix git commit: PHOENIX-1667 Update sqlline to 1.1.8

2015-03-04 Thread maryannxue
PHOENIX-1667 Update sqlline to 1.1.8


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/b8c0559c
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/b8c0559c
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/b8c0559c

Branch: refs/heads/calcite
Commit: b8c0559c0d1f7f5907ffab6dba43991929692b59
Parents: e09a8f8
Author: James Taylor 
Authored: Mon Feb 16 18:08:57 2015 -0800
Committer: James Taylor 
Committed: Mon Feb 16 18:08:57 2015 -0800

--
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/b8c0559c/pom.xml
--
diff --git a/pom.xml b/pom.xml
index 47363da..74a8a36 100644
--- a/pom.xml
+++ b/pom.xml
@@ -91,7 +91,7 @@
 2.5
 1.1.1
 1.0
-1.1.6
+1.1.8
 12.0.1
 1.8.8
 1.4.0



[01/50] [abbrv] phoenix git commit: PHOENIX-1612 Avoid context classloader issue

2015-03-04 Thread maryannxue
Repository: phoenix
Updated Branches:
  refs/heads/calcite 679571b19 -> 026f60b12


PHOENIX-1612 Avoid context classloader issue

Don't create a static HColumnDescriptor to avoid creating an
HBaseConfiguration from a static context. Making this change makes
it possible to run Phoenix via an external jar file in tools like
DBVisualier (instead of having to put Phoenix directly in the
application classpath).


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/d058a41c
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/d058a41c
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/d058a41c

Branch: refs/heads/calcite
Commit: d058a41c52c6a68c1581eff520c1f9e12486b89c
Parents: b12ddfa
Author: Gabriel Reid 
Authored: Wed Jan 28 20:30:33 2015 +0100
Committer: Gabriel Reid 
Committed: Thu Jan 29 11:04:58 2015 +0100

--
 .../org/apache/phoenix/query/ConnectionQueryServicesImpl.java| 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/d058a41c/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
index d545b2b..97efc43 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
@@ -200,8 +200,6 @@ public class ConnectionQueryServicesImpl extends 
DelegateQueryServices implement
 private volatile ConcurrentMap sequenceMap = 
Maps.newConcurrentMap();
 private KeyValueBuilder kvBuilder;
 
-private static final HColumnDescriptor defaultColDescriptor = new 
HColumnDescriptor(QueryConstants.DEFAULT_COLUMN_FAMILY_BYTES);
-
 private PMetaData newEmptyMetaData() {
 long maxSizeBytes = 
props.getLong(QueryServices.MAX_CLIENT_METADATA_CACHE_SIZE_ATTRIB,
 QueryServicesOptions.DEFAULT_MAX_CLIENT_METADATA_CACHE_SIZE);
@@ -1673,7 +1671,7 @@ public class ConnectionQueryServicesImpl extends 
DelegateQueryServices implement
 }
 
 private boolean isHColumnProperty(String propName) {
-return defaultColDescriptor.getValue(propName) != null;
+return HColumnDescriptor.getDefaultValues().containsKey(propName);
 }
 
 private boolean isHTableProperty(String propName) {



[29/50] [abbrv] phoenix git commit: PHOENIX-1654 Incorrect group-by keys from ClientAggregatePlan

2015-03-04 Thread maryannxue
PHOENIX-1654 Incorrect group-by keys from ClientAggregatePlan


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/fc299d5e
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/fc299d5e
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/fc299d5e

Branch: refs/heads/calcite
Commit: fc299d5e554cc5842fce96ece64058069fbea78c
Parents: e0a81a0
Author: maryannxue 
Authored: Thu Feb 12 15:39:23 2015 -0500
Committer: maryannxue 
Committed: Thu Feb 12 15:39:23 2015 -0500

--
 .../java/org/apache/phoenix/end2end/HashJoinIT.java   | 14 ++
 .../org/apache/phoenix/end2end/SortMergeJoinIT.java   | 14 ++
 .../apache/phoenix/execute/ClientAggregatePlan.java   |  2 +-
 3 files changed, 29 insertions(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/fc299d5e/phoenix-core/src/it/java/org/apache/phoenix/end2end/HashJoinIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/HashJoinIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/HashJoinIT.java
index 5d2f522..03686f0 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/HashJoinIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/HashJoinIT.java
@@ -2785,6 +2785,20 @@ public class HashJoinIT extends BaseHBaseManagedTimeIT {
 + "GROUP BY t1.TID, t1.A, t2.A");
 upsertStmt.execute();
 conn.commit();
+
+rs = statement.executeQuery("SELECT * FROM " + joinTable);
+assertTrue(rs.next());
+assertEquals(rs.getString(1), "1");
+assertEquals(rs.getInt(2), 1);
+assertEquals(rs.getInt(3), 2);
+assertEquals(rs.getInt(4), 2);
+assertTrue(rs.next());
+assertEquals(rs.getString(1), "1");
+assertEquals(rs.getInt(2), 2);
+assertEquals(rs.getInt(3), 1);
+assertEquals(rs.getInt(4), 2);
+
+assertFalse(rs.next());
 } finally {
 conn.close();
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/fc299d5e/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortMergeJoinIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortMergeJoinIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortMergeJoinIT.java
index 4503b5b..7912803 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortMergeJoinIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SortMergeJoinIT.java
@@ -1805,6 +1805,20 @@ public class SortMergeJoinIT extends 
BaseHBaseManagedTimeIT {
 + "GROUP BY t1.TID, t1.A, t2.A");
 upsertStmt.execute();
 conn.commit();
+
+rs = statement.executeQuery("SELECT * FROM " + joinTable);
+assertTrue(rs.next());
+assertEquals(rs.getString(1), "1");
+assertEquals(rs.getInt(2), 1);
+assertEquals(rs.getInt(3), 2);
+assertEquals(rs.getInt(4), 2);
+assertTrue(rs.next());
+assertEquals(rs.getString(1), "1");
+assertEquals(rs.getInt(2), 2);
+assertEquals(rs.getInt(3), 1);
+assertEquals(rs.getInt(4), 2);
+
+assertFalse(rs.next());
 } finally {
 conn.close();
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/fc299d5e/phoenix-core/src/main/java/org/apache/phoenix/execute/ClientAggregatePlan.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/execute/ClientAggregatePlan.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/execute/ClientAggregatePlan.java
index 59aab2d..30adbe9 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/execute/ClientAggregatePlan.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/execute/ClientAggregatePlan.java
@@ -101,7 +101,7 @@ public class ClientAggregatePlan extends 
ClientProcessingPlan {
 }
 iterator = new OrderedResultIterator(iterator, 
keyExpressionOrderBy, thresholdBytes, limit, 
projector.getEstimatedRowByteSize());
 }
-aggResultIterator = new 
ClientGroupedAggregatingResultIterator(LookAheadResultIterator.wrap(iterator), 
serverAggregators, groupBy.getExpressions());
+aggResultIterator = new 
ClientGroupedAggregatingResultIterator(LookAheadResultIterator.wrap(iterator), 
serverAggregators, groupBy.getKeyExpressions());
 aggResultIterator = new 
GroupedAggregatingResultIterator(LookAheadResultIterator.wrap(aggResultI

[37/50] [abbrv] phoenix git commit: PHOENIX-1680 phoenix-core/src/main/java/org/apache/phoenix/compile/QueryCompiler.java

2015-03-04 Thread maryannxue
PHOENIX-1680 
phoenix-core/src/main/java/org/apache/phoenix/compile/QueryCompiler.java


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/05723b19
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/05723b19
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/05723b19

Branch: refs/heads/calcite
Commit: 05723b19cc107b72d9f752cd0441af260fc62e22
Parents: 3d50147
Author: maryannxue 
Authored: Wed Feb 25 17:33:41 2015 -0500
Committer: maryannxue 
Committed: Wed Feb 25 17:33:41 2015 -0500

--
 .../org/apache/phoenix/end2end/HashJoinIT.java  | 90 
 .../apache/phoenix/end2end/SortMergeJoinIT.java | 78 -
 .../apache/phoenix/compile/QueryCompiler.java   | 37 
 3 files changed, 188 insertions(+), 17 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/05723b19/phoenix-core/src/it/java/org/apache/phoenix/end2end/HashJoinIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/HashJoinIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/HashJoinIT.java
index 03686f0..e915b36 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/HashJoinIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/HashJoinIT.java
@@ -41,6 +41,7 @@ import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.ResultSetMetaData;
 import java.sql.SQLException;
+import java.sql.Statement;
 import java.sql.Timestamp;
 import java.text.SimpleDateFormat;
 import java.util.Collection;
@@ -464,6 +465,21 @@ public class HashJoinIT extends BaseHBaseManagedTimeIT {
 "CLIENT PARALLEL 4-WAY FULL SCAN OVER 
TEMP_TABLE_COMPOSITE_PK\n" +
 "CLIENT MERGE SORT\n" +
 "DYNAMIC SERVER FILTER BY (COL0, COL1, COL2) IN 
((RHS.COL1, RHS.COL2, TO_INTEGER((RHS.COL3 - 1",
+/*
+ * testJoinWithSetMaxRows()
+ * statement.setMaxRows(4);
+ * SELECT order_id, i.name, quantity FROM joinItemTable i
+ * JOIN joinOrderTable o ON o.item_id = i.item_id;
+ * SELECT o.order_id, i.name, o.quantity FROM 
joinItemTable i
+ * JOIN (SELECT order_id, item_id, quantity FROM 
joinOrderTable) o
+ * ON o.item_id = i.item_id;
+ */
+"CLIENT PARALLEL 1-WAY FULL SCAN OVER " + 
JOIN_ITEM_TABLE_DISPLAY_NAME + "\n" +
+"CLIENT 4 ROW LIMIT\n" +
+"PARALLEL INNER-JOIN TABLE 0\n" +
+"CLIENT PARALLEL 1-WAY FULL SCAN OVER "+ 
JOIN_ORDER_TABLE_DISPLAY_NAME + "\n" +
+"DYNAMIC SERVER FILTER BY \"item_id\" IN 
(\"O.item_id\")\n" +
+"JOIN-SCANNER 4 ROW LIMIT",
 }});
 testCases.add(new String[][] {
 {
@@ -831,6 +847,21 @@ public class HashJoinIT extends BaseHBaseManagedTimeIT {
 "CLIENT PARALLEL 4-WAY FULL SCAN OVER 
TEMP_TABLE_COMPOSITE_PK\n" +
 "CLIENT MERGE SORT\n" +
 "DYNAMIC SERVER FILTER BY (COL0, COL1, COL2) IN 
((RHS.COL1, RHS.COL2, TO_INTEGER((RHS.COL3 - 1",
+/*
+ * testJoinWithSetMaxRows()
+ * statement.setMaxRows(4);
+ * SELECT order_id, i.name, quantity FROM joinItemTable i
+ * JOIN joinOrderTable o ON o.item_id = i.item_id;
+ * SELECT o.order_id, i.name, o.quantity FROM 
joinItemTable i
+ * JOIN (SELECT order_id, item_id, quantity FROM 
joinOrderTable) o
+ * ON o.item_id = i.item_id;
+ */
+"CLIENT PARALLEL 1-WAY FULL SCAN OVER "+ JOIN_SCHEMA + 
".idx_item\n" +
+"SERVER FILTER BY FIRST KEY ONLY\n" +
+"CLIENT 4 ROW LIMIT\n" +
+"PARALLEL INNER-JOIN TABLE 0\n" +
+"CLIENT PARALLEL 1-WAY FULL SCAN OVER "+ JOIN_SCHEMA + 
".OrderTable\n" +
+"JOIN-SCANNER 4 ROW LIMIT",
 }});
 testCases.add(new String[][] {
 {
@@ -1221,6 +1252,23 @@ public class HashJoinIT extends BaseHBaseManagedTimeIT {
 "CLIENT PARALLEL 4-WAY FULL SCAN OVER 
TEMP_TABLE_COMPOSITE_PK\n" +
 "CLIENT MERGE SORT\n" +
 "DYNAMIC SERVER FILTER BY (COL0, COL1, COL2) IN 
((RHS.COL1, RHS.COL2, TO_INTEGER((RHS.COL3 - 1",
+/*
+ * testJoinWithSetMaxRows()
+ * statement.setMaxRows(4);
+ * SELECT order_id, i.name, quantity FROM 

[31/50] [abbrv] phoenix git commit: Fix for TableNotFoundException when optimizing SELECT * FROM a tenant-specific table

2015-03-04 Thread maryannxue
Fix for TableNotFoundException when optimizing SELECT * FROM a tenant-specific 
table


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/d4f7b71a
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/d4f7b71a
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/d4f7b71a

Branch: refs/heads/calcite
Commit: d4f7b71a18859d201c3cab74acdff29702cddb76
Parents: f925a40
Author: Thomas D'Silva 
Authored: Tue Feb 10 21:06:43 2015 -0800
Committer: Thomas 
Committed: Thu Feb 12 13:10:18 2015 -0800

--
 .../index/GlobalIndexOptimizationIT.java|  2 +-
 .../phoenix/compile/ProjectionCompiler.java | 28 ++--
 2 files changed, 21 insertions(+), 9 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/d4f7b71a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/GlobalIndexOptimizationIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/GlobalIndexOptimizationIT.java
 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/GlobalIndexOptimizationIT.java
index e4ba2c6..7fb879e 100644
--- 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/GlobalIndexOptimizationIT.java
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/GlobalIndexOptimizationIT.java
@@ -105,7 +105,7 @@ public class GlobalIndexOptimizationIT extends 
BaseHBaseManagedTimeIT {
 conn1.commit();
 createIndex(TestUtil.DEFAULT_INDEX_TABLE_NAME, 
TestUtil.DEFAULT_DATA_TABLE_NAME, "v1");
 
-String query = "SELECT /*+ INDEX(" + 
TestUtil.DEFAULT_DATA_TABLE_NAME + " " + TestUtil.DEFAULT_INDEX_TABLE_NAME + 
")*/ t_id, k1, k2, k3, V1 FROM " + TestUtil.DEFAULT_DATA_TABLE_NAME +" where 
v1='a'";
+String query = "SELECT /*+ INDEX(" + 
TestUtil.DEFAULT_DATA_TABLE_NAME + " " + TestUtil.DEFAULT_INDEX_TABLE_NAME + 
")*/ * FROM " + TestUtil.DEFAULT_DATA_TABLE_NAME +" where v1='a'";
 ResultSet rs = conn1.createStatement().executeQuery("EXPLAIN "+ 
query);
 
 String expected = 

http://git-wip-us.apache.org/repos/asf/phoenix/blob/d4f7b71a/phoenix-core/src/main/java/org/apache/phoenix/compile/ProjectionCompiler.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/ProjectionCompiler.java 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/ProjectionCompiler.java
index 6b518b9..27fe0f9 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/ProjectionCompiler.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/ProjectionCompiler.java
@@ -74,6 +74,7 @@ import org.apache.phoenix.schema.PColumnFamily;
 import org.apache.phoenix.schema.PDatum;
 import org.apache.phoenix.schema.PName;
 import org.apache.phoenix.schema.PTable;
+import org.apache.phoenix.schema.TableNotFoundException;
 import org.apache.phoenix.schema.PTable.IndexType;
 import org.apache.phoenix.schema.PTable.ViewType;
 import org.apache.phoenix.schema.PTableKey;
@@ -170,24 +171,35 @@ public class ProjectionCompiler {
 PhoenixConnection conn = context.getConnection();
 PName tenantId = conn.getTenantId();
 String tableName = index.getParentName().getString();
-PTable table = conn.getMetaDataCache().getTable(new 
PTableKey(tenantId, tableName));
-int tableOffset = table.getBucketNum() == null ? 0 : 1;
-int minTablePKOffset = getMinPKOffset(table, tenantId);
+PTable dataTable = null;
+try {
+   dataTable = conn.getMetaDataCache().getTable(new 
PTableKey(tenantId, tableName));
+} catch (TableNotFoundException e) {
+if (tenantId != null) { 
+   // Check with null tenantId 
+   dataTable = conn.getMetaDataCache().getTable(new 
PTableKey(null, tableName));
+}
+else {
+   throw e;
+}
+}
+int tableOffset = dataTable.getBucketNum() == null ? 0 : 1;
+int minTablePKOffset = getMinPKOffset(dataTable, tenantId);
 int minIndexPKOffset = getMinPKOffset(index, tenantId);
 if (index.getIndexType() != IndexType.LOCAL) {
-if (index.getColumns().size()-minIndexPKOffset != 
table.getColumns().size()-minTablePKOffset) {
+if (index.getColumns().size()-minIndexPKOffset != 
dataTable.getColumns().size()-minTablePKOffset) {
 // We'll end up not using this by the optimizer, so just throw
 throw new 
ColumnNotFoundException(WildcardParseNode.INSTANCE.toString());
 }
 }
-for (int i = tableOffset, j = tableOffset; i < 
table.getColumns().size(); i++) {
-PCo

[03/50] [abbrv] phoenix git commit: PHOENIX-1596 Turning tracing on results in region server crash

2015-03-04 Thread maryannxue
PHOENIX-1596 Turning tracing on results in region server crash


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/a1baf2ac
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/a1baf2ac
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/a1baf2ac

Branch: refs/heads/calcite
Commit: a1baf2aca91099f1e21086cfca752776cce0
Parents: 1c58f44
Author: Samarth 
Authored: Fri Jan 30 15:08:44 2015 -0800
Committer: Samarth 
Committed: Fri Jan 30 15:08:44 2015 -0800

--
 .../coprocessor/BaseScannerRegionObserver.java  |  31 ++-
 .../org/apache/phoenix/hbase/index/Indexer.java | 225 +--
 .../org/apache/phoenix/trace/util/Tracing.java  |  67 +-
 3 files changed, 133 insertions(+), 190 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/a1baf2ac/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/BaseScannerRegionObserver.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/BaseScannerRegionObserver.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/BaseScannerRegionObserver.java
index 1647e5c..69cdcb6 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/BaseScannerRegionObserver.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/BaseScannerRegionObserver.java
@@ -47,11 +47,11 @@ import org.apache.phoenix.schema.KeyValueSchema;
 import org.apache.phoenix.schema.StaleRegionBoundaryCacheException;
 import org.apache.phoenix.schema.ValueBitSet;
 import org.apache.phoenix.schema.tuple.MultiKeyValueTuple;
-import org.apache.phoenix.trace.util.Tracing;
 import org.apache.phoenix.util.IndexUtil;
 import org.apache.phoenix.util.ScanUtil;
 import org.apache.phoenix.util.ServerUtil;
 import org.cloudera.htrace.Span;
+import org.cloudera.htrace.Trace;
 
 import com.google.common.collect.ImmutableList;
 
@@ -159,24 +159,39 @@ abstract public class BaseScannerRegionObserver extends 
BaseRegionObserver {
 return s;
 }
 boolean success =false;
-// turn on tracing, if its enabled
-final Span child = Tracing.childOnServer(scan, rawConf, 
SCANNER_OPENED_TRACE_INFO);
+// Save the current span. When done with the child span, reset the 
span back to
+// what it was. Otherwise, this causes the thread local storing 
the current span 
+// to not be reset back to null causing catastrophic infinite loops
+// and region servers to crash. See 
https://issues.apache.org/jira/browse/PHOENIX-1596
+// TraceScope can't be used here because closing the scope will 
end up calling 
+// currentSpan.stop() and that should happen only when we are 
closing the scanner.
+final Span savedSpan = Trace.currentSpan();
+final Span child = Trace.startSpan(SCANNER_OPENED_TRACE_INFO, 
savedSpan).getSpan();
 try {
 RegionScanner scanner = doPostScannerOpen(c, scan, s);
 scanner = new DelegateRegionScanner(scanner) {
+// This isn't very obvious but close() could be called in 
a thread
+// that is different from the thread that created the 
scanner.
 @Override
 public void close() throws IOException {
-if (child != null) {
-child.stop();
+try {
+delegate.close();
+} finally {
+if (child != null) {
+child.stop();
+}
 }
-delegate.close();
 }
 };
 success = true;
 return scanner;
 } finally {
-if (!success && child != null) {
-child.stop();
+try {
+if (!success && child != null) {
+child.stop();
+}
+} finally {
+Trace.continueSpan(savedSpan);
 }
 }
 } catch (Throwable t) {

http://git-wip-us.apache.org/repos/asf/phoenix/blob/a1baf2ac/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/Indexer.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/Indexer.java 
b/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/Indexer.java
index b841410..a4fc96b 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/hbase/index/Indexer.java
+++ b/phoenix-core/src/main/java/o

[39/50] [abbrv] phoenix git commit: Surface partial saves in CommitExcepiton (PHOENIX-900) from https://github.com/apache/phoenix/pull/37

2015-03-04 Thread maryannxue
Surface partial saves in CommitExcepiton (PHOENIX-900) from 
https://github.com/apache/phoenix/pull/37


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/fa58c782
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/fa58c782
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/fa58c782

Branch: refs/heads/calcite
Commit: fa58c7821a2e8fce30a8c0ff6e42aa00134dbce0
Parents: dab9d51
Author: Eli Levine 
Authored: Thu Feb 26 20:50:02 2015 -0800
Committer: Eli Levine 
Committed: Thu Feb 26 20:50:02 2015 -0800

--
 .../apache/phoenix/execute/PartialCommitIT.java | 302 +++
 .../apache/phoenix/compile/DeleteCompiler.java  |  13 +-
 .../apache/phoenix/compile/UpsertCompiler.java  |  13 +-
 .../apache/phoenix/execute/CommitException.java |  35 ++-
 .../apache/phoenix/execute/MutationState.java   | 156 ++
 .../apache/phoenix/jdbc/PhoenixConnection.java  |  37 ++-
 .../phoenix/jdbc/PhoenixPreparedStatement.java  |   7 +-
 .../apache/phoenix/jdbc/PhoenixStatement.java   |   3 +
 .../phoenix/execute/MutationStateTest.java  |  64 
 .../java/org/apache/phoenix/query/BaseTest.java |   2 +-
 10 files changed, 543 insertions(+), 89 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/fa58c782/phoenix-core/src/it/java/org/apache/phoenix/execute/PartialCommitIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/execute/PartialCommitIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/execute/PartialCommitIT.java
new file mode 100644
index 000..550d7de
--- /dev/null
+++ b/phoenix-core/src/it/java/org/apache/phoenix/execute/PartialCommitIT.java
@@ -0,0 +1,302 @@
+/*
+ * Copyright 2014 The Apache Software Foundation
+ *
+ * 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 maynot 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 applicablelaw 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.execute;
+
+import static com.google.common.collect.Lists.newArrayList;
+import static com.google.common.collect.Sets.newHashSet;
+import static java.util.Collections.singletonList;
+import static org.apache.phoenix.query.BaseTest.initAndRegisterDriver;
+import static org.apache.phoenix.query.BaseTest.setUpConfigForMiniCluster;
+import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL;
+import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR;
+import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL_TERMINATOR;
+import static 
org.apache.phoenix.util.PhoenixRuntime.PHOENIX_TEST_DRIVER_URL_PARAM;
+import static org.apache.phoenix.util.TestUtil.LOCALHOST;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.sql.Connection;
+import java.sql.Driver;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.DoNotRetryIOException;
+import org.apache.hadoop.hbase.HBaseIOException;
+import org.apache.hadoop.hbase.HBaseTestingUtility;
+import org.apache.hadoop.hbase.client.Durability;
+import org.apache.hadoop.hbase.client.Put;
+import org.apache.hadoop.hbase.coprocessor.ObserverContext;
+import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment;
+import org.apache.hadoop.hbase.coprocessor.RegionObserver;
+import org.apache.hadoop.hbase.coprocessor.SimpleRegionObserver;
+import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.phoenix.end2end.NeedsOwnMiniClusterTest;
+import org.apache.phoenix.hbase.index.Indexer;
+import org.apache.phoenix.hbase.index.util.ImmutableBytesPtr;
+import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.query.QueryServices;
+import org.apache.phoenix.schema.TableRef;
+import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.junit.A

[20/50] [abbrv] phoenix git commit: PHOENIX-1646 Views and functional index expressions may lose information when stringified

2015-03-04 Thread maryannxue
http://git-wip-us.apache.org/repos/asf/phoenix/blob/abeaa74a/phoenix-core/src/test/java/org/apache/phoenix/parse/QueryParserTest.java
--
diff --git 
a/phoenix-core/src/test/java/org/apache/phoenix/parse/QueryParserTest.java 
b/phoenix-core/src/test/java/org/apache/phoenix/parse/QueryParserTest.java
index 866365a..bf599ae 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/parse/QueryParserTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/parse/QueryParserTest.java
@@ -22,6 +22,7 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import java.io.IOException;
 import java.io.StringReader;
 import java.sql.SQLException;
 import java.sql.SQLFeatureNotSupportedException;
@@ -29,24 +30,43 @@ import java.util.List;
 
 import org.apache.hadoop.hbase.util.Pair;
 import org.apache.phoenix.exception.SQLExceptionCode;
+import org.apache.phoenix.jdbc.PhoenixStatement.Operation;
 import org.apache.phoenix.schema.SortOrder;
 import org.junit.Test;
 
 
 public class QueryParserTest {
+private void parseQuery(String sql) throws IOException, SQLException {
+SQLParser parser = new SQLParser(new StringReader(sql));
+BindableStatement stmt = null;
+stmt = parser.parseStatement();
+if (stmt.getOperation() != Operation.QUERY) {
+return;
+}
+String newSQL = stmt.toString();
+SQLParser newParser = new SQLParser(new StringReader(newSQL));
+BindableStatement newStmt = null;
+try {
+newStmt = newParser.parseStatement();
+} catch (SQLException e) {
+fail("Unable to parse new:\n" + newSQL);
+}
+assertEquals("Expected equality:\n" + sql + "\n" + newSQL, stmt, 
newStmt);
+}
+
 @Test
 public void testParsePreQuery0() throws Exception {
-SQLParser parser = new SQLParser(new StringReader(
+String sql = ((
 "select a from b\n" +
 "where ((ind.name = 'X')" +
 "and rownum <= (1000 + 1000))\n"
 ));
-parser.parseStatement();
+parseQuery(sql);
 }
 
 @Test
 public void testParsePreQuery1() throws Exception {
-SQLParser parser = new SQLParser(new StringReader(
+String sql = ((
 "select /*gatherSlowStats*/ count(1) from core.search_name_lookup 
ind\n" +
 "where( (ind.name = 'X'\n" +
 "and rownum <= 1 + 2)\n" +
@@ -54,12 +74,12 @@ public class QueryParserTest {
 "and (ind.key_prefix = '00T')\n" +
 "and (ind.name_type = 't'))"
 ));
-parser.parseStatement();
+parseQuery(sql);
 }
 
 @Test
 public void testParsePreQuery2() throws Exception {
-SQLParser parser = new SQLParser(new StringReader(
+String sql = ((
 "select /*gatherSlowStats*/ count(1) from core.custom_index_value 
ind\n" + 
 "where (ind.string_value in ('a', 'b', 'c', 'd'))\n" + 
 "and rownum <= ( 3 + 1 )\n" + 
@@ -68,12 +88,12 @@ public class QueryParserTest {
 "and (ind.deleted = '0')\n" + 
 "and (ind.index_num = 1)"
 ));
-parser.parseStatement();
+parseQuery(sql);
 }
 
 @Test
 public void testParsePreQuery3() throws Exception {
-SQLParser parser = new SQLParser(new StringReader(
+String sql = ((
 "select /*gatherSlowStats*/ count(1) from core.custom_index_value 
ind\n" + 
 "where (ind.number_value > 3)\n" + 
 "and rownum <= 1000\n" + 
@@ -82,54 +102,54 @@ public class QueryParserTest {
 "and (ind.deleted = '0'))\n" + 
 "and (ind.index_num = 2)"
 ));
-parser.parseStatement();
+parseQuery(sql);
 }
 
 @Test
 public void testParsePreQuery4() throws Exception {
-SQLParser parser = new SQLParser(new StringReader(
+String sql = ((
 "select /*+ index(t iecustom_entity_data_created) */ 
/*gatherSlowStats*/ count(1) from core.custom_entity_data t\n" + 
 "where (t.created_date > to_date('01/01/2001'))\n" + 
 "and rownum <= 4500\n" + 
 "and (t.organization_id = '000')\n" + 
 "and (t.key_prefix = '001')"
 ));
-parser.parseStatement();
+parseQuery(sql);
 }
 
 @Test
 public void testCountDistinctQuery() throws Exception {
-SQLParser parser = new SQLParser(new StringReader(
+String sql = ((
 "select count(distinct foo) from core.custom_entity_data t\n"
 + "where (t.created_date > to_date('01/01/2001'))\n"
 + "and (t.organization_id = '000')\n"
 + "and (t.key_prefix = '001')\n" + "limit 4500"));
-parser.parseStat

[07/50] [abbrv] phoenix git commit: PHOENIX-1248 CsvBulkLoadTool is failing with IAE when local index specified for --index-table parameter(Gabriel Reid)

2015-03-04 Thread maryannxue
PHOENIX-1248 CsvBulkLoadTool is failing with IAE when local index specified for 
--index-table parameter(Gabriel Reid)


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/d6e7846f
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/d6e7846f
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/d6e7846f

Branch: refs/heads/calcite
Commit: d6e7846f491e09780a2d663cc5c23bc21244e26c
Parents: 3f48938
Author: Rajeshbabu Chintaguntla 
Authored: Sun Feb 1 09:28:29 2015 -0800
Committer: Rajeshbabu Chintaguntla 
Committed: Sun Feb 1 09:28:29 2015 -0800

--
 .../phoenix/mapreduce/CsvBulkLoadToolIT.java| 79 ++
 .../phoenix/mapreduce/CsvBulkLoadTool.java  | 85 ++--
 .../phoenix/mapreduce/CsvToKeyValueMapper.java  |  3 +-
 3 files changed, 126 insertions(+), 41 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/d6e7846f/phoenix-core/src/it/java/org/apache/phoenix/mapreduce/CsvBulkLoadToolIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/mapreduce/CsvBulkLoadToolIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/mapreduce/CsvBulkLoadToolIT.java
index 4373f47..0501142 100644
--- 
a/phoenix-core/src/it/java/org/apache/phoenix/mapreduce/CsvBulkLoadToolIT.java
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/mapreduce/CsvBulkLoadToolIT.java
@@ -17,12 +17,6 @@
  */
 package org.apache.phoenix.mapreduce;
 
-import static org.apache.phoenix.query.BaseTest.setUpConfigForMiniCluster;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
 import java.io.PrintWriter;
 import java.sql.Connection;
 import java.sql.DriverManager;
@@ -42,6 +36,12 @@ import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
+import static org.apache.phoenix.query.BaseTest.setUpConfigForMiniCluster;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
 @Category(NeedsOwnMiniClusterTest.class)
 public class CsvBulkLoadToolIT {
 
@@ -191,17 +191,62 @@ public class CsvBulkLoadToolIT {
 rs.close();
 stmt.close();
 }
-
+
 @Test
-public void testImportOneIndexTable() throws Exception {
+public void testImportWithLocalIndex() throws Exception {
 
 Statement stmt = conn.createStatement();
-stmt.execute("CREATE TABLE TABLE4 (ID INTEGER NOT NULL PRIMARY KEY, " +
-"FIRST_NAME VARCHAR, LAST_NAME VARCHAR)");
-String ddl = "CREATE INDEX TABLE4_IDX ON TABLE4 "
+stmt.execute("CREATE TABLE TABLE6 (ID INTEGER NOT NULL PRIMARY KEY, " +
+"FIRST_NAME VARCHAR, LAST_NAME VARCHAR)");
+String ddl = "CREATE LOCAL INDEX TABLE6_IDX ON TABLE6 "
 + " (FIRST_NAME ASC)";
 stmt.execute(ddl);
-
+
+FileSystem fs = FileSystem.get(hbaseTestUtil.getConfiguration());
+FSDataOutputStream outputStream = fs.create(new 
Path("/tmp/input3.csv"));
+PrintWriter printWriter = new PrintWriter(outputStream);
+printWriter.println("1,FirstName 1,LastName 1");
+printWriter.println("2,FirstName 2,LastName 2");
+printWriter.close();
+
+CsvBulkLoadTool csvBulkLoadTool = new CsvBulkLoadTool();
+csvBulkLoadTool.setConf(hbaseTestUtil.getConfiguration());
+int exitCode = csvBulkLoadTool.run(new String[] {
+"--input", "/tmp/input3.csv",
+"--table", "table6",
+"--zookeeper", zkQuorum});
+assertEquals(0, exitCode);
+
+ResultSet rs = stmt.executeQuery("SELECT id, FIRST_NAME FROM TABLE6 
where first_name='FirstName 2'");
+assertTrue(rs.next());
+assertEquals(2, rs.getInt(1));
+assertEquals("FirstName 2", rs.getString(2));
+
+rs.close();
+stmt.close();
+}
+
+@Test
+public void testImportOneIndexTable() throws Exception {
+testImportOneIndexTable("TABLE4", false);
+}
+
+@Test
+public void testImportOneLocalIndexTable() throws Exception {
+testImportOneIndexTable("TABLE5", true);
+}
+
+public void testImportOneIndexTable(String tableName, boolean localIndex) 
throws Exception {
+
+String indexTableName = String.format("%s_IDX", tableName);
+Statement stmt = conn.createStatement();
+stmt.execute("CREATE TABLE " + tableName + "(ID INTEGER NOT NULL 
PRIMARY KEY, "
++ "FIRST_NAME VARCHAR, LAST_NAME VARCHAR)");
+String ddl =
+"CREATE

[15/50] [abbrv] phoenix git commit: PHOENIX-1643 Ensure index usage is backward compatible for 4.2 client against 4.3 server (Thomas D'Silva)

2015-03-04 Thread maryannxue
PHOENIX-1643 Ensure index usage is backward compatible for 4.2 client against 
4.3 server (Thomas D'Silva)


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/9db37bd9
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/9db37bd9
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/9db37bd9

Branch: refs/heads/calcite
Commit: 9db37bd90005695c703f9d092651891a5e39a80a
Parents: 54c4ed8
Author: James Taylor 
Authored: Fri Feb 6 16:08:43 2015 -0800
Committer: James Taylor 
Committed: Fri Feb 6 16:08:43 2015 -0800

--
 .../apache/phoenix/index/IndexMaintainer.java   |  9 ++--
 .../parse/IndexExpressionParseNodeRewriter.java |  6 ++---
 .../org/apache/phoenix/schema/PColumnImpl.java  |  2 +-
 .../java/org/apache/phoenix/util/IndexUtil.java | 16 +++--
 .../org/apache/phoenix/util/SchemaUtil.java | 24 
 5 files changed, 29 insertions(+), 28 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/9db37bd9/phoenix-core/src/main/java/org/apache/phoenix/index/IndexMaintainer.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/index/IndexMaintainer.java 
b/phoenix-core/src/main/java/org/apache/phoenix/index/IndexMaintainer.java
index 31f6c76..7199dad 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/index/IndexMaintainer.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/index/IndexMaintainer.java
@@ -282,9 +282,6 @@ public class IndexMaintainer implements Writable, 
Iterable {
 int indexedExpressionCount = 0;
 for (int i = indexPosOffset; i {
 IndexExpressionCompiler expressionIndexCompiler = new 
IndexExpressionCompiler(context);
 for (int i = indexPosOffset; i < index.getPKColumns().size(); i++) {
 PColumn indexColumn = index.getPKColumns().get(i);
-if (!IndexUtil.isIndexColumn(indexColumn)) {
-continue;
-}
 int indexPos = i - indexPosOffset;
 Expression expression = null;
 try {
 expressionIndexCompiler.reset();
-ParseNode parseNode  = 
SQLParser.parseCondition(indexColumn.getExpressionStr());
+String expressionStr = 
IndexUtil.getIndexColumnExpressionStr(indexColumn);
+ParseNode parseNode  = SQLParser.parseCondition(expressionStr);
 expression = parseNode.accept(expressionIndexCompiler);
 } catch (SQLException e) {
 throw new RuntimeException(e); // Impossible

http://git-wip-us.apache.org/repos/asf/phoenix/blob/9db37bd9/phoenix-core/src/main/java/org/apache/phoenix/parse/IndexExpressionParseNodeRewriter.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/parse/IndexExpressionParseNodeRewriter.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/parse/IndexExpressionParseNodeRewriter.java
index efa3835..43cb9f3 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/parse/IndexExpressionParseNodeRewriter.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/parse/IndexExpressionParseNodeRewriter.java
@@ -71,10 +71,8 @@ public class IndexExpressionParseNodeRewriter extends 
ParseNodeRewriter {
 List pkColumns = index.getPKColumns();
for (int i=indexPosOffset; ihttp://git-wip-us.apache.org/repos/asf/phoenix/blob/9db37bd9/phoenix-core/src/main/java/org/apache/phoenix/schema/PColumnImpl.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/schema/PColumnImpl.java 
b/phoenix-core/src/main/java/org/apache/phoenix/schema/PColumnImpl.java
index 11cc53d..ac044df 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/PColumnImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/PColumnImpl.java
@@ -38,7 +38,7 @@ public class PColumnImpl implements PColumn {
 private byte[] viewConstant;
 private boolean isViewReferenced;
 private String expressionStr;
-
+
 public PColumnImpl() {
 }
 

http://git-wip-us.apache.org/repos/asf/phoenix/blob/9db37bd9/phoenix-core/src/main/java/org/apache/phoenix/util/IndexUtil.java
--
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/IndexUtil.java 
b/phoenix-core/src/main/java/org/apache/phoenix/util/IndexUtil.java
index 8dd4f4d..c058eb8 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/IndexUtil.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/IndexUtil.java
@@ -137,12 +137,9 @@ public class IndexUtil {
 return name.substring(0,name.indexOf(INDEX_COLUM

[40/50] [abbrv] phoenix git commit: Revert "Surface partial saves in CommitExcepiton (PHOENIX-900) from https://github.com/apache/phoenix/pull/37"

2015-03-04 Thread maryannxue
Revert "Surface partial saves in CommitExcepiton (PHOENIX-900) from 
https://github.com/apache/phoenix/pull/37";

This reverts commit fa58c7821a2e8fce30a8c0ff6e42aa00134dbce0.


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/569469a4
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/569469a4
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/569469a4

Branch: refs/heads/calcite
Commit: 569469a46bae57cc4d6cbbcd7e01d535560f07e2
Parents: fa58c78
Author: Eli Levine 
Authored: Fri Feb 27 11:15:28 2015 -0800
Committer: Eli Levine 
Committed: Fri Feb 27 11:15:28 2015 -0800

--
 .../apache/phoenix/execute/PartialCommitIT.java | 302 ---
 .../apache/phoenix/compile/DeleteCompiler.java  |  13 +-
 .../apache/phoenix/compile/UpsertCompiler.java  |  13 +-
 .../apache/phoenix/execute/CommitException.java |  35 +--
 .../apache/phoenix/execute/MutationState.java   | 156 --
 .../apache/phoenix/jdbc/PhoenixConnection.java  |  37 +--
 .../phoenix/jdbc/PhoenixPreparedStatement.java  |   7 +-
 .../apache/phoenix/jdbc/PhoenixStatement.java   |   3 -
 .../phoenix/execute/MutationStateTest.java  |  64 
 .../java/org/apache/phoenix/query/BaseTest.java |   2 +-
 10 files changed, 89 insertions(+), 543 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/569469a4/phoenix-core/src/it/java/org/apache/phoenix/execute/PartialCommitIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/execute/PartialCommitIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/execute/PartialCommitIT.java
deleted file mode 100644
index 550d7de..000
--- a/phoenix-core/src/it/java/org/apache/phoenix/execute/PartialCommitIT.java
+++ /dev/null
@@ -1,302 +0,0 @@
-/*
- * Copyright 2014 The Apache Software Foundation
- *
- * 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 maynot 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 applicablelaw 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.execute;
-
-import static com.google.common.collect.Lists.newArrayList;
-import static com.google.common.collect.Sets.newHashSet;
-import static java.util.Collections.singletonList;
-import static org.apache.phoenix.query.BaseTest.initAndRegisterDriver;
-import static org.apache.phoenix.query.BaseTest.setUpConfigForMiniCluster;
-import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL;
-import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR;
-import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL_TERMINATOR;
-import static 
org.apache.phoenix.util.PhoenixRuntime.PHOENIX_TEST_DRIVER_URL_PARAM;
-import static org.apache.phoenix.util.TestUtil.LOCALHOST;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import java.sql.Connection;
-import java.sql.Driver;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.DoNotRetryIOException;
-import org.apache.hadoop.hbase.HBaseIOException;
-import org.apache.hadoop.hbase.HBaseTestingUtility;
-import org.apache.hadoop.hbase.client.Durability;
-import org.apache.hadoop.hbase.client.Put;
-import org.apache.hadoop.hbase.coprocessor.ObserverContext;
-import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment;
-import org.apache.hadoop.hbase.coprocessor.RegionObserver;
-import org.apache.hadoop.hbase.coprocessor.SimpleRegionObserver;
-import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
-import org.apache.hadoop.hbase.util.Bytes;
-import org.apache.phoenix.end2end.NeedsOwnMiniClusterTest;
-import org.apache.phoenix.hbase.index.Indexer;
-import org.apache.phoenix.hbase.index.util.ImmutableBytesPtr;
-import org.apache.phoenix.jdbc.PhoenixConnection;
-import org.apache.phoenix.query.QueryServices;
-import org.apache.phoenix.schema.TableRef;
-import org.apache.phoenix.util.Phoen

[12/50] [abbrv] phoenix git commit: PHOENIX-1142 Improve CsvBulkLoadTool to parse different Date formats

2015-03-04 Thread maryannxue
PHOENIX-1142 Improve CsvBulkLoadTool to parse different Date formats


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/2d770333
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/2d770333
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/2d770333

Branch: refs/heads/calcite
Commit: 2d7703339f87c73625d251fe3322f839cc1ee791
Parents: 8c340f5
Author: Jeffrey Zhong 
Authored: Mon Feb 2 22:33:04 2015 -0800
Committer: Jeffrey Zhong 
Committed: Fri Feb 6 14:08:15 2015 -0800

--
 .../phoenix/end2end/ProductMetricsIT.java   |   7 +-
 .../phoenix/end2end/ToDateFunctionIT.java   |  15 ++
 .../phoenix/end2end/TruncateFunctionIT.java |   5 +-
 .../apache/phoenix/end2end/UpsertValuesIT.java  |  63 ++--
 .../phoenix/end2end/VariableLengthPKIT.java |   7 +-
 .../phoenix/mapreduce/CsvBulkLoadToolIT.java|  21 ++-
 .../phoenix/expression/LiteralExpression.java   |   9 +-
 .../expression/function/ToDateFunction.java |  17 +--
 .../apache/phoenix/parse/ToDateParseNode.java   |  10 +-
 .../org/apache/phoenix/schema/types/PDate.java  |   5 +-
 .../org/apache/phoenix/schema/types/PTime.java  |   2 +
 .../apache/phoenix/schema/types/PTimestamp.java |   2 +
 .../java/org/apache/phoenix/util/DateUtil.java  | 147 +--
 .../phoenix/util/csv/CsvUpsertExecutor.java |  35 -
 .../util/csv/StringToArrayConverter.java|  24 +--
 .../phoenix/compile/WhereCompilerTest.java  |   3 +-
 .../org/apache/phoenix/util/DateUtilTest.java   |  28 ++--
 17 files changed, 265 insertions(+), 135 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/2d770333/phoenix-core/src/it/java/org/apache/phoenix/end2end/ProductMetricsIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ProductMetricsIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ProductMetricsIT.java
index cd436e5..975541e 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ProductMetricsIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ProductMetricsIT.java
@@ -57,7 +57,6 @@ import com.google.common.collect.Ordering;
 
 
 public class ProductMetricsIT extends BaseClientManagedTimeIT {
-private static Format format = 
DateUtil.getDateParser(DateUtil.DEFAULT_DATE_FORMAT);
 private static final String PRODUCT_METRICS_NAME = "PRODUCT_METRICS";
 private static final String PRODUCT_METRICS_SCHEMA_NAME = "";
 private static final String DS1 = "1970-01-01 00:58:00";
@@ -88,11 +87,7 @@ public class ProductMetricsIT extends 
BaseClientManagedTimeIT {
 }
 
 private static Date toDate(String dateString) {
-try {
-return (Date)format.parseObject(dateString);
-} catch (ParseException e) {
-throw new RuntimeException(e);
-}
+return DateUtil.parseDateTime(dateString);
 }
 
 private static void initTable(byte[][] splits, long ts) throws Exception {

http://git-wip-us.apache.org/repos/asf/phoenix/blob/2d770333/phoenix-core/src/it/java/org/apache/phoenix/end2end/ToDateFunctionIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ToDateFunctionIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ToDateFunctionIT.java
index 19257c1..984e21b 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ToDateFunctionIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ToDateFunctionIT.java
@@ -27,12 +27,14 @@ import java.sql.Statement;
 import java.util.Properties;
 
 import org.apache.phoenix.query.QueryServices;
+import org.apache.phoenix.util.DateUtil;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 
 public class ToDateFunctionIT extends BaseHBaseManagedTimeIT {
@@ -69,6 +71,19 @@ public class ToDateFunctionIT extends BaseHBaseManagedTimeIT 
{
 public void testToDate_Default() throws SQLException {
 // Default time zone is GMT, so this is timestamp 0
 assertEquals(0L, callToDateFunction("TO_DATE('1970-01-01 
00:00:00')").getTime());
+assertEquals(0L, callToDateFunction("TO_DATE('1970-01-01 
00:00:00.000')").getTime());
+assertEquals(0L, 
callToDateFunction("TO_DATE('1970-01-01')").getTime());
+assertEquals(0L, 
callToDateFunction("TO_DATE('1970/01/01','/MM/dd')").getTime());
+
+// Test other ISO 8601 Date Compliant Formats to verify they can be 
parsed
+try {
+callToDateFunction("TO_DATE('2015-01-27T16:17:57+00:00')");
+callToDateFun

[17/50] [abbrv] phoenix git commit: PHOENIX-1142 Fix compiler errors and warnings from original checkin

2015-03-04 Thread maryannxue
PHOENIX-1142 Fix compiler errors and warnings from original checkin


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/47ca5958
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/47ca5958
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/47ca5958

Branch: refs/heads/calcite
Commit: 47ca5958a2334bef35da0d9ff938e0420a79b321
Parents: eaa7fbf
Author: James Taylor 
Authored: Fri Feb 6 18:12:49 2015 -0800
Committer: James Taylor 
Committed: Fri Feb 6 18:12:49 2015 -0800

--
 .../main/java/org/apache/phoenix/util/DateUtil.java  |  5 +
 .../java/org/apache/phoenix/util/DateUtilTest.java   | 15 +++
 2 files changed, 8 insertions(+), 12 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/47ca5958/phoenix-core/src/main/java/org/apache/phoenix/util/DateUtil.java
--
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/DateUtil.java 
b/phoenix-core/src/main/java/org/apache/phoenix/util/DateUtil.java
index 659f45e..fbc74ba 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/DateUtil.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/DateUtil.java
@@ -155,10 +155,6 @@ public class DateUtil {
 private String datePattern;
 private SimpleDateFormat parser;
 
-public SimpleDateFormatParser(String pattern) {
-this(pattern, DEFAULT_TIME_ZONE);
-}
-
 public SimpleDateFormatParser(String pattern, TimeZone timeZone) {
 datePattern = pattern;
 parser = new SimpleDateFormat(pattern) {
@@ -171,6 +167,7 @@ public class DateUtil {
 parser.setTimeZone(timeZone);
 }
 
+@Override
 public Date parseDateTime(String dateTimeString) throws 
IllegalDataException {
 try {
 java.util.Date date =parser.parse(dateTimeString);

http://git-wip-us.apache.org/repos/asf/phoenix/blob/47ca5958/phoenix-core/src/test/java/org/apache/phoenix/util/DateUtilTest.java
--
diff --git 
a/phoenix-core/src/test/java/org/apache/phoenix/util/DateUtilTest.java 
b/phoenix-core/src/test/java/org/apache/phoenix/util/DateUtilTest.java
index 1cca156..702e556 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/util/DateUtilTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/util/DateUtilTest.java
@@ -17,6 +17,10 @@
  */
 package org.apache.phoenix.util;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
 import java.sql.Date;
 import java.sql.Time;
 import java.sql.Timestamp;
@@ -26,11 +30,6 @@ import java.util.TimeZone;
 import org.apache.phoenix.schema.IllegalDataException;
 import org.junit.Test;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
 /**
  * Test class for {@link DateUtil}
  *
@@ -69,20 +68,20 @@ public class DateUtilTest {
 
 @Test
 public void testGetDateParser_DefaultTimeZone() throws ParseException {
-Date date = (Date) 
DateUtil.getDateParser("-MM-dd").parseDateTime("1970-01-01");
+Date date = 
DateUtil.getDateParser("-MM-dd").parseDateTime("1970-01-01");
 assertEquals(0, date.getTime());
 }
 
 @Test
 public void testGetDateParser_CustomTimeZone() throws ParseException {
-Date date = (Date) DateUtil.getDateParser(
+Date date = DateUtil.getDateParser(
 "-MM-dd", 
TimeZone.getTimeZone("GMT+1")).parseDateTime("1970-01-01");
 assertEquals(-ONE_HOUR_IN_MILLIS, date.getTime());
 }
 
 @Test
 public void testGetDateParser_LocalTimeZone() throws ParseException {
-Date date = (Date) DateUtil.getDateParser(
+Date date = DateUtil.getDateParser(
 "-MM-dd", 
TimeZone.getDefault()).parseDateTime("1970-01-01");
 assertEquals(Date.valueOf("1970-01-01"), date);
 }



[23/50] [abbrv] phoenix git commit: PHOENIX-688 Add to_time and to_timestamp built-in functions

2015-03-04 Thread maryannxue
PHOENIX-688 Add to_time and to_timestamp built-in functions


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/11a76b29
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/11a76b29
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/11a76b29

Branch: refs/heads/calcite
Commit: 11a76b297fad46cd7f51019810ba4d1a7b51b418
Parents: 78d91d1
Author: James Taylor 
Authored: Sat Feb 7 23:54:53 2015 -0800
Committer: James Taylor 
Committed: Mon Feb 9 18:37:14 2015 -0800

--
 .../phoenix/end2end/ProductMetricsIT.java   |   4 +-
 .../phoenix/end2end/ToDateFunctionIT.java   |  67 +-
 .../phoenix/end2end/TruncateFunctionIT.java |   5 +-
 .../apache/phoenix/end2end/UpsertValuesIT.java  |   6 +-
 .../phoenix/end2end/VariableLengthPKIT.java |   3 +-
 .../phoenix/mapreduce/CsvBulkLoadToolIT.java|  10 +-
 .../phoenix/compile/StatementContext.java   |  28 ++-
 .../phoenix/expression/ExpressionType.java  |  10 +-
 .../expression/function/ToDateFunction.java |  93 ++--
 .../expression/function/ToTimeFunction.java |  63 ++
 .../function/ToTimestampFunction.java   |  63 ++
 .../apache/phoenix/jdbc/PhoenixConnection.java  |  20 +-
 .../apache/phoenix/parse/ToDateParseNode.java   |   6 +-
 .../apache/phoenix/parse/ToTimeParseNode.java   |  48 +
 .../phoenix/parse/ToTimestampParseNode.java |  48 +
 .../org/apache/phoenix/query/QueryServices.java |   3 +
 .../org/apache/phoenix/schema/types/PDate.java  |  12 +-
 .../org/apache/phoenix/schema/types/PTime.java  |  16 +-
 .../apache/phoenix/schema/types/PTimestamp.java |  24 +--
 .../java/org/apache/phoenix/util/DateUtil.java  | 213 +--
 .../phoenix/util/csv/CsvUpsertExecutor.java |  52 +++--
 .../phoenix/compile/WhereCompilerTest.java  |   8 +-
 .../expression/SortOrderExpressionTest.java |  34 +--
 .../org/apache/phoenix/util/DateUtilTest.java   |  35 +--
 24 files changed, 656 insertions(+), 215 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/11a76b29/phoenix-core/src/it/java/org/apache/phoenix/end2end/ProductMetricsIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ProductMetricsIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ProductMetricsIT.java
index 975541e..ddc5fab 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ProductMetricsIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ProductMetricsIT.java
@@ -31,8 +31,6 @@ import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
 import java.sql.Types;
-import java.text.Format;
-import java.text.ParseException;
 import java.util.Collections;
 import java.util.List;
 import java.util.Properties;
@@ -87,7 +85,7 @@ public class ProductMetricsIT extends BaseClientManagedTimeIT 
{
 }
 
 private static Date toDate(String dateString) {
-return DateUtil.parseDateTime(dateString);
+return DateUtil.parseDate(dateString);
 }
 
 private static void initTable(byte[][] splits, long ts) throws Exception {

http://git-wip-us.apache.org/repos/asf/phoenix/blob/11a76b29/phoenix-core/src/it/java/org/apache/phoenix/end2end/ToDateFunctionIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ToDateFunctionIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ToDateFunctionIT.java
index 984e21b..bda4ea5 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ToDateFunctionIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ToDateFunctionIT.java
@@ -18,24 +18,25 @@
 
 package org.apache.phoenix.end2end;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 import java.sql.Connection;
 import java.sql.Date;
 import java.sql.DriverManager;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
+import java.sql.Time;
+import java.sql.Timestamp;
 import java.util.Properties;
 
 import org.apache.phoenix.query.QueryServices;
-import org.apache.phoenix.util.DateUtil;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
 
 public class ToDateFunctionIT extends BaseHBaseManagedTimeIT {
 
@@ -53,18 +54,26 @@ public class ToDateFunctionIT extends 
BaseHBaseManagedTimeIT {
 conn.close();
 }
 
-private static Date callToDateFunction(Connection conn, String invocation) 
throws SQLException {
+private static java.util.Date callToDa

[10/50] [abbrv] phoenix git commit: PHOENIX-514 Support functional indexes (Thomas D'Silva)

2015-03-04 Thread maryannxue
http://git-wip-us.apache.org/repos/asf/phoenix/blob/8c340f5a/phoenix-core/src/main/java/org/apache/phoenix/compile/PostIndexDDLCompiler.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/PostIndexDDLCompiler.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/PostIndexDDLCompiler.java
index 2ea42ce..c8cf28e 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/PostIndexDDLCompiler.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/PostIndexDDLCompiler.java
@@ -22,7 +22,6 @@ import java.util.List;
 
 import org.apache.phoenix.jdbc.PhoenixConnection;
 import org.apache.phoenix.jdbc.PhoenixStatement;
-import org.apache.phoenix.schema.ColumnNotFoundException;
 import org.apache.phoenix.schema.PColumn;
 import org.apache.phoenix.schema.PColumnFamily;
 import org.apache.phoenix.schema.PTable;
@@ -56,35 +55,37 @@ public class PostIndexDDLCompiler {
 //   that would allow the user to easily monitor the process of index 
creation.
 StringBuilder indexColumns = new StringBuilder();
 StringBuilder dataColumns = new StringBuilder();
-List dataPKColumns = dataTableRef.getTable().getPKColumns();
-PTable dataTable = dataTableRef.getTable();
-int nPKColumns = dataPKColumns.size();
-boolean isSalted = dataTable.getBucketNum() != null;
-boolean isMultiTenant = connection.getTenantId() != null && 
dataTable.isMultiTenant();
-int posOffset = (isSalted ? 1 : 0) + (isMultiTenant ? 1 : 0);
-for (int i = posOffset; i < nPKColumns; i++) {
-PColumn col = dataPKColumns.get(i);
-if (col.getViewConstant() == null) {
-String indexColName = IndexUtil.getIndexColumnName(col);
-dataColumns.append('"').append(col.getName()).append("\",");
-indexColumns.append('"').append(indexColName).append("\",");
-}
+
+// Add the pk index columns
+List indexPKColumns = indexTable.getPKColumns();
+int nIndexPKColumns = indexTable.getPKColumns().size();
+boolean isSalted = indexTable.getBucketNum() != null;
+boolean isMultiTenant = connection.getTenantId() != null && 
indexTable.isMultiTenant();
+boolean isViewIndex = indexTable.getViewIndexId()!=null;
+int posOffset = (isSalted ? 1 : 0) + (isMultiTenant ? 1 : 0) + 
(isViewIndex ? 1 : 0);
+for (int i = posOffset; i < nIndexPKColumns; i++) {
+PColumn col = indexPKColumns.get(i);
+String indexColName = col.getName().getString();
+dataColumns.append(col.getExpressionStr()).append(",");
+indexColumns.append('"').append(indexColName).append("\",");
 }
-for (PColumnFamily family : 
dataTableRef.getTable().getColumnFamilies()) {
+
+// Add the covered columns
+for (PColumnFamily family : indexTable.getColumnFamilies()) {
 for (PColumn col : family.getColumns()) {
 if (col.getViewConstant() == null) {
-String indexColName = IndexUtil.getIndexColumnName(col);
-try {
-indexTable.getColumn(indexColName);
-
dataColumns.append('"').append(col.getFamilyName()).append("\".");
-
dataColumns.append('"').append(col.getName()).append("\",");
-
indexColumns.append('"').append(indexColName).append("\",");
-} catch (ColumnNotFoundException e) {
-// Catch and ignore - means that this data column is 
not in the index
+String indexColName = col.getName().getString();
+String dataFamilyName = 
IndexUtil.getDataColumnFamilyName(indexColName);
+String dataColumnName = 
IndexUtil.getDataColumnName(indexColName);
+if (!dataFamilyName.equals("")) {
+
dataColumns.append('"').append(dataFamilyName).append("\".");
 }
+
dataColumns.append('"').append(dataColumnName).append("\",");
+
indexColumns.append('"').append(indexColName).append("\",");
 }
 }
 }
+
 dataColumns.setLength(dataColumns.length()-1);
 indexColumns.setLength(indexColumns.length()-1);
 String schemaName = 
dataTableRef.getTable().getSchemaName().getString();

http://git-wip-us.apache.org/repos/asf/phoenix/blob/8c340f5a/phoenix-core/src/main/java/org/apache/phoenix/compile/UpsertCompiler.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/UpsertCompiler.java 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/UpsertCompiler.java
index d534d50..2ac075e 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/

[25/50] [abbrv] phoenix git commit: PHOENIX-1646 Views and functional index expressions may lose information when stringified

2015-03-04 Thread maryannxue
PHOENIX-1646 Views and functional index expressions may lose information when 
stringified


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/2730e874
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/2730e874
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/2730e874

Branch: refs/heads/calcite
Commit: 2730e874d4632e681d2e21d1df88e4516e87e72e
Parents: abeaa74
Author: James Taylor 
Authored: Tue Feb 10 01:05:06 2015 -0800
Committer: James Taylor 
Committed: Tue Feb 10 01:05:06 2015 -0800

--
 .../apache/phoenix/end2end/DerivedTableIT.java  |  6 ++--
 .../org/apache/phoenix/end2end/HashJoinIT.java  | 30 ++--
 .../phoenix/end2end/HashJoinLocalIndexIT.java   |  2 +-
 .../org/apache/phoenix/end2end/SubqueryIT.java  | 16 +--
 .../end2end/SubqueryUsingSortMergeJoinIT.java   | 24 
 .../java/org/apache/phoenix/end2end/ViewIT.java |  2 +-
 .../end2end/index/BaseMutableIndexIT.java   |  6 ++--
 .../index/GlobalIndexOptimizationIT.java|  4 +--
 .../phoenix/end2end/index/LocalIndexIT.java |  4 +--
 .../phoenix/compile/IndexStatementRewriter.java |  5 ++--
 10 files changed, 49 insertions(+), 50 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/2730e874/phoenix-core/src/it/java/org/apache/phoenix/end2end/DerivedTableIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DerivedTableIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DerivedTableIT.java
index 7a418bd..7443267 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DerivedTableIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DerivedTableIT.java
@@ -92,15 +92,15 @@ public class DerivedTableIT extends BaseClientManagedTimeIT 
{
 "CREATE INDEX ATABLE_DERIVED_IDX ON aTable (a_byte) INCLUDE 
(A_STRING, B_STRING)" 
 }, {
 "CLIENT PARALLEL 1-WAY FULL SCAN OVER ATABLE_DERIVED_IDX\n" +
-"SERVER AGGREGATE INTO DISTINCT ROWS BY [A_STRING, 
B_STRING]\n" +
+"SERVER AGGREGATE INTO DISTINCT ROWS BY [\"A_STRING\", 
\"B_STRING\"]\n" +
 "CLIENT MERGE SORT\n" +
-"CLIENT SORTED BY [B_STRING]\n" +
+"CLIENT SORTED BY [\"B_STRING\"]\n" +
 "CLIENT SORTED BY [A]\n" +
 "CLIENT AGGREGATE INTO DISTINCT ROWS BY [A]\n" +
 "CLIENT SORTED BY [A DESC]",
 
 "CLIENT PARALLEL 1-WAY FULL SCAN OVER ATABLE_DERIVED_IDX\n" +
-"SERVER AGGREGATE INTO DISTINCT ROWS BY [A_STRING, 
B_STRING]\n" +
+"SERVER AGGREGATE INTO DISTINCT ROWS BY [\"A_STRING\", 
\"B_STRING\"]\n" +
 "CLIENT MERGE SORT\n" +
 "CLIENT AGGREGATE INTO DISTINCT ROWS BY [A]\n" +
 "CLIENT DISTINCT ON [COLLECTDISTINCT(B)]"}});

http://git-wip-us.apache.org/repos/asf/phoenix/blob/2730e874/phoenix-core/src/it/java/org/apache/phoenix/end2end/HashJoinIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/HashJoinIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/HashJoinIT.java
index 76eab22..5d2f522 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/HashJoinIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/HashJoinIT.java
@@ -478,9 +478,9 @@ public class HashJoinIT extends BaseHBaseManagedTimeIT {
  * GROUP BY i.name ORDER BY i.name
  */ 
 "CLIENT PARALLEL 1-WAY FULL SCAN OVER " + 
JOIN_ORDER_TABLE_DISPLAY_NAME + "\n" +
-"SERVER AGGREGATE INTO DISTINCT ROWS BY [I.0:NAME]\n" +
+"SERVER AGGREGATE INTO DISTINCT ROWS BY [\"I.0:NAME\"]\n" +
 "CLIENT MERGE SORT\n" +
-"CLIENT SORTED BY [I.0:NAME]\n" +
+"CLIENT SORTED BY [\"I.0:NAME\"]\n" +
 "PARALLEL LEFT-JOIN TABLE 0\n" +
 "CLIENT PARALLEL 1-WAY FULL SCAN OVER " + JOIN_SCHEMA 
+ ".idx_item\n" +
 "SERVER FILTER BY FIRST KEY ONLY",
@@ -518,7 +518,7 @@ public class HashJoinIT extends BaseHBaseManagedTimeIT {
  */
 "CLIENT PARALLEL 1-WAY FULL SCAN OVER " + JOIN_SCHEMA + 
".idx_item\n" +
 "SERVER FILTER BY FIRST KEY ONLY\n" +
-"SERVER AGGREGATE INTO ORDERED DISTINCT ROWS BY 
[I.0:NAME]\n" +
+"SERVER AGGREGATE INTO ORDERED DISTINCT ROWS BY 
[\"I.0:NAME\"]\n" +
 "CLIENT MERGE SORT\n" +
 "PARALLEL LEFT-JOIN TABLE 0\n

[47/50] [abbrv] phoenix git commit: PHOENIX-1690 IndexOutOfBoundsException during SkipScanFilter interesect

2015-03-04 Thread maryannxue
PHOENIX-1690 IndexOutOfBoundsException during SkipScanFilter interesect


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/49f06b33
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/49f06b33
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/49f06b33

Branch: refs/heads/calcite
Commit: 49f06b331c2b364f176d77548d04a4eb9d15c5c9
Parents: 3f82975
Author: James Taylor 
Authored: Tue Mar 3 12:07:56 2015 -0800
Committer: James Taylor 
Committed: Tue Mar 3 12:07:56 2015 -0800

--
 .../apache/phoenix/filter/SkipScanFilter.java   |  31 +-
 .../org/apache/phoenix/schema/PTableImpl.java   |   9 +
 .../phoenix/filter/SkipScanBigFilterTest.java   | 717 +++
 .../filter/SkipScanFilterIntersectTest.java |  69 +-
 4 files changed, 821 insertions(+), 5 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/49f06b33/phoenix-core/src/main/java/org/apache/phoenix/filter/SkipScanFilter.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/filter/SkipScanFilter.java 
b/phoenix-core/src/main/java/org/apache/phoenix/filter/SkipScanFilter.java
index 0aafdbb..1923856 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/filter/SkipScanFilter.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/filter/SkipScanFilter.java
@@ -195,7 +195,7 @@ public class SkipScanFilter extends FilterBase implements 
Writable {
 Arrays.fill(position, 0);
 }
 
-private boolean intersect(byte[] lowerInclusiveKey, byte[] 
upperExclusiveKey, List> newSlots) {
+private boolean intersect(final byte[] lowerInclusiveKey, final byte[] 
upperExclusiveKey, List> newSlots) {
 resetState();
 boolean lowerUnbound = (lowerInclusiveKey.length == 0);
 int startPos = 0;
@@ -262,6 +262,9 @@ public class SkipScanFilter extends FilterBase implements 
Writable {
 }
 int[] lowerPosition = Arrays.copyOf(position, position.length);
 // Navigate to the upperExclusiveKey, but not past it
+// TODO: We're including everything between the lowerPosition and end 
position, which is
+// more than we need. We can optimize this by tracking whether each 
range in each slot position
+// intersects.
 ReturnCode endCode = navigate(upperExclusiveKey, 0, 
upperExclusiveKey.length, Terminate.AT);
 if (endCode == ReturnCode.INCLUDE) {
 setStartKey();
@@ -286,6 +289,11 @@ public class SkipScanFilter extends FilterBase implements 
Writable {
 position[i] = slots.get(i).size() - 1;
 }
 }
+int prevRowKeyPos = -1;
+ImmutableBytesWritable lowerPtr = new ImmutableBytesWritable();
+ImmutableBytesWritable upperPtr = new ImmutableBytesWritable();
+schema.iterator(lowerInclusiveKey, lowerPtr);
+schema.iterator(upperExclusiveKey, upperPtr);
 // Copy inclusive all positions 
 for (int i = 0; i <= lastSlot; i++) {
 List newRanges = slots.get(i).subList(lowerPosition[i], 
Math.min(position[i] + 1, slots.get(i).size()));
@@ -295,12 +303,33 @@ public class SkipScanFilter extends FilterBase implements 
Writable {
 if (newSlots != null) {
 newSlots.add(newRanges);
 }
+// Must include all "less-significant" slot values if:
+// 1) a more-significant slot was incremented
 if (position[i] > lowerPosition[i]) {
 if (newSlots != null) {
 newSlots.addAll(slots.subList(i+1, slots.size()));
 }
 break;
 }
+// 2) we're at a slot containing a range and the values differ 
between the lower and upper range,
+//since less-significant slots may be lower after traversal 
than where they started.
+if (!slots.get(i).get(position[i]).isSingleKey()) {
+int rowKeyPos = ScanUtil.getRowKeyPosition(slotSpan, i);
+// Position lowerPtr/upperPtr within 
lowerInclusiveKey/upperExclusiveKey at value for slot i
+// The reposition method will do this incrementally, where we 
we're initially have prevRowKeyPos = -1. 
+schema.reposition(lowerPtr, prevRowKeyPos, rowKeyPos, 0, 
lowerInclusiveKey.length, slotSpan[i]);
+schema.reposition(upperPtr, prevRowKeyPos, rowKeyPos, 0, 
upperExclusiveKey.length, slotSpan[i]);
+// If we have a range and the values differ, we must include 
all slots that are less significant.
+// For example: [A-D][1,23], the lower/upper keys could be 
B5/C2, where the C is in range and the
+// next slot value of 2 is less than the next corresp

[36/50] [abbrv] phoenix git commit: PHOENIX-1672 RegionScanner.nextRaw contract not implemented correctly

2015-03-04 Thread maryannxue
PHOENIX-1672 RegionScanner.nextRaw contract not implemented correctly


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/3d50147f
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/3d50147f
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/3d50147f

Branch: refs/heads/calcite
Commit: 3d50147f213dd3f830b039159fde68eae10ae233
Parents: c633151
Author: Andrew Purtell 
Authored: Sat Feb 21 20:34:08 2015 -0800
Committer: Andrew Purtell 
Committed: Sat Feb 21 20:34:08 2015 -0800

--
 .../GroupedAggregateRegionObserver.java |  96 
 .../UngroupedAggregateRegionObserver.java   | 246 ++-
 .../phoenix/index/PhoenixIndexBuilder.java  |  18 +-
 .../iterate/RegionScannerResultIterator.java|  36 +--
 4 files changed, 216 insertions(+), 180 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/3d50147f/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/GroupedAggregateRegionObserver.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/GroupedAggregateRegionObserver.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/GroupedAggregateRegionObserver.java
index 8b59b85..0984b06 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/GroupedAggregateRegionObserver.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/GroupedAggregateRegionObserver.java
@@ -375,7 +375,7 @@ public class GroupedAggregateRegionObserver extends 
BaseScannerRegionObserver {
  * @param limit TODO
  */
 private RegionScanner 
scanUnordered(ObserverContext c, Scan scan,
-final RegionScanner s, final List expressions,
+final RegionScanner scanner, final List expressions,
 final ServerAggregators aggregators, long limit) throws 
IOException {
 if (logger.isDebugEnabled()) {
 logger.debug(LogUtil.addCustomAnnotations("Grouped aggregation 
over unordered rows with scan " + scan
@@ -410,28 +410,30 @@ public class GroupedAggregateRegionObserver extends 
BaseScannerRegionObserver {
 HRegion region = c.getEnvironment().getRegion();
 region.startRegionOperation();
 try {
-do {
-List results = new ArrayList();
-// Results are potentially returned even when the return
-// value of s.next is false
-// since this is an indication of whether or not there are
-// more values after the
-// ones returned
-hasMore = s.nextRaw(results);
-if (!results.isEmpty()) {
-result.setKeyValues(results);
-ImmutableBytesWritable key =
+synchronized (scanner) {
+do {
+List results = new ArrayList();
+// Results are potentially returned even when the 
return
+// value of s.next is false
+// since this is an indication of whether or not there 
are
+// more values after the
+// ones returned
+hasMore = scanner.nextRaw(results);
+if (!results.isEmpty()) {
+result.setKeyValues(results);
+ImmutableBytesWritable key =
 TupleUtil.getConcatenatedValue(result, 
expressions);
-Aggregator[] rowAggregators = groupByCache.cache(key);
-// Aggregate values here
-aggregators.aggregate(rowAggregators, result);
-}
-} while (hasMore && groupByCache.size() < limit);
+Aggregator[] rowAggregators = 
groupByCache.cache(key);
+// Aggregate values here
+aggregators.aggregate(rowAggregators, result);
+}
+} while (hasMore && groupByCache.size() < limit);
+}
 } finally {
 region.closeRegionOperation();
 }
 
-RegionScanner regionScanner = groupByCache.getScanner(s);
+RegionScanner regionScanner = groupByCache.getScanner(scanner);
 
 // Do not sort here, but sort back on the client instead
 // The reason is that if the scan ever extends beyond a region
@@ -453,7 +455,7 @@ public class GroupedAggregateRegionObserver extends 
BaseScannerRegionObserver {
  * @throws IOException 
  */
 private RegionScanner scanOrder

[08/50] [abbrv] phoenix git commit: PHOENIX-514 Support functional indexes (Thomas D'Silva)

2015-03-04 Thread maryannxue
http://git-wip-us.apache.org/repos/asf/phoenix/blob/8c340f5a/phoenix-core/src/main/java/org/apache/phoenix/schema/SaltingUtil.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/schema/SaltingUtil.java 
b/phoenix-core/src/main/java/org/apache/phoenix/schema/SaltingUtil.java
index 91e4f36..964ac39 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/SaltingUtil.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/SaltingUtil.java
@@ -38,7 +38,7 @@ public class SaltingUtil {
 public static final String SALTING_COLUMN_NAME = "_SALT";
 public static final String SALTED_ROW_KEY_NAME = "_SALTED_KEY";
 public static final PColumnImpl SALTING_COLUMN = new PColumnImpl(
-PNameFactory.newName(SALTING_COLUMN_NAME), null, PBinary.INSTANCE, 
1, 0, false, 0, SortOrder.getDefault(), 0, null, false);
+PNameFactory.newName(SALTING_COLUMN_NAME), null, PBinary.INSTANCE, 
1, 0, false, 0, SortOrder.getDefault(), 0, null, false, null);
 public static final RowKeySchema VAR_BINARY_SALTED_SCHEMA = new 
RowKeySchemaBuilder(2)
 .addField(SALTING_COLUMN, false, SortOrder.getDefault())
 .addField(SchemaUtil.VAR_BINARY_DATUM, false, 
SortOrder.getDefault()).build();

http://git-wip-us.apache.org/repos/asf/phoenix/blob/8c340f5a/phoenix-core/src/main/java/org/apache/phoenix/schema/tuple/ValueGetterTuple.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/schema/tuple/ValueGetterTuple.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/schema/tuple/ValueGetterTuple.java
new file mode 100644
index 000..6fc480e
--- /dev/null
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/schema/tuple/ValueGetterTuple.java
@@ -0,0 +1,93 @@
+/*
+ * 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.schema.tuple;
+
+import static 
org.apache.phoenix.hbase.index.util.ImmutableBytesPtr.copyBytesIfNecessary;
+
+import java.io.IOException;
+
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.KeyValue;
+import org.apache.hadoop.hbase.KeyValue.Type;
+import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
+import org.apache.phoenix.expression.Expression;
+import org.apache.phoenix.hbase.index.ValueGetter;
+import org.apache.phoenix.hbase.index.covered.update.ColumnReference;
+import org.apache.phoenix.hbase.index.util.ImmutableBytesPtr;
+
+/**
+ * 
+ * Class used to construct a {@link Tuple} in order to evaluate an {@link 
Expression}
+ */
+public class ValueGetterTuple extends BaseTuple {
+   private ValueGetter valueGetter;
+
+public ValueGetterTuple(ValueGetter valueGetter) {
+this.valueGetter = valueGetter;
+}
+
+public ValueGetterTuple() {
+}
+
+@Override
+public void getKey(ImmutableBytesWritable ptr) {
+ptr.set(valueGetter.getRowKey());
+}
+
+@Override
+public boolean isImmutable() {
+return true;
+}
+
+@Override
+public KeyValue getValue(byte[] family, byte[] qualifier) {
+   ImmutableBytesPtr value = null;
+try {
+value = valueGetter.getLatestValue(new ColumnReference(family, 
qualifier));
+} catch (IOException e) {
+throw new RuntimeException(e);
+}
+   return new KeyValue(valueGetter.getRowKey(), family, qualifier, 
HConstants.LATEST_TIMESTAMP, Type.Put, value!=null? copyBytesIfNecessary(value) 
: null);
+}
+
+@Override
+public String toString() {
+throw new UnsupportedOperationException();
+}
+
+@Override
+public int size() {
+throw new UnsupportedOperationException();
+}
+
+@Override
+public KeyValue getValue(int index) {
+throw new UnsupportedOperationException();
+}
+
+@Override
+public boolean getValue(byte[] family, byte[] qualifier,
+ImmutableBytesWritable ptr) {
+KeyValue kv = getValue(family, qualifier);
+if (kv == null)
+return false;
+ptr.set(kv.getBuffer(), kv.getValueOffset(), kv.getValueLength());
+return true;
+}
+

[04/50] [abbrv] phoenix git commit: PHOENIX-1616 Creating a View with a case sensitive column name does not work (Thomas D'Silva)

2015-03-04 Thread maryannxue
http://git-wip-us.apache.org/repos/asf/phoenix/blob/03a5d7ef/phoenix-core/src/main/java/org/apache/phoenix/util/SchemaUtil.java
--
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/SchemaUtil.java 
b/phoenix-core/src/main/java/org/apache/phoenix/util/SchemaUtil.java
index 72c67bf..9ab0692 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/SchemaUtil.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/SchemaUtil.java
@@ -48,18 +48,18 @@ import 
org.apache.phoenix.schema.ColumnFamilyNotFoundException;
 import org.apache.phoenix.schema.ColumnNotFoundException;
 import org.apache.phoenix.schema.PColumn;
 import org.apache.phoenix.schema.PColumnFamily;
-import org.apache.phoenix.schema.types.PDataType;
 import org.apache.phoenix.schema.PDatum;
 import org.apache.phoenix.schema.PMetaData;
 import org.apache.phoenix.schema.PName;
 import org.apache.phoenix.schema.PTable;
-import org.apache.phoenix.schema.types.PVarbinary;
-import org.apache.phoenix.schema.types.PVarchar;
 import org.apache.phoenix.schema.RowKeySchema;
 import org.apache.phoenix.schema.RowKeySchema.RowKeySchemaBuilder;
 import org.apache.phoenix.schema.SaltingUtil;
 import org.apache.phoenix.schema.SortOrder;
 import org.apache.phoenix.schema.ValueSchema.Field;
+import org.apache.phoenix.schema.types.PDataType;
+import org.apache.phoenix.schema.types.PVarbinary;
+import org.apache.phoenix.schema.types.PVarchar;
 
 import com.google.common.base.Preconditions;
 
@@ -174,7 +174,7 @@ public class SchemaUtil {
 }
 
 public static boolean isCaseSensitive(String name) {
-return name.length() > 0 && name.charAt(0)=='"';
+return name!=null && name.length() > 0 && name.charAt(0)=='"';
 }
 
 public static  List concat(List l1, List l2) {



[13/50] [abbrv] phoenix git commit: PHOENIX-1644 Check for min HBase version before creating local index and provide means of disabling usage

2015-03-04 Thread maryannxue
PHOENIX-1644 Check for min HBase version before creating local index and 
provide means of disabling usage


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/54c4ed80
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/54c4ed80
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/54c4ed80

Branch: refs/heads/calcite
Commit: 54c4ed80869f6ac0011a65d1247285cfae0a6759
Parents: f3c675b
Author: James Taylor 
Authored: Fri Feb 6 14:43:04 2015 -0800
Committer: James Taylor 
Committed: Fri Feb 6 14:59:01 2015 -0800

--
 .../phoenix/end2end/DisableLocalIndexIT.java| 99 
 .../phoenix/exception/SQLExceptionCode.java |  3 +
 .../phoenix/jdbc/PhoenixDatabaseMetaData.java   |  5 +-
 .../query/ConnectionQueryServicesImpl.java  |  8 ++
 .../org/apache/phoenix/query/HTableFactory.java |  3 +-
 .../org/apache/phoenix/query/QueryServices.java |  1 +
 .../phoenix/query/QueryServicesOptions.java |  1 +
 .../apache/phoenix/schema/MetaDataClient.java   | 13 ++-
 8 files changed, 127 insertions(+), 6 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/54c4ed80/phoenix-core/src/it/java/org/apache/phoenix/end2end/DisableLocalIndexIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/DisableLocalIndexIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DisableLocalIndexIT.java
new file mode 100644
index 000..5f18a1c
--- /dev/null
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/DisableLocalIndexIT.java
@@ -0,0 +1,99 @@
+/*
+ * 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 static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.fail;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.hadoop.hbase.client.HBaseAdmin;
+import org.apache.hadoop.hbase.client.HTableInterface;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.phoenix.exception.SQLExceptionCode;
+import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.query.QueryServices;
+import org.apache.phoenix.util.MetaDataUtil;
+import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.PropertiesUtil;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.apache.phoenix.util.TestUtil;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.google.common.collect.Maps;
+
+public class DisableLocalIndexIT extends BaseHBaseManagedTimeIT {
+@BeforeClass
+@Shadower(classBeingShadowed = BaseHBaseManagedTimeIT.class)
+public static void doSetup() throws Exception {
+Map props = Maps.newHashMapWithExpectedSize(1);
+// Must update config before starting server
+props.put(QueryServices.ALLOW_LOCAL_INDEX_ATTRIB, 
Boolean.FALSE.toString());
+setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
+}
+
+@Test
+public void testDisabledLocalIndexes() throws Exception {
+Connection conn = DriverManager.getConnection(getUrl());
+conn.setAutoCommit(true);
+String tableName = "DISABLE_LOCAL_INDEX_TEST";
+conn.createStatement().execute("CREATE TABLE " + tableName + " (k1 
VARCHAR NOT NULL, k2 VARCHAR, CONSTRAINT PK PRIMARY KEY(K1,K2)) 
MULTI_TENANT=true");
+conn.createStatement().execute("UPSERT INTO " + tableName + " 
VALUES('t1','x')");
+conn.createStatement().execute("UPSERT INTO " + tableName + " 
VALUES('t2','y')");
+HBaseAdmin admin = 
conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin();
+
assertFalse(admin.tableExists(Bytes.toBytes(MetaDataUtil.LOCAL_INDEX_TABLE_PREFIX
 + tableName)));
+admin.close();
+try {
+HTableInterface t = 
conn.unwrap(PhoenixConnection.class).getQueryServices().getTable(Bytes.toBytes(Me

[46/50] [abbrv] phoenix git commit: PHOENIX-1690 IndexOutOfBoundsException during SkipScanFilter interesect

2015-03-04 Thread maryannxue
http://git-wip-us.apache.org/repos/asf/phoenix/blob/49f06b33/phoenix-core/src/test/java/org/apache/phoenix/filter/SkipScanBigFilterTest.java
--
diff --git 
a/phoenix-core/src/test/java/org/apache/phoenix/filter/SkipScanBigFilterTest.java
 
b/phoenix-core/src/test/java/org/apache/phoenix/filter/SkipScanBigFilterTest.java
new file mode 100644
index 000..29e14bf
--- /dev/null
+++ 
b/phoenix-core/src/test/java/org/apache/phoenix/filter/SkipScanBigFilterTest.java
@@ -0,0 +1,717 @@
+/*
+ * 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.filter;
+
+import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Properties;
+import java.util.SortedMap;
+
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.phoenix.compile.QueryPlan;
+import org.apache.phoenix.end2end.Shadower;
+import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.jdbc.PhoenixStatement;
+import org.apache.phoenix.query.BaseConnectionlessQueryTest;
+import org.apache.phoenix.query.QueryConstants;
+import org.apache.phoenix.query.QueryServices;
+import org.apache.phoenix.schema.PTable;
+import org.apache.phoenix.schema.PTableImpl;
+import org.apache.phoenix.schema.PTableKey;
+import org.apache.phoenix.schema.stats.GuidePostsInfo;
+import org.apache.phoenix.schema.stats.PTableStats;
+import org.apache.phoenix.util.PropertiesUtil;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.google.common.collect.Maps;
+
+
+
+public class SkipScanBigFilterTest extends BaseConnectionlessQueryTest {
+private static final byte[][] REGION_BOUNDARIES_MINIMAL = {
+
Bytes.toBytesBinary("\\x06\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00"),
+};
+
+private static final byte[][] GUIDE_POSTS_MINIMAL = {
+
Bytes.toBytesBinary("\\x08\\x80\\x00)\\xE4\\x80\\x00\\x0E\\x00\\x80\\x00\\x00\\x01DESKTOP\\x00\\x80\\x00\\x00\\x01\\x07#[j\\x80\\x00\\x00\\x00Y\\x08u\\xF3\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x00"),
+
Bytes.toBytesBinary("\\x08\\x80\\x00)\\xE4\\x80\\x00\\x0E\\x17\\x80\\x00\\x00\\x01DESKTOP\\x00\\x80\\x00\\x00\\x00\\xD3U\\x88\\xFF\\x80\\x00\\x00\\x00\\x84\\xBFJ\\xE0\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x00"),
+};
+
+
+private static final byte[][] REGION_BOUNDARIES_ALL = {
+
Bytes.toBytesBinary("\\x00\\x80\\x00b\\xB9\\x80\\x00\\x0D^\\x80\\x03t\\xC5DESKTOP\\x00\\x80\\x00\\x00\\x01y3\\xF7P\\x80\\x00\\x00\\x00B\\xE7\\xF6F\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x00"),
+
Bytes.toBytesBinary("\\x00\\x80\\x00b\\xB9\\x80\\x00\\x0D\\xB3\\x80\\x00\\x00\\x01MOBILE\\x00\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x80\\x00\\x00\\x00oI\\x17B\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x00"),
+
Bytes.toBytesBinary("\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00"),
+
Bytes.toBytesBinary("\\x01\\x80\\x00)\\xE4\\x80\\x00\\x0E#\\x80\\x00\\x00\\x01DESKTOP\\x00\\x80\\x00\\x00\\x01\\xFA._\\xE2\\x80\\x00\\x00\\x00\\x98\\xFE2\\xF5\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x00"),
+
Bytes.toBytesBinary("\\x01\\x80\\x00b\\xB9\\x80\\x00\\x0Da\\x80\\x00\\x00\\x01MOBILE\\x00\\x80\\x00\\x00\\x01`1%"),
+
Bytes.toBytesBinary("\\x01\\x80\\x00b\\xB9\\x80\\x00\\x0D\\xAA\\x80\\x00\\x00\\x01DESKTOP\\x00\\x80\\x00\\x00\\x01\\x82\\xB4]\\xE7\\x80\\x00\\x00\\x00ER\\xFE#\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x00"),
+
Bytes.toBytes

[09/50] [abbrv] phoenix git commit: PHOENIX-514 Support functional indexes (Thomas D'Silva)

2015-03-04 Thread maryannxue
http://git-wip-us.apache.org/repos/asf/phoenix/blob/8c340f5a/phoenix-core/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java 
b/phoenix-core/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java
index 9c5c2cd..a51723b 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/optimize/QueryOptimizer.java
@@ -37,13 +37,15 @@ import org.apache.phoenix.compile.SubqueryRewriter;
 import org.apache.phoenix.iterate.ParallelIteratorFactory;
 import org.apache.phoenix.jdbc.PhoenixStatement;
 import org.apache.phoenix.parse.AliasedNode;
-import org.apache.phoenix.parse.HintNode;
-import org.apache.phoenix.parse.HintNode.Hint;
 import org.apache.phoenix.parse.AndParseNode;
 import org.apache.phoenix.parse.BooleanParseNodeVisitor;
 import org.apache.phoenix.parse.ColumnParseNode;
+import org.apache.phoenix.parse.IndexExpressionParseNodeRewriter;
+import org.apache.phoenix.parse.HintNode;
+import org.apache.phoenix.parse.HintNode.Hint;
 import org.apache.phoenix.parse.ParseNode;
 import org.apache.phoenix.parse.ParseNodeFactory;
+import org.apache.phoenix.parse.ParseNodeRewriter;
 import org.apache.phoenix.parse.SelectStatement;
 import org.apache.phoenix.parse.TableNode;
 import org.apache.phoenix.query.QueryServices;
@@ -54,9 +56,8 @@ import org.apache.phoenix.schema.PDatum;
 import org.apache.phoenix.schema.PIndexState;
 import org.apache.phoenix.schema.PTable;
 import org.apache.phoenix.schema.PTable.IndexType;
-import org.apache.phoenix.schema.types.PDataType;
 import org.apache.phoenix.schema.PTableType;
-import org.apache.phoenix.schema.SaltingUtil;
+import org.apache.phoenix.schema.types.PDataType;
 import org.apache.phoenix.util.IndexUtil;
 
 import com.google.common.collect.Lists;
@@ -232,7 +233,10 @@ public class QueryOptimizer {
 // Check index state of now potentially updated index table to make 
sure it's active
 if 
(PIndexState.ACTIVE.equals(resolver.getTables().get(0).getTable().getIndexState()))
 {
 try {
+   // translate nodes that match expressions that are indexed to 
the associated column parse node
+indexSelect = ParseNodeRewriter.rewrite(indexSelect, new  
IndexExpressionParseNodeRewriter(index, statement.getConnection()));
 QueryCompiler compiler = new QueryCompiler(statement, 
indexSelect, resolver, targetColumns, parallelIteratorFactory, 
dataPlan.getContext().getSequenceManager());
+
 QueryPlan plan = compiler.compile();
 // If query doesn't have where clause and some of columns to 
project are missing
 // in the index then we need to get missing columns from main 
table for each row in

http://git-wip-us.apache.org/repos/asf/phoenix/blob/8c340f5a/phoenix-core/src/main/java/org/apache/phoenix/parse/BetweenParseNode.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/parse/BetweenParseNode.java 
b/phoenix-core/src/main/java/org/apache/phoenix/parse/BetweenParseNode.java
index cc65d89..961af20 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/parse/BetweenParseNode.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/BetweenParseNode.java
@@ -49,4 +49,26 @@ public class BetweenParseNode extends CompoundParseNode {
 }
 return visitor.visitLeave(this, l);
 }
+
+   @Override
+   public int hashCode() {
+   final int prime = 31;
+   int result = super.hashCode();
+   result = prime * result + (negate ? 1231 : 1237);
+   return result;
+   }
+
+   @Override
+   public boolean equals(Object obj) {
+   if (this == obj)
+   return true;
+   if (!super.equals(obj))
+   return false;
+   if (getClass() != obj.getClass())
+   return false;
+   BetweenParseNode other = (BetweenParseNode) obj;
+   if (negate != other.negate)
+   return false;
+   return true;
+   }
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/8c340f5a/phoenix-core/src/main/java/org/apache/phoenix/parse/BindParseNode.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/parse/BindParseNode.java 
b/phoenix-core/src/main/java/org/apache/phoenix/parse/BindParseNode.java
index 75dfa90..5f649de 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/parse/BindParseNode.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/BindParseNode.java
@@ -56,4 +56,26 @@ public class BindParseNode extends NamedParseNode {
  

[14/50] [abbrv] phoenix git commit: PHOENIX-1620 Add API for getting tenant ID from an HBase row of a Phoenix table

2015-03-04 Thread maryannxue
PHOENIX-1620 Add API for getting tenant ID from an HBase row of a Phoenix table


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/f3c675bf
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/f3c675bf
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/f3c675bf

Branch: refs/heads/calcite
Commit: f3c675bf735d7d4e4534433f3406af15360ed5d9
Parents: 2d77033
Author: James Taylor 
Authored: Fri Feb 6 11:14:26 2015 -0800
Committer: James Taylor 
Committed: Fri Feb 6 14:59:01 2015 -0800

--
 .../phoenix/end2end/PhoenixRuntimeIT.java   | 138 +++
 .../org/apache/phoenix/util/PhoenixRuntime.java |  39 +-
 .../org/apache/phoenix/util/SchemaUtil.java |   4 +
 .../java/org/apache/phoenix/query/BaseTest.java |  20 ++-
 .../apache/phoenix/util/PhoenixRuntimeTest.java |  58 
 5 files changed, 255 insertions(+), 4 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/f3c675bf/phoenix-core/src/it/java/org/apache/phoenix/end2end/PhoenixRuntimeIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/PhoenixRuntimeIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PhoenixRuntimeIT.java
new file mode 100644
index 000..234ea1c
--- /dev/null
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/PhoenixRuntimeIT.java
@@ -0,0 +1,138 @@
+/*
+ * 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 static 
org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.TABLE_FAMILY_BYTES;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import java.io.IOException;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.hadoop.hbase.client.HTableInterface;
+import org.apache.hadoop.hbase.client.Result;
+import org.apache.hadoop.hbase.client.ResultScanner;
+import org.apache.hadoop.hbase.client.Scan;
+import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp;
+import org.apache.hadoop.hbase.filter.Filter;
+import org.apache.hadoop.hbase.filter.FilterList;
+import org.apache.hadoop.hbase.filter.FirstKeyOnlyFilter;
+import org.apache.hadoop.hbase.filter.SingleColumnValueFilter;
+import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.phoenix.expression.Expression;
+import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData;
+import org.apache.phoenix.schema.PTableType;
+import org.apache.phoenix.schema.tuple.ResultTuple;
+import org.apache.phoenix.schema.types.PVarchar;
+import org.apache.phoenix.util.MetaDataUtil;
+import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.PropertiesUtil;
+import org.apache.phoenix.util.TestUtil;
+import org.junit.Test;
+
+import com.google.common.collect.Lists;
+
+public class PhoenixRuntimeIT extends BaseHBaseManagedTimeIT {
+private static void assertTenantIds(Expression e, HTableInterface htable, 
Filter filter, String[] tenantIds) throws IOException {
+ImmutableBytesWritable ptr = new ImmutableBytesWritable();
+Scan scan = new Scan();
+scan.setFilter(filter);
+ResultScanner scanner = htable.getScanner(scan);
+Result result = null;
+ResultTuple tuple = new ResultTuple();
+List actualTenantIds = 
Lists.newArrayListWithExpectedSize(tenantIds.length);
+List expectedTenantIds = Arrays.asList(tenantIds);
+while ((result = scanner.next()) != null) {
+tuple.setResult(result);
+e.evaluate(tuple, ptr);
+String tenantId = (String)PVarchar.INSTANCE.toObject(ptr);
+actualTenantIds.add(tenantId == null ? "" : tenantId);
+}
+// Need to sort because of salting
+Collections.sort(actualTenantIds);
+assertE

[24/50] [abbrv] phoenix git commit: PHOENIX-653 Support ANSI-standard date literals from SQL 2003

2015-03-04 Thread maryannxue
PHOENIX-653 Support ANSI-standard date literals from SQL 2003


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/2d5913b8
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/2d5913b8
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/2d5913b8

Branch: refs/heads/calcite
Commit: 2d5913b80349179da5aa18a1abbb56c230ee0542
Parents: 11a76b2
Author: James Taylor 
Authored: Sun Feb 8 20:46:46 2015 -0800
Committer: James Taylor 
Committed: Mon Feb 9 18:37:14 2015 -0800

--
 phoenix-core/src/main/antlr3/PhoenixSQL.g   | 17 -
 .../expression/ArrayConstructorExpression.java  | 12 
 .../phoenix/expression/LiteralExpression.java   | 17 +++--
 .../apache/phoenix/parse/ParseNodeFactory.java  | 14 
 .../phoenix/schema/types/PArrayDataType.java| 17 +
 .../apache/phoenix/schema/types/PBinary.java| 15 ++--
 .../org/apache/phoenix/schema/types/PChar.java  | 14 ++--
 .../apache/phoenix/schema/types/PDataType.java  | 12 ++--
 .../org/apache/phoenix/schema/types/PDate.java  | 14 ++--
 .../apache/phoenix/schema/types/PDecimal.java   | 19 +++--
 .../org/apache/phoenix/schema/types/PTime.java  |  4 +-
 .../apache/phoenix/schema/types/PTimestamp.java |  4 +-
 .../phoenix/schema/types/PUnsignedDate.java | 12 ++--
 .../phoenix/schema/types/PUnsignedTime.java | 11 ++-
 .../schema/types/PUnsignedTimestamp.java| 11 ++-
 .../apache/phoenix/schema/types/PVarbinary.java | 25 ---
 .../apache/phoenix/schema/types/PVarchar.java   | 15 ++--
 .../compile/StatementHintsCompilationTest.java  |  2 +-
 .../apache/phoenix/parse/QueryParserTest.java   | 76 
 .../org/apache/phoenix/query/QueryPlanTest.java |  4 +-
 20 files changed, 242 insertions(+), 73 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/2d5913b8/phoenix-core/src/main/antlr3/PhoenixSQL.g
--
diff --git a/phoenix-core/src/main/antlr3/PhoenixSQL.g 
b/phoenix-core/src/main/antlr3/PhoenixSQL.g
index fad5fb3..cda93fe 100644
--- a/phoenix-core/src/main/antlr3/PhoenixSQL.g
+++ b/phoenix-core/src/main/antlr3/PhoenixSQL.g
@@ -152,6 +152,12 @@ import org.apache.phoenix.schema.PTableType;
 import org.apache.phoenix.schema.PTable.IndexType;
 import org.apache.phoenix.schema.stats.StatisticsCollectionScope;
 import org.apache.phoenix.schema.types.PDataType;
+import org.apache.phoenix.schema.types.PDate;
+import org.apache.phoenix.schema.types.PTime;
+import org.apache.phoenix.schema.types.PTimestamp;
+import org.apache.phoenix.schema.types.PUnsignedDate;
+import org.apache.phoenix.schema.types.PUnsignedTime;
+import org.apache.phoenix.schema.types.PUnsignedTimestamp;
 import org.apache.phoenix.util.SchemaUtil;
 import org.apache.phoenix.parse.LikeParseNode.LikeType;
 }
@@ -864,7 +870,9 @@ literal_or_bind returns [ParseNode ret]
 
 // Get a string, integer, double, date, boolean, or NULL value.
 literal returns [LiteralParseNode ret]
-:   t=STRING_LITERAL { ret = factory.literal(t.getText()); }
+:   t=STRING_LITERAL {
+ret = factory.literal(t.getText()); 
+}
 |   l=int_literal { ret = l; }
 |   l=long_literal { ret = l; }
 |   l=double_literal { ret = l; }
@@ -878,6 +886,13 @@ literal returns [LiteralParseNode ret]
 |   NULL {ret = factory.literal(null);}
 |   TRUE {ret = factory.literal(Boolean.TRUE);} 
 |   FALSE {ret = factory.literal(Boolean.FALSE);}
+|   dt=identifier t=STRING_LITERAL { 
+try {
+ret = factory.literal(t.getText(), dt);
+} catch (SQLException e) {
+throw new RuntimeException(e);
+}
+}
 ;
 
 int_literal returns [LiteralParseNode ret]

http://git-wip-us.apache.org/repos/asf/phoenix/blob/2d5913b8/phoenix-core/src/main/java/org/apache/phoenix/expression/ArrayConstructorExpression.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/expression/ArrayConstructorExpression.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/expression/ArrayConstructorExpression.java
index 9b0ee8f..15cd14c 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/expression/ArrayConstructorExpression.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/expression/ArrayConstructorExpression.java
@@ -166,4 +166,16 @@ public class ArrayConstructorExpression extends 
BaseCompoundExpression {
 }
 return t;
 }
+
+@Override
+public String toString() {
+StringBuilder buf = new StringBuilder(PArrayDataType.ARRAY_TYPE_SUFFIX 
+ "[");
+if (children.size()==0)
+return buf.append("]").toString();
+for (int i = 0; i < children.size() - 1; i++) {
+

[42/50] [abbrv] phoenix git commit: PHOENIX-1115 Provide a SQL command to turn tracing on/off(Rajeshbabu)

2015-03-04 Thread maryannxue
PHOENIX-1115 Provide a SQL command to turn tracing on/off(Rajeshbabu)


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/0440aca5
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/0440aca5
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/0440aca5

Branch: refs/heads/calcite
Commit: 0440aca51916d689f3ea94d4ef708d73887f7994
Parents: 93f5605
Author: Rajeshbabu Chintaguntla 
Authored: Sat Feb 28 05:49:53 2015 +0530
Committer: Rajeshbabu Chintaguntla 
Committed: Sat Feb 28 05:49:53 2015 +0530

--
 .../phoenix/trace/PhoenixTracingEndToEndIT.java |  32 ++-
 phoenix-core/src/main/antlr3/PhoenixSQL.g   |  10 +
 .../apache/phoenix/compile/TraceQueryPlan.java  | 220 +++
 .../apache/phoenix/jdbc/PhoenixConnection.java  |  17 ++
 .../apache/phoenix/jdbc/PhoenixStatement.java   |  24 +-
 .../apache/phoenix/parse/ParseNodeFactory.java  |   4 +
 .../apache/phoenix/parse/TraceStatement.java|  43 
 .../org/apache/phoenix/trace/util/Tracing.java  |  10 +
 8 files changed, 358 insertions(+), 2 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/0440aca5/phoenix-core/src/it/java/org/apache/phoenix/trace/PhoenixTracingEndToEndIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/trace/PhoenixTracingEndToEndIT.java
 
b/phoenix-core/src/it/java/org/apache/phoenix/trace/PhoenixTracingEndToEndIT.java
index 201de38..53d22c5 100644
--- 
a/phoenix-core/src/it/java/org/apache/phoenix/trace/PhoenixTracingEndToEndIT.java
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/trace/PhoenixTracingEndToEndIT.java
@@ -19,12 +19,15 @@ package org.apache.phoenix.trace;
 
 import static org.apache.phoenix.util.PhoenixRuntime.TENANT_ID_ATTRIB;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
 import java.sql.Connection;
+import java.sql.DriverManager;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
+import java.sql.Statement;
 import java.util.Collection;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
@@ -33,6 +36,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.metrics2.MetricsSource;
 import org.apache.phoenix.coprocessor.BaseScannerRegionObserver;
+import org.apache.phoenix.jdbc.PhoenixConnection;
 import org.apache.phoenix.metrics.Metrics;
 import org.apache.phoenix.query.QueryServicesOptions;
 import org.apache.phoenix.trace.TraceReader.SpanInfo;
@@ -391,7 +395,33 @@ public class PhoenixTracingEndToEndIT extends 
BaseTracingTestIT {
 assertAnnotationPresent(TENANT_ID_ATTRIB, tenantId, conn);
 // CurrentSCN is also added as an annotation. Not tested here because 
it screws up test setup.
 }
-
+
+@Test
+public void testTraceOnOrOff() throws Exception {
+Connection conn1 = DriverManager.getConnection(getUrl());
+try{
+Statement statement = conn1.createStatement();
+ResultSet  rs = statement.executeQuery("TRACE ON");
+assertTrue(rs.next());
+long traceId = ((PhoenixConnection) 
conn1).getTraceScope().getSpan()
+.getTraceId();
+assertEquals(rs.getLong(1), traceId);
+assertEquals(rs.getLong("trace_id"), traceId);
+assertFalse(rs.next());
+
+rs = statement.executeQuery("TRACE OFF");
+assertTrue(rs.next());
+assertEquals(rs.getLong(1), traceId);
+assertEquals(rs.getLong("trace_id"), traceId);
+assertFalse(rs.next());
+
+rs = statement.executeQuery("TRACE OFF");
+assertFalse(rs.next());
+   } finally {
+conn1.close();
+}
+}
+
 private void assertAnnotationPresent(final String annotationKey, final 
String annotationValue, Connection conn) throws Exception {
 boolean tracingComplete = checkStoredTraces(conn, new TraceChecker(){
 @Override

http://git-wip-us.apache.org/repos/asf/phoenix/blob/0440aca5/phoenix-core/src/main/antlr3/PhoenixSQL.g
--
diff --git a/phoenix-core/src/main/antlr3/PhoenixSQL.g 
b/phoenix-core/src/main/antlr3/PhoenixSQL.g
index cda93fe..9e843a0 100644
--- a/phoenix-core/src/main/antlr3/PhoenixSQL.g
+++ b/phoenix-core/src/main/antlr3/PhoenixSQL.g
@@ -33,6 +33,7 @@ tokens
 AS='as';
 OUTER='outer';
 ON='on';
+OFF='off';
 IN='in';
 GROUP='group';
 HAVING='having';
@@ -107,6 +108,7 @@ tokens
 UPDATE='update';
 STATISTICS='statistics';
 COLUMNS='columns';
+TRACE='trace

[48/50] [abbrv] phoenix git commit: PHOENIX-1696 Selecting column more than once fails (Maryann Xue, Samarth Jain)

2015-03-04 Thread maryannxue
PHOENIX-1696 Selecting column more than once fails (Maryann Xue, Samarth Jain)


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/9a546b9c
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/9a546b9c
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/9a546b9c

Branch: refs/heads/calcite
Commit: 9a546b9c89a3920345ea35ad503dfb360d4c34a5
Parents: 49f06b3
Author: James Taylor 
Authored: Wed Mar 4 08:27:51 2015 -0800
Committer: James Taylor 
Committed: Wed Mar 4 08:27:51 2015 -0800

--
 .../java/org/apache/phoenix/end2end/QueryMoreIT.java  | 14 ++
 .../java/org/apache/phoenix/compile/RowProjector.java |  3 ---
 2 files changed, 14 insertions(+), 3 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/9a546b9c/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java
index af5e6fa..e725376 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryMoreIT.java
@@ -18,6 +18,8 @@
 package org.apache.phoenix.end2end;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
 import java.sql.Connection;
 import java.sql.Date;
@@ -33,6 +35,7 @@ import java.util.Properties;
 import org.apache.hadoop.hbase.util.Base64;
 import org.apache.hadoop.hbase.util.Pair;
 import org.apache.phoenix.util.PhoenixRuntime;
+import org.apache.phoenix.util.TestUtil;
 import org.junit.Test;
 
 import com.google.common.collect.Lists;
@@ -314,4 +317,15 @@ public class QueryMoreIT extends BaseHBaseManagedTimeIT {
 sb.append(")");
 return sb.toString();
 }
+
+@Test // see - https://issues.apache.org/jira/browse/PHOENIX-1696
+public void testSelectColumnMoreThanOnce() throws Exception {
+Date date = new Date(System.currentTimeMillis());
+initEntityHistoryTableValues("abcd", getDefaultSplits("abcd"), date, 
100l);
+String query = "SELECT NEW_VALUE, NEW_VALUE FROM " + 
TestUtil.ENTITY_HISTORY_TABLE_NAME + " LIMIT 1";
+ResultSet rs = 
DriverManager.getConnection(getUrl()).createStatement().executeQuery(query);
+assertTrue(rs.next());
+rs.getObject("NEW_VALUE");
+assertFalse(rs.next());
+}
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/9a546b9c/phoenix-core/src/main/java/org/apache/phoenix/compile/RowProjector.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/RowProjector.java 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/RowProjector.java
index 364ebd6..1b35e92 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/RowProjector.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/RowProjector.java
@@ -139,9 +139,6 @@ public class RowProjector {
 throw new ColumnNotFoundException(name);
 }
 }
-if (index.size() > 1) {
-throw new AmbiguousColumnException(name);
-}
 
 return index.get(0);
 }



[49/50] [abbrv] phoenix git commit: Merge branch 'master' into calcite

2015-03-04 Thread maryannxue
Merge branch 'master' into calcite


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/b9d24a94
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/b9d24a94
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/b9d24a94

Branch: refs/heads/calcite
Commit: b9d24a94986360525bbe70b93308434877ed078d
Parents: 679571b 9a546b9
Author: maryannxue 
Authored: Wed Mar 4 12:33:38 2015 -0500
Committer: maryannxue 
Committed: Wed Mar 4 12:33:38 2015 -0500

--
 .gitignore  |1 +
 bin/phoenix_sandbox.py  |   59 +
 bin/phoenix_utils.py|2 +-
 bin/sandbox-log4j.properties|   45 +
 phoenix-assembly/pom.xml|4 +-
 phoenix-assembly/src/build/client.xml   |1 -
 .../src/build/components-major-client.xml   |3 +-
 .../src/build/components-minimal.xml|1 +
 .../components/all-common-dependencies.xml  |1 -
 .../src/build/components/all-common-jars.xml|3 +-
 .../src/build/package-to-tar-all.xml|   14 +
 .../src/build/server-without-antlr.xml  |2 +-
 phoenix-assembly/src/build/server.xml   |1 -
 phoenix-core/pom.xml|   19 +
 ...ReplayWithIndexWritesAndCompressedWALIT.java |2 +-
 .../src/it/java/org/apache/phoenix/Sandbox.java |   67 +
 .../phoenix/end2end/AggregateQueryIT.java   |  238 +
 .../apache/phoenix/end2end/AlterTableIT.java| 1374 +++-
 .../phoenix/end2end/ArithmeticQueryIT.java  |  100 +
 .../org/apache/phoenix/end2end/ArrayIT.java |2 +-
 .../org/apache/phoenix/end2end/BaseQueryIT.java |   17 +-
 .../end2end/BaseTenantSpecificViewIndexIT.java  |   16 +-
 .../org/apache/phoenix/end2end/BaseViewIT.java  |   15 +-
 .../phoenix/end2end/CSVCommonsLoaderIT.java |   47 +-
 .../end2end/ColumnProjectionOptimizationIT.java |   24 +-
 .../apache/phoenix/end2end/CreateTableIT.java   |   47 +-
 .../phoenix/end2end/DecodeFunctionIT.java   |7 +-
 .../apache/phoenix/end2end/DerivedTableIT.java  |   15 +-
 .../phoenix/end2end/DisableLocalIndexIT.java|   99 +
 .../apache/phoenix/end2end/DynamicFamilyIT.java |   23 +-
 .../org/apache/phoenix/end2end/GroupByIT.java   |   15 +
 .../org/apache/phoenix/end2end/HashJoinIT.java  |  596 +-
 .../phoenix/end2end/HashJoinLocalIndexIT.java   |  171 +
 .../org/apache/phoenix/end2end/InListIT.java|   23 +-
 .../org/apache/phoenix/end2end/KeyOnlyIT.java   |2 +-
 .../end2end/MinMaxAggregateFunctionIT.java  |   86 +
 .../phoenix/end2end/ParallelIteratorsIT.java|4 +-
 .../apache/phoenix/end2end/PercentileIT.java|7 +-
 .../phoenix/end2end/PhoenixRuntimeIT.java   |  138 +
 .../phoenix/end2end/PointInTimeQueryIT.java |  179 +
 .../phoenix/end2end/ProductMetricsIT.java   |   15 +-
 .../end2end/QueryDatabaseMetaDataIT.java|   59 +-
 .../org/apache/phoenix/end2end/QueryIT.java |  343 +-
 .../org/apache/phoenix/end2end/QueryMoreIT.java |   14 +
 .../apache/phoenix/end2end/QueryTimeoutIT.java  |   94 +
 .../phoenix/end2end/QueryWithLimitIT.java   |2 +-
 .../org/apache/phoenix/end2end/SequenceIT.java  |1 +
 .../apache/phoenix/end2end/SkipScanQueryIT.java |   90 +-
 .../apache/phoenix/end2end/SortMergeJoinIT.java |  363 +-
 .../end2end/StatsCollectorAbstractIT.java   |   77 +
 .../phoenix/end2end/StatsCollectorIT.java   |  185 +-
 .../StatsCollectorWithSplitsAndMultiCFIT.java   |  256 +
 .../apache/phoenix/end2end/StoreNullsIT.java|  226 +
 .../org/apache/phoenix/end2end/SubqueryIT.java  |  369 +-
 .../end2end/SubqueryUsingSortMergeJoinIT.java   |  906 +++
 .../end2end/TenantSpecificViewIndexIT.java  |7 +-
 .../phoenix/end2end/ToDateFunctionIT.java   |  179 +
 .../phoenix/end2end/ToNumberFunctionIT.java |6 +-
 .../phoenix/end2end/TruncateFunctionIT.java |6 +-
 .../apache/phoenix/end2end/UpsertSelectIT.java  |   18 +-
 .../apache/phoenix/end2end/UpsertValuesIT.java  |   99 +-
 .../phoenix/end2end/VariableLengthPKIT.java |   16 +-
 .../java/org/apache/phoenix/end2end/ViewIT.java |   61 +-
 .../phoenix/end2end/index/BaseIndexIT.java  |   30 -
 .../end2end/index/BaseMutableIndexIT.java   | 1212 ++-
 .../phoenix/end2end/index/DropViewIT.java   |2 +-
 .../index/GlobalIndexOptimizationIT.java|  469 ++
 .../end2end/index/GlobalMutableIndexIT.java |   26 +
 .../phoenix/end2end/index/ImmutableIndexIT.java |   83 +-
 .../end2end/index/IndexExpressionIT.java| 1267 +++
 .../phoenix/end2end/index/IndexMetadataIT.java  |   65 +-
 .../phoenix/end2end/index/IndexTestUtil.java|2 +-
 .../phoenix/end2end/index/LocalIndexIT.java |  497 +-
 .../end2end/index/LocalMutableIndexIT.java  |   26 +
 .../phoenix/end2end/index/MutableIndexIT.java   | 1344

phoenix git commit: Make projection work with new Phoenix master

2015-03-04 Thread maryannxue
Repository: phoenix
Updated Branches:
  refs/heads/calcite 026f60b12 -> de6c14a14


Make projection work with new Phoenix master


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/de6c14a1
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/de6c14a1
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/de6c14a1

Branch: refs/heads/calcite
Commit: de6c14a14d7ab65f8236744199a7f870c003510f
Parents: 026f60b
Author: maryannxue 
Authored: Thu Mar 5 00:06:16 2015 -0500
Committer: maryannxue 
Committed: Thu Mar 5 00:06:16 2015 -0500

--
 .../org/apache/phoenix/calcite/CalciteTest.java |  4 +-
 .../apache/phoenix/calcite/PhoenixProject.java  |  2 +-
 .../org/apache/phoenix/calcite/PhoenixRel.java  |  4 +-
 .../calcite/PhoenixRelImplementorImpl.java  | 89 
 .../expression/ProjectedColumnExpression.java   |  9 ++
 5 files changed, 87 insertions(+), 21 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/de6c14a1/phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteTest.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteTest.java 
b/phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteTest.java
index 9bce0a3..6604bde 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteTest.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/calcite/CalciteTest.java
@@ -182,9 +182,9 @@ public class CalciteTest extends BaseClientManagedTimeIT {
 new PhoenixSchema(phoenixConnection));
 calciteConnection.setSchema("phoenix");
 final Statement statement = calciteConnection.createStatement();
-final ResultSet resultSet = statement.executeQuery("select * from 
aTable where a_string = 'a'");
+final ResultSet resultSet = statement.executeQuery("select entity_id, 
a_string, organization_id from aTable where a_string = 'a'");
 while (resultSet.next()) {
-System.out.println("org_id=" + resultSet.getObject(1) + 
",entity_id=" + resultSet.getObject(2) + ",a_string=" + 
resultSet.getObject("A_STRING"));
+System.out.println("org_id=" + resultSet.getObject(3) + 
",entity_id=" + resultSet.getObject(1) + ",a_string=" + 
resultSet.getObject("A_STRING"));
 }
 resultSet.close();
 statement.close();

http://git-wip-us.apache.org/repos/asf/phoenix/blob/de6c14a1/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixProject.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixProject.java 
b/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixProject.java
index 2e90397..8a1b6b7 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixProject.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixProject.java
@@ -34,7 +34,7 @@ public class PhoenixProject extends Project implements 
PhoenixRel {
 
 @Override
 public void implement(Implementor implementor, PhoenixConnection conn) {
+implementor.setProjects(getProjects());
 implementor.visitInput(0, (PhoenixRel) getInput());
-throw new UnsupportedOperationException();
 }
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/de6c14a1/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixRel.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixRel.java 
b/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixRel.java
index c255e90..95088a2 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixRel.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixRel.java
@@ -1,10 +1,11 @@
 package org.apache.phoenix.calcite;
 
+import java.util.List;
+
 import org.apache.calcite.plan.Convention;
 import org.apache.calcite.rel.RelNode;
 import org.apache.calcite.rex.RexNode;
 import org.apache.phoenix.compile.QueryPlan;
-import org.apache.phoenix.compile.RowProjector;
 import org.apache.phoenix.expression.ColumnExpression;
 import org.apache.phoenix.jdbc.PhoenixConnection;
 import org.apache.phoenix.schema.PTable;
@@ -33,6 +34,7 @@ public interface PhoenixRel extends RelNode {
   interface Implementor {
 void visitInput(int i, PhoenixRel input);
 ColumnExpression newColumnExpression(int index);
+void setProjects(List projects);
 void setContext(PhoenixConnection conn, PTable pTable, RexNode filter);
 QueryPlan makePlan();
   }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/de6c14a1/phoenix-core/src/main/java/org/apache/phoenix/calcite/PhoenixRelImplementorImpl.java
-