[ 
https://issues.apache.org/jira/browse/DRILL-7406?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17004228#comment-17004228
 ] 

ASF GitHub Bot commented on DRILL-7406:
---------------------------------------

vvysotskyi commented on pull request #1940: DRILL-7406: Update Calcite to 1.21.0
URL: https://github.com/apache/drill/pull/1940#discussion_r361660974
 
 

 ##########
 File path: 
exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/DrillConvertletTable.java
 ##########
 @@ -138,14 +105,209 @@ public SqlRexConvertlet get(SqlCall call) {
       ((SqlBasicCall) call).setOperator(wrapper);
       return sqlRexConvertlet;
     }
-
-    if ((convertlet = map.get(call.getOperator())) != null) {
+    if ((convertlet = operatorToConvertletMap.get(call.getOperator())) != 
null) {
       return convertlet;
     }
-
     return StandardConvertletTable.INSTANCE.get(call);
   }
 
-  private DrillConvertletTable() {
+  /**
+   * Custom convertlet to handle extract functions. Optiq rewrites
+   * extract functions as divide and modulo functions, based on the
+   * data type. We cannot do that in Drill since we don't know the data type
+   * till we start scanning. So we don't rewrite extract and treat it as
+   * a regular function.
+   */
+  private SqlRexConvertlet extract() {
+    return (cx, call) -> {
+      final RexBuilder rexBuilder = cx.getRexBuilder();
+      final List<SqlNode> operands = call.getOperandList();
+      final List<RexNode> exprs = new LinkedList<>();
+
+      String timeUnit = ((SqlIntervalQualifier) 
operands.get(0)).timeUnitRange.toString();
+
+      RelDataTypeFactory typeFactory = cx.getTypeFactory();
+
+      //RelDataType nullableReturnType =
+
+      for (SqlNode node : operands) {
+        exprs.add(cx.convertExpression(node));
+      }
+
+      final RelDataType returnType;
+      if (call.getOperator() == SqlStdOperatorTable.EXTRACT) {
+        // Legacy code:
+        // The return type is wrong!
+        // Legacy code choose SqlTypeName.BIGINT simply to avoid conflicting 
against Calcite's inference mechanism
+        // (, which chose BIGINT in validation phase already)
+        // Determine NULL-able using 2nd argument's Null-able.
 
 Review comment:
   NULL-able -> nullability
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Update Calcite to 1.21.0
> ------------------------
>
>                 Key: DRILL-7406
>                 URL: https://issues.apache.org/jira/browse/DRILL-7406
>             Project: Apache Drill
>          Issue Type: Task
>          Components: Query Planning &amp; Optimization, SQL Parser
>    Affects Versions: 1.17.0
>            Reporter: Igor Guzenko
>            Assignee: Igor Guzenko
>            Priority: Major
>             Fix For: 1.18.0
>
>
> DRILL-7340 should be fixed by this update.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to