Github user mravi commented on a diff in the pull request:
https://github.com/apache/incubator-phoenix/pull/27#discussion_r11746444
--- Diff:
phoenix-pig/src/main/java/org/apache/phoenix/pig/util/QuerySchemaParserFunction.java
---
@@ -0,0 +1,103 @@
+/*
+ * 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 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.pig.util;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.hbase.util.Pair;
+import org.apache.phoenix.compile.ColumnProjector;
+import org.apache.phoenix.compile.QueryPlan;
+import org.apache.phoenix.jdbc.PhoenixStatement;
+import org.apache.phoenix.parse.SelectStatement;
+import org.apache.phoenix.pig.PhoenixPigConfiguration;
+
+import com.google.common.base.Function;
+import com.google.common.base.Joiner;
+import com.google.common.base.Preconditions;
+import com.google.common.base.Throwables;
+import com.google.common.collect.Lists;
+
+/**
+ *
+ * A function to parse the select query passed to LOAD into a Pair of
<table Name, List<columns>
+ *
+ */
+public class QuerySchemaParserFunction implements
Function<String,Pair<String,String>> {
+
+ private static final Log LOG =
LogFactory.getLog(QuerySchemaParserFunction.class);
+ private PhoenixPigConfiguration phoenixConfiguration;
+
+ public QuerySchemaParserFunction(PhoenixPigConfiguration
phoenixConfiguration) {
+ Preconditions.checkNotNull(phoenixConfiguration);
+ this.phoenixConfiguration = phoenixConfiguration;
+ }
+
+ @Override
+ public Pair<String, String> apply(final String selectStatement) {
--- End diff --
I have created a new method isValidStatement() where all validations on
the SQL statement is done. Currently, the javadoc for it is
/**
* The method validates the statement passed to the query plan. List of
conditions are
* <ol>
* <li>Is a SELECT statement</li>
* <li>doesn't contain ORDER BY expression</li>
* <li>doesn't contain LIMIT</li>
* <li>doesn't contain GROUP BY expression</li>
* <li>doesn't contain DISTINCT</li>
* <li>doesn't contain AGGREGATE functions</li>
* </ol>
In the final write up document, I will have this specified explicitly.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---