calcite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jh...@apache.org
Subject [37/50] [abbrv] calcite git commit: [CALCITE-975] Allow Planner to return validated row type together with SqlNode
Date Thu, 21 Jan 2016 22:39:14 GMT
[CALCITE-975] Allow Planner to return validated row type together with SqlNode

close apache/calcite#184


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

Branch: refs/heads/branch-release
Commit: 0045e01f6178df5bcc8caf780040f3cff159bb20
Parents: a67b4a9
Author: Jinfeng Ni <jni@maprtech.com>
Authored: Tue Apr 7 03:34:06 2015 -0700
Committer: Julian Hyde <jhyde@apache.org>
Committed: Tue Jan 12 10:22:09 2016 -0800

----------------------------------------------------------------------
 .../java/org/apache/calcite/prepare/PlannerImpl.java     |  9 +++++++++
 core/src/main/java/org/apache/calcite/tools/Planner.java | 11 +++++++++++
 2 files changed, 20 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/calcite/blob/0045e01f/core/src/main/java/org/apache/calcite/prepare/PlannerImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/prepare/PlannerImpl.java b/core/src/main/java/org/apache/calcite/prepare/PlannerImpl.java
index d75d9c9..18d9746 100644
--- a/core/src/main/java/org/apache/calcite/prepare/PlannerImpl.java
+++ b/core/src/main/java/org/apache/calcite/prepare/PlannerImpl.java
@@ -44,6 +44,7 @@ import org.apache.calcite.tools.Planner;
 import org.apache.calcite.tools.Program;
 import org.apache.calcite.tools.RelConversionException;
 import org.apache.calcite.tools.ValidationException;
+import org.apache.calcite.util.Pair;
 import org.apache.calcite.util.Util;
 
 import com.google.common.collect.ImmutableList;
@@ -180,6 +181,14 @@ public class PlannerImpl implements Planner {
     return validatedSqlNode;
   }
 
+  public Pair<SqlNode, RelDataType> validateAndGetType(SqlNode sqlNode)
+      throws ValidationException {
+    final SqlNode validatedNode = this.validate(sqlNode);
+    final RelDataType type =
+        this.validator.getValidatedNodeType(validatedNode);
+    return Pair.of(validatedNode, type);
+  }
+
   public final RelNode convert(SqlNode sql) throws RelConversionException {
     return rel(sql).rel;
   }

http://git-wip-us.apache.org/repos/asf/calcite/blob/0045e01f/core/src/main/java/org/apache/calcite/tools/Planner.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/tools/Planner.java b/core/src/main/java/org/apache/calcite/tools/Planner.java
index 73c8047..8b2b25d 100644
--- a/core/src/main/java/org/apache/calcite/tools/Planner.java
+++ b/core/src/main/java/org/apache/calcite/tools/Planner.java
@@ -19,9 +19,11 @@ package org.apache.calcite.tools;
 import org.apache.calcite.plan.RelTraitSet;
 import org.apache.calcite.rel.RelNode;
 import org.apache.calcite.rel.RelRoot;
+import org.apache.calcite.rel.type.RelDataType;
 import org.apache.calcite.rel.type.RelDataTypeFactory;
 import org.apache.calcite.sql.SqlNode;
 import org.apache.calcite.sql.parser.SqlParseException;
+import org.apache.calcite.util.Pair;
 
 /**
  * A fa&ccedil;ade that covers Calcite's query planning process: parse SQL,
@@ -53,6 +55,15 @@ public interface Planner {
   SqlNode validate(SqlNode sqlNode) throws ValidationException;
 
   /**
+   * Validates a SQL statement.
+   *
+   * @param sqlNode Root node of the SQL parse tree.
+   * @return Validated node and its validated type.
+   * @throws ValidationException if not valid
+   */
+  Pair<SqlNode, RelDataType> validateAndGetType(SqlNode sqlNode) throws ValidationException;
+
+  /**
    * Converts a SQL parse tree into a tree of relational expressions.
    *
    * <p>You must call {@link #validate(org.apache.calcite.sql.SqlNode)} first.


Mime
View raw message