You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by jb...@apache.org on 2022/11/29 17:26:31 UTC

[calcite] branch main updated: [CALCITE-5259] Add getParameterRowType method to Planner interface

This is an automated email from the ASF dual-hosted git repository.

jbalint pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/calcite.git


The following commit(s) were added to refs/heads/main by this push:
     new 531dc3d3fa [CALCITE-5259] Add getParameterRowType method to Planner interface
531dc3d3fa is described below

commit 531dc3d3fab1f882dd609f419683177df6c57c77
Author: dssysolyatin <dm...@gmail.com>
AuthorDate: Thu Sep 1 12:25:42 2022 +0300

    [CALCITE-5259] Add getParameterRowType method to Planner interface
---
 core/src/main/java/org/apache/calcite/prepare/PlannerImpl.java | 9 +++++++++
 core/src/main/java/org/apache/calcite/tools/Planner.java       | 8 ++++++++
 2 files changed, 17 insertions(+)

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 a16c5a8a27..a845129135 100644
--- a/core/src/main/java/org/apache/calcite/prepare/PlannerImpl.java
+++ b/core/src/main/java/org/apache/calcite/prepare/PlannerImpl.java
@@ -237,6 +237,15 @@ public class PlannerImpl implements Planner, ViewExpander {
     return Pair.of(validatedNode, type);
   }
 
+  @Override public RelDataType getParameterRowType() {
+    if (state.ordinal() < State.STATE_4_VALIDATED.ordinal()) {
+      throw new RuntimeException("Need to call #validate() first");
+    }
+
+    return requireNonNull(validator, "validator")
+        .getParameterRowType(requireNonNull(validatedSqlNode, "validatedSqlNode"));
+  }
+
   @SuppressWarnings("deprecation")
   @Override public final RelNode convert(SqlNode sql) {
     return rel(sql).rel;
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 11de3da0d8..afaf160c74 100644
--- a/core/src/main/java/org/apache/calcite/tools/Planner.java
+++ b/core/src/main/java/org/apache/calcite/tools/Planner.java
@@ -78,6 +78,14 @@ public interface Planner extends AutoCloseable {
    */
   Pair<SqlNode, RelDataType> validateAndGetType(SqlNode sqlNode) throws ValidationException;
 
+  /**
+   * Returns a record type that contains the name and type of each parameter.
+   * Returns a record type with no fields if there are no parameters.
+   *
+   * @return Record type
+   */
+  RelDataType getParameterRowType();
+
   /**
    * Converts a SQL parse tree into a tree of relational expressions.
    *