You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by pr...@apache.org on 2018/05/30 23:11:31 UTC
hive git commit: HIVE-19682: Provide option for GenericUDTFGetSplits
to return only schema metadata (Eric Wohlstadter reviewed by Prasanth
Jayachandran)
Repository: hive
Updated Branches:
refs/heads/branch-3 e600a348d -> d76686d81
HIVE-19682: Provide option for GenericUDTFGetSplits to return only schema metadata (Eric Wohlstadter reviewed by Prasanth Jayachandran)
Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/d76686d8
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/d76686d8
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/d76686d8
Branch: refs/heads/branch-3
Commit: d76686d81f0169616246789dad0edbb436b4edd0
Parents: e600a34
Author: Eric Wohlstadter <wo...@gmail.com>
Authored: Wed May 30 16:09:41 2018 -0700
Committer: Prasanth Jayachandran <pr...@apache.org>
Committed: Wed May 30 16:11:15 2018 -0700
----------------------------------------------------------------------
.../hive/ql/udf/generic/GenericUDTFGetSplits.java | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hive/blob/d76686d8/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDTFGetSplits.java
----------------------------------------------------------------------
diff --git a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDTFGetSplits.java b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDTFGetSplits.java
index 05d277f..7dbde7a 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDTFGetSplits.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDTFGetSplits.java
@@ -120,7 +120,8 @@ import com.google.common.base.Preconditions;
*
*/
@Description(name = "get_splits", value = "_FUNC_(string,int) - "
- + "Returns an array of length int serialized splits for the referenced tables string.")
+ + "Returns an array of length int serialized splits for the referenced tables string."
+ + " Passing length 0 returns only schema data for the compiled query.")
@UDFType(deterministic = false)
public class GenericUDTFGetSplits extends GenericUDTF {
private static final Logger LOG = LoggerFactory.getLogger(GenericUDTFGetSplits.class);
@@ -271,6 +272,10 @@ public class GenericUDTFGetSplits extends GenericUDTF {
}
List<Task<?>> roots = plan.getRootTasks();
Schema schema = convertSchema(plan.getResultSchema());
+ if(num == 0) {
+ //Schema only
+ return new PlanFragment(null, schema, null);
+ }
boolean fetchTask = plan.getFetchTask() != null;
TezWork tezWork;
if (roots == null || roots.size() != 1 || !(roots.get(0) instanceof TezTask)) {
@@ -361,6 +366,14 @@ public class GenericUDTFGetSplits extends GenericUDTF {
public InputSplit[] getSplits(JobConf job, int numSplits, TezWork work, Schema schema, ApplicationId applicationId)
throws IOException {
+ if(numSplits == 0) {
+ //Schema only
+ LlapInputSplit schemaSplit = new LlapInputSplit(
+ 0, new byte[0], new byte[0], new byte[0],
+ new SplitLocationInfo[0], schema, "", new byte[0]);
+ return new InputSplit[] { schemaSplit };
+ }
+
DAG dag = DAG.create(work.getName());
dag.setCredentials(job.getCredentials());