You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ja...@apache.org on 2014/01/27 23:15:35 UTC

[19/51] [partial] Initial commit of master branch from github

http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/50d523f6/phoenix-core/src/main/java/org/apache/phoenix/parse/ArrayConstructorNode.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/ArrayConstructorNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/ArrayConstructorNode.java
new file mode 100644
index 0000000..7d62b32
--- /dev/null
+++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/ArrayConstructorNode.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2010 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 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;
+
+/**
+ * Holds the list of array elements that will be used by the upsert stmt with ARRAY column 
+ *
+ */
+public class ArrayConstructorNode extends CompoundParseNode {
+
+	public ArrayConstructorNode(List<ParseNode> children) {
+		super(children);
+	}
+
+	@Override
+	public <T> T accept(ParseNodeVisitor<T> visitor) throws SQLException {
+		List<T> l = Collections.emptyList();
+        if (visitor.visitEnter(this)) {
+            l = acceptChildren(visitor);
+        }
+        return visitor.visitLeave(this, l);
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/50d523f6/phoenix-core/src/main/java/org/apache/phoenix/parse/AvgAggregateParseNode.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/AvgAggregateParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/AvgAggregateParseNode.java
new file mode 100644
index 0000000..0b944c0
--- /dev/null
+++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/AvgAggregateParseNode.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2010 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 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.List;
+
+import org.apache.phoenix.compile.StatementContext;
+import org.apache.phoenix.expression.Expression;
+import org.apache.phoenix.expression.function.*;
+
+
+public class AvgAggregateParseNode extends AggregateFunctionParseNode {
+
+    public AvgAggregateParseNode(String name, List<ParseNode> children, BuiltInFunctionInfo info) {
+        super(name, children, info);
+    }
+
+    @Override
+    public FunctionExpression create(List<Expression> children, StatementContext context) throws SQLException {
+        SumAggregateFunction sumFunc;
+        CountAggregateFunction countFunc = (CountAggregateFunction)context.getExpressionManager().addIfAbsent(new CountAggregateFunction(children));
+        if (!countFunc.isConstantExpression()) {
+            sumFunc = (SumAggregateFunction)context.getExpressionManager().addIfAbsent(new SumAggregateFunction(countFunc.getChildren(),null));
+        } else {
+            sumFunc = null;
+        }
+
+        return new AvgAggregateFunction(children, countFunc, sumFunc);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/50d523f6/phoenix-core/src/main/java/org/apache/phoenix/parse/BaseParseNodeVisitor.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/BaseParseNodeVisitor.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/BaseParseNodeVisitor.java
new file mode 100644
index 0000000..233d5ec
--- /dev/null
+++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/BaseParseNodeVisitor.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2010 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 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.sql.SQLFeatureNotSupportedException;
+import java.util.List;
+
+
+
+/**
+ * 
+ * Base class for parse node visitors.
+ *
+ * @author jtaylor
+ * @since 0.1
+ */
+public abstract class BaseParseNodeVisitor<E> implements ParseNodeVisitor<E> {
+
+    /**
+     * Fall through visitEnter method. Anything coming through
+     * here means that a more specific method wasn't found
+     * and thus this CompoundNode is not yet supported.
+     */
+    @Override
+    public boolean visitEnter(CompoundParseNode expressionNode) throws SQLException {
+        throw new SQLFeatureNotSupportedException(expressionNode.toString());
+    }
+
+    @Override
+    public E visitLeave(CompoundParseNode expressionNode, List<E> l) throws SQLException {
+        throw new SQLFeatureNotSupportedException(expressionNode.toString());
+    }
+
+    /**
+     * Fall through visit method. Anything coming through
+     * here means that a more specific method wasn't found
+     * and thus this Node is not yet supported.
+     */
+    @Override
+    public E visit(ParseNode expressionNode) throws SQLException {
+        throw new SQLFeatureNotSupportedException(expressionNode.toString());
+    }
+    
+    @Override
+    public List<E> newElementList(int size) {
+        return null;
+    }
+    
+    @Override
+    public void addElement(List<E> l, E element) {
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/50d523f6/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
new file mode 100644
index 0000000..6306d67
--- /dev/null
+++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/BetweenParseNode.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2010 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 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.*;
+
+
+
+/**
+ * 
+ * Node representing BETWEEN in SQL
+ *
+ * @author jtaylor
+ * @since 0.1
+ */
+public class BetweenParseNode extends CompoundParseNode {
+    private final boolean negate;
+
+    BetweenParseNode(ParseNode l, ParseNode r1, ParseNode r2, boolean negate) {
+        super(Arrays.asList(l, r1, r2));
+        this.negate = negate;
+    }
+    
+    public boolean isNegate() {
+        return negate;
+    }
+    
+    @Override
+    public <T> T accept(ParseNodeVisitor<T> visitor) throws SQLException {
+        List<T> l = Collections.emptyList();
+        if (visitor.visitEnter(this)) {
+            l = acceptChildren(visitor);
+        }
+        return visitor.visitLeave(this, l);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/50d523f6/phoenix-core/src/main/java/org/apache/phoenix/parse/BinaryParseNode.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/BinaryParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/BinaryParseNode.java
new file mode 100644
index 0000000..82695f5
--- /dev/null
+++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/BinaryParseNode.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2010 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 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.util.Arrays;
+
+/**
+ * 
+ * Abstract class for operators that operate on exactly two nodes
+ *
+ * @author jtaylor
+ * @since 0.1
+ */
+public abstract class BinaryParseNode extends CompoundParseNode {
+
+    BinaryParseNode(ParseNode lhs, ParseNode rhs) {
+        super(Arrays.asList(lhs, rhs));
+    }
+
+    public ParseNode getLHS() {
+        return getChildren().get(0);
+    }
+    
+    public ParseNode getRHS() {
+        return getChildren().get(1);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/50d523f6/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
new file mode 100644
index 0000000..5d4f173
--- /dev/null
+++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/BindParseNode.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2010 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 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;
+
+
+
+/**
+ * 
+ * Node representing a bind variable in a SQL expression
+ *
+ * @author jtaylor
+ * @since 0.1
+ */
+public class BindParseNode extends NamedParseNode {
+    private final int index;
+    
+    BindParseNode(String name) {
+        super(name);
+        index = Integer.parseInt(name);
+    }
+    
+    public int getIndex() {
+        return index-1;
+    }
+
+    @Override
+    public <T> T accept(ParseNodeVisitor<T> visitor) throws SQLException {
+        return visitor.visit(this);
+    }
+
+    
+    @Override
+    public boolean isStateless() {
+        return true;
+    }
+    
+    @Override
+    public String toString() {
+        return ":" + index;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/50d523f6/phoenix-core/src/main/java/org/apache/phoenix/parse/BindTableNode.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/BindTableNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/BindTableNode.java
new file mode 100644
index 0000000..7aca261
--- /dev/null
+++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/BindTableNode.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2010 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 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;
+
+
+
+/**
+ * 
+ * Node representing a TABLE bound using an ARRAY variable
+ * TODO: modify grammar to support this
+ * @author jtaylor
+ * @since 0.1
+ */
+public class BindTableNode extends ConcreteTableNode {
+
+    BindTableNode(String alias, TableName name) {
+        super(alias, name);
+    }
+
+    @Override
+    public void accept(TableNodeVisitor visitor) throws SQLException {
+        visitor.visit(this);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/50d523f6/phoenix-core/src/main/java/org/apache/phoenix/parse/BindableStatement.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/BindableStatement.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/BindableStatement.java
new file mode 100644
index 0000000..7ce9162
--- /dev/null
+++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/BindableStatement.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2010 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 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;
+
+
+public interface BindableStatement {
+    public int getBindCount();
+}

http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/50d523f6/phoenix-core/src/main/java/org/apache/phoenix/parse/CaseParseNode.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/CaseParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/CaseParseNode.java
new file mode 100644
index 0000000..bd04490
--- /dev/null
+++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/CaseParseNode.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2010 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 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 a CASE in SQL
+ *
+ * @author jtaylor
+ * @since 0.1
+ */
+public class CaseParseNode extends CompoundParseNode {
+
+    CaseParseNode(List<ParseNode> children) {
+        super(children);
+    }
+
+    @Override
+    public <T> T accept(ParseNodeVisitor<T> visitor) throws SQLException {
+        List<T> l = Collections.emptyList();
+        if (visitor.visitEnter(this)) {
+            l = acceptChildren(visitor);
+        }
+        return visitor.visitLeave(this, l);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/50d523f6/phoenix-core/src/main/java/org/apache/phoenix/parse/CastParseNode.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/CastParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/CastParseNode.java
new file mode 100644
index 0000000..24cae70
--- /dev/null
+++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/CastParseNode.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2010 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 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;
+
+import org.apache.phoenix.expression.Expression;
+import org.apache.phoenix.expression.function.RoundDecimalExpression;
+import org.apache.phoenix.expression.function.RoundTimestampExpression;
+import org.apache.phoenix.schema.PDataType;
+import org.apache.phoenix.schema.TypeMismatchException;
+
+/**
+ * 
+ * Node representing the CAST operator in SQL.
+ * 
+ * @author samarth.jain
+ * @since 0.1
+ *
+ */
+public class CastParseNode extends UnaryParseNode {
+	
+	private final PDataType dt;
+	
+	CastParseNode(ParseNode expr, String dataType) {
+		super(expr);
+		dt = PDataType.fromSqlTypeName(dataType);
+	}
+	
+	CastParseNode(ParseNode expr, PDataType dataType) {
+		super(expr);
+		dt = dataType;
+	}
+
+	@Override
+    public <T> T accept(ParseNodeVisitor<T> visitor) throws SQLException {
+        List<T> l = Collections.emptyList();
+        if (visitor.visitEnter(this)) {
+            l = acceptChildren(visitor);
+        }
+        return visitor.visitLeave(this, l);
+    }
+
+	public PDataType getDataType() {
+		return dt;
+	}
+	
+	public static Expression convertToRoundExpressionIfNeeded(PDataType fromDataType, PDataType targetDataType, List<Expression> expressions) throws SQLException {
+	    Expression firstChildExpr = expressions.get(0);
+	    if(fromDataType == targetDataType) {
+	        return firstChildExpr;
+	    } else if(fromDataType == PDataType.DECIMAL && targetDataType.isCoercibleTo(PDataType.LONG)) {
+	        return new RoundDecimalExpression(expressions);
+	    } else if((fromDataType == PDataType.TIMESTAMP || fromDataType == PDataType.UNSIGNED_TIMESTAMP) && targetDataType.isCoercibleTo(PDataType.DATE)) {
+	        return RoundTimestampExpression.create(expressions);
+	    } else if(!fromDataType.isCoercibleTo(targetDataType)) {
+	        throw TypeMismatchException.newException(fromDataType, targetDataType, firstChildExpr.toString());
+	    }
+	    return firstChildExpr;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/50d523f6/phoenix-core/src/main/java/org/apache/phoenix/parse/CeilParseNode.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/CeilParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/CeilParseNode.java
new file mode 100644
index 0000000..b041c84
--- /dev/null
+++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/CeilParseNode.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2010 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 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.List;
+
+import org.apache.phoenix.compile.StatementContext;
+import org.apache.phoenix.expression.Expression;
+import org.apache.phoenix.expression.function.CeilDateExpression;
+import org.apache.phoenix.expression.function.CeilDecimalExpression;
+import org.apache.phoenix.expression.function.CeilFunction;
+import org.apache.phoenix.expression.function.CeilTimestampExpression;
+import org.apache.phoenix.schema.PDataType;
+import org.apache.phoenix.schema.TypeMismatchException;
+
+/**
+ * Parse node corresponding to {@link CeilFunction}. 
+ * It also acts as a factory for creating the right kind of
+ * ceil expression according to the data type of the 
+ * first child.
+ *
+ * @author samarth.jain
+ * @since 3.0.0
+ */
+public class CeilParseNode extends FunctionParseNode {
+    
+    CeilParseNode(String name, List<ParseNode> children, BuiltInFunctionInfo info) {
+        super(name, children, info);
+    }
+    
+    @Override
+    public Expression create(List<Expression> children, StatementContext context) throws SQLException {
+        return getCeilExpression(children);
+    }
+    
+    public static Expression getCeilExpression(List<Expression> children) throws SQLException {
+        final Expression firstChild = children.get(0);
+        final PDataType firstChildDataType = firstChild.getDataType();
+        if(firstChildDataType.isCoercibleTo(PDataType.DATE)) {
+            return CeilDateExpression.create(children);
+        } else if (firstChildDataType == PDataType.TIMESTAMP || firstChildDataType == PDataType.UNSIGNED_TIMESTAMP) {
+            return CeilTimestampExpression.create(children);
+        } else if(firstChildDataType.isCoercibleTo(PDataType.DECIMAL)) {
+            return new CeilDecimalExpression(children);
+        } else {
+            throw TypeMismatchException.newException(firstChildDataType, "1");
+        }
+    }
+    
+    /**
+     * When ceiling off decimals, user need not specify the scale. In such cases, 
+     * we need to prevent the function from getting evaluated as null. This is really
+     * a hack. A better way would have been if {@link org.apache.phoenix.parse.FunctionParseNode.BuiltInFunctionInfo} provided a 
+     * way of associating default values for each permissible data type.
+     * Something like: @ Argument(allowedTypes={PDataType.VARCHAR, PDataType.INTEGER}, defaultValues = {"null", "1"} isConstant=true)
+     * Till then, this will have to do.
+     */
+    @Override
+    public boolean evalToNullIfParamIsNull(StatementContext context, int index) throws SQLException {
+        return index == 0;
+    }
+    
+    
+}   

http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/50d523f6/phoenix-core/src/main/java/org/apache/phoenix/parse/ColumnDef.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/ColumnDef.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/ColumnDef.java
new file mode 100644
index 0000000..183da7c
--- /dev/null
+++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/ColumnDef.java
@@ -0,0 +1,178 @@
+/*
+ * Copyright 2010 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 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 org.apache.phoenix.exception.SQLExceptionCode;
+import org.apache.phoenix.exception.SQLExceptionInfo;
+import org.apache.phoenix.schema.ColumnModifier;
+import org.apache.phoenix.schema.PDataType;
+import org.apache.phoenix.util.SchemaUtil;
+
+
+/**
+ * 
+ * Represents a column definition during DDL
+ *
+ * @author jtaylor
+ * @since 0.1
+ */
+public class ColumnDef {
+    private final ColumnName columnDefName;
+    private PDataType dataType;
+    private final boolean isNull;
+    private final Integer maxLength;
+    private final Integer scale;
+    private final boolean isPK;
+    private final ColumnModifier columnModifier;
+    private final boolean isArray;
+    private final Integer arrSize;
+ 
+    ColumnDef(ColumnName columnDefName, String sqlTypeName, boolean isArray, Integer arrSize, boolean isNull, Integer maxLength,
+    		            Integer scale, boolean isPK, ColumnModifier columnModifier) {
+   	 try {
+   	     PDataType localType = null;
+         this.columnDefName = columnDefName;
+         this.isArray = isArray;
+         // TODO : Add correctness check for arrSize.  Should this be ignored as in postgres
+         // Also add what is the limit that we would support.  Are we going to support a
+         //  fixed size or like postgres allow infinite.  May be the data types max limit can 
+         // be used for the array size (May be too big)
+         if(this.isArray) {
+        	 localType = sqlTypeName == null ? null : PDataType.fromTypeId(PDataType.sqlArrayType(SchemaUtil.normalizeIdentifier(sqlTypeName)));
+        	 this.dataType = sqlTypeName == null ? null : PDataType.fromSqlTypeName(SchemaUtil.normalizeIdentifier(sqlTypeName));
+             this.arrSize = arrSize; // Can only be non negative based on parsing
+         } else {
+             this.dataType = sqlTypeName == null ? null : PDataType.fromSqlTypeName(SchemaUtil.normalizeIdentifier(sqlTypeName));
+             this.arrSize = null;
+         }
+         
+         this.isNull = isNull;
+         if (this.dataType == PDataType.CHAR) {
+             if (maxLength == null) {
+                 throw new SQLExceptionInfo.Builder(SQLExceptionCode.MISSING_CHAR_LENGTH)
+                     .setColumnName(columnDefName.getColumnName()).build().buildException();
+             }
+             if (maxLength < 1) {
+                 throw new SQLExceptionInfo.Builder(SQLExceptionCode.NONPOSITIVE_CHAR_LENGTH)
+                     .setColumnName(columnDefName.getColumnName()).build().buildException();
+             }
+             scale = null;
+         } else if (this.dataType == PDataType.VARCHAR) {
+             if (maxLength != null && maxLength < 1) {
+                 throw new SQLExceptionInfo.Builder(SQLExceptionCode.NONPOSITIVE_CHAR_LENGTH)
+                     .setColumnName(columnDefName.getColumnName()).build().buildException(); 
+             }
+             scale = null;
+         } else if (this.dataType == PDataType.DECIMAL) {
+         	Integer origMaxLength = maxLength;
+             maxLength = maxLength == null ? PDataType.MAX_PRECISION : maxLength;
+             // for deciaml, 1 <= maxLength <= PDataType.MAX_PRECISION;
+             if (maxLength < 1 || maxLength > PDataType.MAX_PRECISION) {
+                 throw new SQLExceptionInfo.Builder(SQLExceptionCode.DECIMAL_PRECISION_OUT_OF_RANGE)
+                     .setColumnName(columnDefName.getColumnName()).build().buildException();
+             }
+             // When a precision is specified and a scale is not specified, it is set to 0. 
+             // 
+             // This is the standard as specified in
+             // http://docs.oracle.com/cd/B28359_01/server.111/b28318/datatype.htm#CNCPT1832
+             // and 
+             // http://docs.oracle.com/javadb/10.6.2.1/ref/rrefsqlj15260.html.
+             // Otherwise, if scale is bigger than maxLength, just set it to the maxLength;
+             //
+             // When neither a precision nor a scale is specified, the precision and scale is
+             // ignored. All decimal are stored with as much decimal points as possible.
+             scale = scale == null ? 
+             		origMaxLength == null ? null : PDataType.DEFAULT_SCALE : 
+             		scale > maxLength ? maxLength : scale; 
+         } else if (this.dataType == PDataType.BINARY) {
+             if (maxLength == null) {
+                 throw new SQLExceptionInfo.Builder(SQLExceptionCode.MISSING_BINARY_LENGTH)
+                     .setColumnName(columnDefName.getColumnName()).build().buildException();
+             }
+             if (maxLength < 1) {
+                 throw new SQLExceptionInfo.Builder(SQLExceptionCode.NONPOSITIVE_BINARY_LENGTH)
+                     .setColumnName(columnDefName.getColumnName()).build().buildException();
+             }
+             scale = null;
+         } else if (this.dataType == PDataType.INTEGER) {
+             maxLength = PDataType.INT_PRECISION;
+             scale = PDataType.ZERO;
+         } else if (this.dataType == PDataType.LONG) {
+             maxLength = PDataType.LONG_PRECISION;
+             scale = PDataType.ZERO;
+         } else {
+             // ignore maxLength and scale for other types.
+             maxLength = null;
+             scale = null;
+         }
+         this.maxLength = maxLength;
+         this.scale = scale;
+         this.isPK = isPK;
+         this.columnModifier = columnModifier;
+         if(this.isArray) {
+             this.dataType = localType;
+         }
+     } catch (SQLException e) {
+         throw new ParseException(e);
+     }
+    }
+    ColumnDef(ColumnName columnDefName, String sqlTypeName, boolean isNull, Integer maxLength,
+            Integer scale, boolean isPK, ColumnModifier columnModifier) {
+    	this(columnDefName, sqlTypeName, false, 0, isNull, maxLength, scale, isPK, columnModifier);
+    }
+
+    public ColumnName getColumnDefName() {
+        return columnDefName;
+    }
+
+    public PDataType getDataType() {
+        return dataType;
+    }
+
+    public boolean isNull() {
+        return isNull;
+    }
+
+    public Integer getMaxLength() {
+        return maxLength;
+    }
+
+    public Integer getScale() {
+        return scale;
+    }
+
+    public boolean isPK() {
+        return isPK;
+    }
+    
+    public ColumnModifier getColumnModifier() {
+    	return columnModifier;
+    }
+        
+	public boolean isArray() {
+		return isArray;
+	}
+
+	public Integer getArraySize() {
+		return arrSize;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/50d523f6/phoenix-core/src/main/java/org/apache/phoenix/parse/ColumnFamilyDef.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/ColumnFamilyDef.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/ColumnFamilyDef.java
new file mode 100644
index 0000000..5323066
--- /dev/null
+++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/ColumnFamilyDef.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2010 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 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.util.*;
+
+
+import com.google.common.collect.ImmutableList;
+import org.apache.phoenix.util.SchemaUtil;
+
+/**
+ * 
+ * Definition of a Column Family at DDL time
+ *
+ * @author jtaylor
+ * @since 0.1
+ */
+public class ColumnFamilyDef {
+    private final String name;
+    private final List<ColumnDef> columnDefs;
+    private final Map<String,Object> props;
+    
+    ColumnFamilyDef(String name, List<ColumnDef> columnDefs, Map<String,Object> props) {
+        this.name = SchemaUtil.normalizeIdentifier(name);
+        this.columnDefs = ImmutableList.copyOf(columnDefs);
+        this.props = props == null ? Collections.<String,Object>emptyMap() : props;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public List<ColumnDef> getColumnDefs() {
+        return columnDefs;
+    }
+
+    public Map<String,Object> getProps() {
+        return props;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/50d523f6/phoenix-core/src/main/java/org/apache/phoenix/parse/ColumnName.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/ColumnName.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/ColumnName.java
new file mode 100644
index 0000000..34511c7
--- /dev/null
+++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/ColumnName.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2010 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 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 org.apache.phoenix.util.SchemaUtil;
+
+
+public class ColumnName {
+    private final NamedNode familyNode;
+    private final NamedNode columnNode;
+    
+    public static ColumnName caseSensitiveColumnName(String familyName, String columnName) {
+        return new ColumnName(NamedNode.caseSensitiveNamedNode(familyName), NamedNode.caseSensitiveNamedNode(columnName));
+    }
+    
+    public static ColumnName caseSensitiveColumnName(String columnName) {
+        return new ColumnName(null, NamedNode.caseSensitiveNamedNode(columnName));
+    }
+    
+    public static ColumnName newColumnName(NamedNode columnName) {
+        return new ColumnName(null, columnName);
+    }
+    
+    public static ColumnName newColumnName(NamedNode familyName, NamedNode columnName) {
+        return new ColumnName(familyName, columnName);
+    }
+    
+    private ColumnName(NamedNode familyNode, NamedNode columnNode) {
+        this.familyNode = familyNode;
+        this.columnNode = columnNode;
+    }
+    
+
+    ColumnName(String familyName, String columnName) {
+        this.familyNode = familyName == null ? null : new NamedNode(familyName);
+        this.columnNode = new NamedNode(columnName);
+    }
+
+    ColumnName(String columnName) {
+        this(null, columnName);
+    }
+
+    public String getFamilyName() {
+        return familyNode == null ? null : familyNode.getName();
+    }
+
+    public String getColumnName() {
+        return columnNode.getName();
+    }
+
+    public NamedNode getFamilyNode() {
+        return familyNode;
+    }
+
+    public NamedNode getColumnNode() {
+        return columnNode;
+    }
+
+    @Override
+    public String toString() {
+        return SchemaUtil.getColumnName(getFamilyName(),getColumnName());
+    }
+    
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + columnNode.hashCode();
+        result = prime * result + ((familyNode == null) ? 0 : familyNode.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) return true;
+        if (obj == null) return false;
+        if (getClass() != obj.getClass()) return false;
+        ColumnName other = (ColumnName)obj;
+        if (!columnNode.equals(other.columnNode)) return false;
+        if (familyNode == null) {
+            if (other.familyNode != null) return false;
+        } else if (!familyNode.equals(other.familyNode)) return false;
+        return true;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/50d523f6/phoenix-core/src/main/java/org/apache/phoenix/parse/ColumnParseNode.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/ColumnParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/ColumnParseNode.java
new file mode 100644
index 0000000..33058e9
--- /dev/null
+++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/ColumnParseNode.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2010 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 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 org.apache.phoenix.query.QueryConstants;
+
+/**
+ * Node representing a reference to a column in a SQL expression
+ * 
+ * @author jtaylor
+ * @since 0.1
+ */
+public class ColumnParseNode extends NamedParseNode {
+    private final TableName tableName;
+    private final String fullName;
+    private final String alias;
+
+    public ColumnParseNode(TableName tableName, String name, String alias) {
+        // Upper case here so our Maps can depend on this (and we don't have to upper case and create a string on every
+        // lookup
+        super(name);
+        this.alias = alias;
+        this.tableName = tableName;
+        fullName = tableName == null ? getName() : tableName.toString() + QueryConstants.NAME_SEPARATOR + getName();
+    }
+
+    public ColumnParseNode(TableName tableName, String name) {
+        this(tableName, name, null);
+    }
+    
+    @Override
+    public <T> T accept(ParseNodeVisitor<T> visitor) throws SQLException {
+        return visitor.visit(this);
+    }
+
+    public String getTableName() {
+        return tableName == null ? null : tableName.getTableName();
+    }
+
+    public String getSchemaName() {
+        return tableName == null ? null : tableName.getSchemaName();
+    }
+
+    public String getFullName() {
+        return fullName;
+    }
+
+    @Override
+    public String getAlias() {
+        return alias;
+    }
+
+    @Override
+    public String toString() {
+        return fullName;
+    }
+
+    @Override
+    public int hashCode() {
+        return fullName.hashCode();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) return true;
+        if (obj == null) return false;
+        if (getClass() != obj.getClass()) return false;
+        ColumnParseNode other = (ColumnParseNode)obj;
+        return fullName.equals(other.fullName);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/50d523f6/phoenix-core/src/main/java/org/apache/phoenix/parse/ComparisonParseNode.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/ComparisonParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/ComparisonParseNode.java
new file mode 100644
index 0000000..1a50fb7
--- /dev/null
+++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/ComparisonParseNode.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2010 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 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;
+
+import org.apache.hadoop.hbase.filter.CompareFilter;
+
+/**
+ * 
+ * Common base class for =, >, >=, <, <=, !=
+ *
+ * @author jtaylor
+ * @since 0.1
+ */
+public abstract class ComparisonParseNode extends BinaryParseNode {
+
+    ComparisonParseNode(ParseNode lhs, ParseNode rhs) {
+        super(lhs, rhs);
+    }
+
+    @Override
+    public final <T> T accept(ParseNodeVisitor<T> visitor) throws SQLException {
+        List<T> l = Collections.emptyList();
+        if (visitor.visitEnter(this)) {
+            l = acceptChildren(visitor);
+        }
+        return visitor.visitLeave(this, l);
+    }
+
+    /**
+     * Return the comparison operator associated with the given comparison expression node
+     */
+    public abstract CompareFilter.CompareOp getFilterOp();
+    
+    /**
+     * Return the inverted operator for the CompareOp
+     */
+    public abstract CompareFilter.CompareOp getInvertFilterOp();
+}

http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/50d523f6/phoenix-core/src/main/java/org/apache/phoenix/parse/CompoundParseNode.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/CompoundParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/CompoundParseNode.java
new file mode 100644
index 0000000..45c196e
--- /dev/null
+++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/CompoundParseNode.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2010 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 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;
+
+
+
+/**
+ * 
+ * Abstract node representing an expression node that has children
+ *
+ * @author jtaylor
+ * @since 0.1
+ */
+public abstract class CompoundParseNode extends ParseNode {
+    private final List<ParseNode> children;
+    private final boolean isStateless;
+    
+    CompoundParseNode(List<ParseNode> children) {
+        this.children = Collections.unmodifiableList(children);
+        boolean isStateless = true;
+        for (ParseNode child : children) {
+            isStateless &= child.isStateless();
+            if (!isStateless) {
+                break;
+            }
+        }
+        this.isStateless = isStateless;
+    }
+    
+    @Override
+    public boolean isStateless() {
+        return isStateless;
+    }
+    
+    @Override
+    public final List<ParseNode> getChildren() {
+        return children;
+    }
+
+
+    final <T> List<T> acceptChildren(ParseNodeVisitor<T> visitor) throws SQLException {
+        List<T> l = visitor.newElementList(children.size());        
+        for (int i = 0; i < children.size(); i++) {
+            T e = children.get(i).accept(visitor);
+            visitor.addElement(l, e);
+        }
+        return l;
+    }
+
+    @Override
+    public String toString() {
+        return this.getClass().getName() + children.toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/50d523f6/phoenix-core/src/main/java/org/apache/phoenix/parse/ConcreteTableNode.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/ConcreteTableNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/ConcreteTableNode.java
new file mode 100644
index 0000000..cd00316
--- /dev/null
+++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/ConcreteTableNode.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2010 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 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 org.apache.phoenix.util.SchemaUtil;
+
+/**
+ * 
+ * Abstract node representing a table reference in the FROM clause in SQL
+ *
+ * @author jtaylor
+ * @since 0.1
+ */
+public abstract class ConcreteTableNode extends TableNode {
+    private final TableName name;
+
+    ConcreteTableNode(String alias, TableName name) {
+        super(SchemaUtil.normalizeIdentifier(alias));
+        this.name = name;
+    }
+
+    public TableName getName() {
+        return name;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/50d523f6/phoenix-core/src/main/java/org/apache/phoenix/parse/CreateIndexStatement.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/CreateIndexStatement.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/CreateIndexStatement.java
new file mode 100644
index 0000000..95d3233
--- /dev/null
+++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/CreateIndexStatement.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2010 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 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.util.Collections;
+import java.util.List;
+
+import org.apache.hadoop.hbase.util.Pair;
+
+import com.google.common.collect.ListMultimap;
+
+
+public class CreateIndexStatement extends SingleTableSQLStatement {
+    private final TableName indexTableName;
+    private final PrimaryKeyConstraint indexConstraint;
+    private final List<ColumnName> includeColumns;
+    private final List<ParseNode> splitNodes;
+    private final ListMultimap<String,Pair<String,Object>> props;
+    private final boolean ifNotExists;
+
+    public CreateIndexStatement(NamedNode indexTableName, NamedTableNode dataTable, 
+            PrimaryKeyConstraint indexConstraint, List<ColumnName> includeColumns, List<ParseNode> splits,
+            ListMultimap<String,Pair<String,Object>> props, boolean ifNotExists, int bindCount) {
+        super(dataTable, bindCount);
+        this.indexTableName =TableName.createNormalized(dataTable.getName().getSchemaName(),indexTableName.getName());
+        this.indexConstraint = indexConstraint == null ? PrimaryKeyConstraint.EMPTY : indexConstraint;
+        this.includeColumns = includeColumns == null ? Collections.<ColumnName>emptyList() : includeColumns;
+        this.splitNodes = splits == null ? Collections.<ParseNode>emptyList() : splits;
+        this.props = props;
+        this.ifNotExists = ifNotExists;
+    }
+
+    public PrimaryKeyConstraint getIndexConstraint() {
+        return indexConstraint;
+    }
+
+    public List<ColumnName> getIncludeColumns() {
+        return includeColumns;
+    }
+
+    public TableName getIndexTableName() {
+        return indexTableName;
+    }
+
+    public List<ParseNode> getSplitNodes() {
+        return splitNodes;
+    }
+
+    public ListMultimap<String,Pair<String,Object>> getProps() {
+        return props;
+    }
+
+    public boolean ifNotExists() {
+        return ifNotExists;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/50d523f6/phoenix-core/src/main/java/org/apache/phoenix/parse/CreateSequenceStatement.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/CreateSequenceStatement.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/CreateSequenceStatement.java
new file mode 100644
index 0000000..b24c076
--- /dev/null
+++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/CreateSequenceStatement.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2010 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 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;
+
+public class CreateSequenceStatement implements BindableStatement {
+
+	private final TableName sequenceName;
+	private final ParseNode startWith;
+	private final ParseNode incrementBy;
+    private final ParseNode cacheSize;
+    private final boolean ifNotExists;
+	private final int bindCount;
+
+	protected CreateSequenceStatement(TableName sequenceName, ParseNode startsWith, ParseNode incrementBy, ParseNode cacheSize, boolean ifNotExists, int bindCount) {
+		this.sequenceName = sequenceName;
+		this.startWith = startsWith == null ? LiteralParseNode.ONE : startsWith;
+		this.incrementBy = incrementBy == null ? LiteralParseNode.ONE : incrementBy;
+        this.cacheSize = cacheSize == null ? null : cacheSize;
+		this.ifNotExists = ifNotExists;
+		this.bindCount = bindCount;
+	}
+
+	@Override
+	public int getBindCount() {
+		return this.bindCount;
+	}
+	
+	public ParseNode getIncrementBy() {
+		return incrementBy;
+	}
+
+	public TableName getSequenceName() {
+		return sequenceName;
+	}
+
+    public ParseNode getCacheSize() {
+        return cacheSize;
+    }
+
+	public ParseNode getStartWith() {
+		return startWith;
+	}
+
+    public boolean ifNotExists() {
+        return ifNotExists;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/50d523f6/phoenix-core/src/main/java/org/apache/phoenix/parse/CreateTableStatement.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/CreateTableStatement.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/CreateTableStatement.java
new file mode 100644
index 0000000..9d6d551
--- /dev/null
+++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/CreateTableStatement.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2010 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 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.util.Collections;
+import java.util.List;
+
+import org.apache.hadoop.hbase.util.Pair;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableListMultimap;
+import com.google.common.collect.ListMultimap;
+import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData;
+import org.apache.phoenix.schema.PTableType;
+
+public class CreateTableStatement implements BindableStatement {
+    private final TableName tableName;
+    private final PTableType tableType;
+    private final List<ColumnDef> columns;
+    private final PrimaryKeyConstraint pkConstraint;
+    private final List<ParseNode> splitNodes;
+    private final int bindCount;
+    private final ListMultimap<String,Pair<String,Object>> props;
+    private final boolean ifNotExists;
+    private final TableName baseTableName;
+    private final ParseNode whereClause;
+    
+    protected CreateTableStatement(TableName tableName, ListMultimap<String,Pair<String,Object>> props, List<ColumnDef> columns, PrimaryKeyConstraint pkConstraint,
+            List<ParseNode> splitNodes, PTableType tableType, boolean ifNotExists, 
+            TableName baseTableName, ParseNode whereClause, int bindCount) {
+        this.tableName = tableName;
+        this.props = props == null ? ImmutableListMultimap.<String,Pair<String,Object>>of() : props;
+        this.tableType = PhoenixDatabaseMetaData.TYPE_SCHEMA.equals(tableName.getSchemaName()) ? PTableType.SYSTEM : tableType;
+        this.columns = columns == null ? ImmutableList.<ColumnDef>of() : ImmutableList.<ColumnDef>copyOf(columns);
+        this.pkConstraint = pkConstraint == null ? PrimaryKeyConstraint.EMPTY : pkConstraint;
+        this.splitNodes = splitNodes == null ? Collections.<ParseNode>emptyList() : ImmutableList.copyOf(splitNodes);
+        this.bindCount = bindCount;
+        this.ifNotExists = ifNotExists;
+        this.baseTableName = baseTableName;
+        this.whereClause = whereClause;
+    }
+    
+    public ParseNode getWhereClause() {
+        return whereClause;
+    }
+    
+    @Override
+    public int getBindCount() {
+        return bindCount;
+    }
+
+    public TableName getTableName() {
+        return tableName;
+    }
+
+    public TableName getBaseTableName() {
+        return baseTableName;
+    }
+
+    public List<ColumnDef> getColumnDefs() {
+        return columns;
+    }
+
+    public List<ParseNode> getSplitNodes() {
+        return splitNodes;
+    }
+
+    public PTableType getTableType() {
+        return tableType;
+    }
+
+    public ListMultimap<String,Pair<String,Object>> getProps() {
+        return props;
+    }
+
+    public boolean ifNotExists() {
+        return ifNotExists;
+    }
+
+    public PrimaryKeyConstraint getPrimaryKeyConstraint() {
+        return pkConstraint;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/50d523f6/phoenix-core/src/main/java/org/apache/phoenix/parse/CurrentDateParseNode.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/CurrentDateParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/CurrentDateParseNode.java
new file mode 100644
index 0000000..4ad29bc
--- /dev/null
+++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/CurrentDateParseNode.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2010 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 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.List;
+
+import org.apache.phoenix.compile.StatementContext;
+import org.apache.phoenix.expression.Expression;
+import org.apache.phoenix.expression.function.CurrentDateFunction;
+import org.apache.phoenix.expression.function.FunctionExpression;
+
+
+public class CurrentDateParseNode extends FunctionParseNode {
+
+    public CurrentDateParseNode(String name, List<ParseNode> children, BuiltInFunctionInfo info) {
+        super(name, children, info);
+    }
+
+    @Override
+    public FunctionExpression create(List<Expression> children, StatementContext context) throws SQLException {
+        return new CurrentDateFunction(context.getCurrentTime());
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/50d523f6/phoenix-core/src/main/java/org/apache/phoenix/parse/CurrentTimeParseNode.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/CurrentTimeParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/CurrentTimeParseNode.java
new file mode 100644
index 0000000..ede88a2
--- /dev/null
+++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/CurrentTimeParseNode.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2010 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 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.List;
+
+import org.apache.phoenix.compile.StatementContext;
+import org.apache.phoenix.expression.Expression;
+import org.apache.phoenix.expression.function.CurrentTimeFunction;
+import org.apache.phoenix.expression.function.FunctionExpression;
+
+
+public class CurrentTimeParseNode extends FunctionParseNode {
+
+    public CurrentTimeParseNode(String name, List<ParseNode> children, BuiltInFunctionInfo info) {
+        super(name, children, info);
+    }
+
+    @Override
+    public FunctionExpression create(List<Expression> children, StatementContext context) throws SQLException {
+        return new CurrentTimeFunction(context.getCurrentTime());
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/50d523f6/phoenix-core/src/main/java/org/apache/phoenix/parse/DelegateConstantToCountParseNode.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/DelegateConstantToCountParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/DelegateConstantToCountParseNode.java
new file mode 100644
index 0000000..8e436ce
--- /dev/null
+++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/DelegateConstantToCountParseNode.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2010 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 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.List;
+
+import org.apache.phoenix.compile.StatementContext;
+import org.apache.phoenix.expression.Expression;
+import org.apache.phoenix.expression.function.CountAggregateFunction;
+import org.apache.phoenix.expression.function.FunctionExpression;
+
+
+public abstract class DelegateConstantToCountParseNode extends AggregateFunctionParseNode {
+
+    public DelegateConstantToCountParseNode(String name, List<ParseNode> children, BuiltInFunctionInfo info) {
+        super(name, children, info);
+    }
+    
+    protected CountAggregateFunction getDelegateFunction(List<Expression> children, StatementContext context) {
+        CountAggregateFunction countFunc = null;
+        if (getChildren().get(0).isStateless()) {
+            countFunc = (CountAggregateFunction)context.getExpressionManager().addIfAbsent(new CountAggregateFunction(children));
+        }
+        return countFunc;
+    }
+    
+    @Override
+    public abstract FunctionExpression create(List<Expression> children, StatementContext context) throws SQLException;
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/50d523f6/phoenix-core/src/main/java/org/apache/phoenix/parse/DeleteStatement.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/DeleteStatement.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/DeleteStatement.java
new file mode 100644
index 0000000..8b23c9a
--- /dev/null
+++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/DeleteStatement.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2010 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 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.util.Collections;
+import java.util.List;
+
+public class DeleteStatement extends SingleTableSQLStatement implements FilterableStatement {
+    private final ParseNode whereNode;
+    private final List<OrderByNode> orderBy;
+    private final LimitNode limit;
+    private final HintNode hint;
+    
+    public DeleteStatement(NamedTableNode table, HintNode hint, ParseNode whereNode, List<OrderByNode> orderBy, LimitNode limit, int bindCount) {
+        super(table, bindCount);
+        this.whereNode = whereNode;
+        this.orderBy = orderBy == null ? Collections.<OrderByNode>emptyList() : orderBy;
+        this.limit = limit;
+        this.hint = hint == null ? HintNode.EMPTY_HINT_NODE : hint;
+    }
+
+    @Override
+    public ParseNode getWhere() {
+        return whereNode;
+    }
+
+    @Override
+    public List<OrderByNode> getOrderBy() {
+        return orderBy;
+    }
+
+    @Override
+    public LimitNode getLimit() {
+        return limit;
+    }
+
+    @Override
+    public HintNode getHint() {
+        return hint;
+    }
+
+    @Override
+    public boolean isDistinct() {
+        return false;
+    }
+
+    @Override
+    public boolean isAggregate() {
+        return false;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/50d523f6/phoenix-core/src/main/java/org/apache/phoenix/parse/DerivedTableNode.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/DerivedTableNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/DerivedTableNode.java
new file mode 100644
index 0000000..3d76698
--- /dev/null
+++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/DerivedTableNode.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2010 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 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;
+
+
+
+/**
+ * 
+ * Node representing a subselect in the FROM clause of SQL
+ *
+ * @author jtaylor
+ * @since 0.1
+ */
+public class DerivedTableNode extends TableNode {
+
+    private final SelectStatement select;
+
+    DerivedTableNode(String alias, SelectStatement select) {
+        super(alias);
+        this.select = select;
+    }
+
+    public SelectStatement getSelect() {
+        return select;
+    }
+
+    @Override
+    public void accept(TableNodeVisitor visitor) throws SQLException {
+        visitor.visit(this);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/50d523f6/phoenix-core/src/main/java/org/apache/phoenix/parse/DistinctCountParseNode.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/DistinctCountParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/DistinctCountParseNode.java
new file mode 100644
index 0000000..d270f2b
--- /dev/null
+++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/DistinctCountParseNode.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2010 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 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.List;
+
+import org.apache.phoenix.compile.StatementContext;
+import org.apache.phoenix.expression.Expression;
+import org.apache.phoenix.expression.function.DistinctCountAggregateFunction;
+import org.apache.phoenix.expression.function.FunctionExpression;
+
+/**
+ * 
+ * @author anoopsjohn
+ * @since 1.2.1
+ */
+public class DistinctCountParseNode extends DelegateConstantToCountParseNode {
+    
+    public DistinctCountParseNode(String name, List<ParseNode> children, BuiltInFunctionInfo info) {
+        super(name, children, info);
+    }
+
+    @Override
+    public FunctionExpression create(List<Expression> children, StatementContext context)
+            throws SQLException {
+        return new DistinctCountAggregateFunction(children, getDelegateFunction(children, context));
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/50d523f6/phoenix-core/src/main/java/org/apache/phoenix/parse/DivideParseNode.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/DivideParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/DivideParseNode.java
new file mode 100644
index 0000000..bef0d8c
--- /dev/null
+++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/DivideParseNode.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2010 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 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 division in a SQL expression
+ *
+ * @author jtaylor
+ * @since 0.1
+ */
+public class DivideParseNode extends ArithmeticParseNode {
+
+    DivideParseNode(List<ParseNode> children) {
+        super(children);
+    }
+
+    @Override
+    public <T> T accept(ParseNodeVisitor<T> visitor) throws SQLException {
+        List<T> l = Collections.emptyList();
+        if (visitor.visitEnter(this)) {
+            l = acceptChildren(visitor);
+        }
+        return visitor.visitLeave(this, l);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/50d523f6/phoenix-core/src/main/java/org/apache/phoenix/parse/DropColumnStatement.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/DropColumnStatement.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/DropColumnStatement.java
new file mode 100644
index 0000000..71cf099
--- /dev/null
+++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/DropColumnStatement.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2010 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 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.util.List;
+
+import org.apache.phoenix.schema.PTableType;
+
+public class DropColumnStatement extends AlterTableStatement {
+    private final List<ColumnName> columnRefs;
+    private final boolean ifExists;
+    
+    protected DropColumnStatement(NamedTableNode table, PTableType tableType, List<ColumnName> columnRefs, boolean ifExists) {
+        super(table, tableType);
+        this.columnRefs = columnRefs;
+        this.ifExists = ifExists;
+    }
+
+    public List<ColumnName> getColumnRefs() {
+        return columnRefs;
+    }
+
+    public boolean ifExists() {
+        return ifExists;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/50d523f6/phoenix-core/src/main/java/org/apache/phoenix/parse/DropIndexStatement.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/DropIndexStatement.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/DropIndexStatement.java
new file mode 100644
index 0000000..8a01622
--- /dev/null
+++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/DropIndexStatement.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2010 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 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;
+
+public class DropIndexStatement implements BindableStatement {
+    private final TableName tableName;
+    private final NamedNode indexName;
+    private final boolean ifExists;
+
+    public DropIndexStatement(NamedNode indexName, TableName tableName, boolean ifExists) {
+        this.indexName = indexName;
+        this.tableName = tableName;
+        this.ifExists = ifExists;
+    }
+
+    public TableName getTableName() {
+        return tableName;
+    }
+
+    public NamedNode getIndexName() {
+        return indexName;
+    }
+
+    @Override
+    public int getBindCount() {
+        return 0;
+    }
+
+    public boolean ifExists() {
+        return ifExists;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/50d523f6/phoenix-core/src/main/java/org/apache/phoenix/parse/DropSequenceStatement.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/DropSequenceStatement.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/DropSequenceStatement.java
new file mode 100644
index 0000000..6ae9652
--- /dev/null
+++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/DropSequenceStatement.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2010 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 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;
+
+public class DropSequenceStatement implements BindableStatement {
+
+    private final TableName sequenceName;
+    private final boolean ifExists;
+    private final int bindCount;
+
+    protected DropSequenceStatement(TableName sequenceName, boolean ifExists, int bindCount) {
+        this.sequenceName = sequenceName;
+        this.ifExists = ifExists;
+        this.bindCount = bindCount;
+    }
+
+    @Override
+    public int getBindCount() {
+        return bindCount;
+    }
+
+    public TableName getSequenceName() {
+        return sequenceName;
+    }
+
+    public boolean ifExists() {
+        return ifExists;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/50d523f6/phoenix-core/src/main/java/org/apache/phoenix/parse/DropTableStatement.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/DropTableStatement.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/DropTableStatement.java
new file mode 100644
index 0000000..22c4530
--- /dev/null
+++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/DropTableStatement.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2010 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 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 org.apache.phoenix.schema.PTableType;
+
+public class DropTableStatement implements BindableStatement {
+    private final TableName tableName;
+    private final boolean ifExists;
+    private final PTableType tableType;
+
+    protected DropTableStatement(TableName tableName, PTableType tableType, boolean ifExists) {
+        this.tableName = tableName;
+        this.tableType = tableType;
+        this.ifExists = ifExists;
+    }
+    
+    @Override
+    public int getBindCount() {
+        return 0; // No binds for DROP
+    }
+
+    public TableName getTableName() {
+        return tableName;
+    }
+
+    public PTableType getTableType() {
+        return tableType;
+    }
+
+    public boolean ifExists() {
+        return ifExists;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-phoenix/blob/50d523f6/phoenix-core/src/main/java/org/apache/phoenix/parse/EqualParseNode.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/parse/EqualParseNode.java b/phoenix-core/src/main/java/org/apache/phoenix/parse/EqualParseNode.java
new file mode 100644
index 0000000..bdefff9
--- /dev/null
+++ b/phoenix-core/src/main/java/org/apache/phoenix/parse/EqualParseNode.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2010 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 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 org.apache.hadoop.hbase.filter.CompareFilter.CompareOp;
+
+
+/**
+ * 
+ * Node representing the equal operator in SQL
+ *
+ * @author jtaylor
+ * @since 0.1
+ */
+public class EqualParseNode extends ComparisonParseNode {
+
+    EqualParseNode(ParseNode lhs, ParseNode rhs) {
+        super(lhs, rhs);
+    }
+
+    @Override
+    public CompareOp getFilterOp() {
+        return CompareOp.EQUAL;
+    }
+
+    @Override
+    public CompareOp getInvertFilterOp() {
+        return CompareOp.EQUAL;
+    }
+}