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

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

amansinha100 closed pull request #1224: DRILL-6321: Customize Drill's 
conformance. Allow support to APPLY key…
URL: https://github.com/apache/drill/pull/1224
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/DrillConformance.java
 
b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/DrillConformance.java
new file mode 100644
index 0000000000..e6efeb92d1
--- /dev/null
+++ 
b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/DrillConformance.java
@@ -0,0 +1,43 @@
+/*
+ * 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 may not 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 applicable law 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.drill.exec.planner.sql;
+
+import org.apache.calcite.sql.validate.SqlConformanceEnum;
+import org.apache.calcite.sql.validate.SqlDelegatingConformance;
+
+/**
+ * Drill's SQL conformance is SqlConformanceEnum.DEFAULT except for method 
isApplyAllowed().
+ * Since Drill is going to allow OUTER APPLY and CROSS APPLY to allow each row 
from left child of Join
+ * to join with output of right side (sub-query or table function that will be 
invoked for each row).
+ * Refer to DRILL-5999 for more information.
+ */
+public class DrillConformance extends SqlDelegatingConformance {
+
+  public DrillConformance() {
+    super(SqlConformanceEnum.DEFAULT);
+  }
+
+  public DrillConformance(SqlConformanceEnum flavor) {
+    super(flavor);
+  }
+
+  @Override
+  public boolean isApplyAllowed() {
+    return true;
+  }
+}
diff --git 
a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/DrillParserConfig.java
 
b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/DrillParserConfig.java
index 1f67c5e161..575ad8610f 100644
--- 
a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/DrillParserConfig.java
+++ 
b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/DrillParserConfig.java
@@ -22,7 +22,6 @@
 import org.apache.calcite.sql.parser.SqlParser;
 import org.apache.calcite.sql.parser.SqlParserImplFactory;
 import org.apache.calcite.sql.validate.SqlConformance;
-import org.apache.calcite.sql.validate.SqlConformanceEnum;
 import org.apache.drill.exec.planner.physical.PlannerSettings;
 import 
org.apache.drill.exec.planner.sql.parser.impl.DrillParserWithCompoundIdConverter;
 
@@ -30,6 +29,7 @@
 
   private final long identifierMaxLength;
   private final Quoting quotingIdentifiers;
+  public final static SqlConformance DRILL_CONFORMANCE = new 
DrillConformance();
 
   public DrillParserConfig(PlannerSettings settings) {
     identifierMaxLength = settings.getIdentifierMaxLength();
@@ -63,7 +63,7 @@ public boolean caseSensitive() {
 
   @Override
   public SqlConformance conformance() {
-    return SqlConformanceEnum.DEFAULT;
+    return DRILL_CONFORMANCE;
   }
 
   @Override
diff --git 
a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/SqlConverter.java
 
b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/SqlConverter.java
index 69362d9392..d9ead8b78b 100644
--- 
a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/SqlConverter.java
+++ 
b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/SqlConverter.java
@@ -31,6 +31,7 @@
 import org.apache.calcite.config.CalciteConnectionProperty;
 import org.apache.calcite.jdbc.DynamicSchema;
 import org.apache.calcite.jdbc.JavaTypeFactoryImpl;
+import org.apache.calcite.plan.Contexts;
 import org.apache.calcite.plan.ConventionTraitDef;
 import org.apache.calcite.plan.RelOptCluster;
 import org.apache.calcite.plan.RelOptCostFactory;
@@ -58,6 +59,7 @@
 import org.apache.calcite.sql.parser.SqlParserPos;
 import org.apache.calcite.sql.type.SqlTypeName;
 import org.apache.calcite.sql.util.ChainedSqlOperatorTable;
+import org.apache.calcite.sql.validate.SqlConformance;
 import org.apache.calcite.sql.validate.SqlConformanceEnum;
 import org.apache.calcite.sql.validate.SqlValidatorCatalogReader;
 import org.apache.calcite.sql.validate.SqlValidatorImpl;
@@ -139,7 +141,7 @@ public SqlConverter(QueryContext context) {
         session);
     this.opTab = new 
ChainedSqlOperatorTable(Arrays.asList(context.getDrillOperatorTable(), 
catalog));
     this.costFactory = (settings.useDefaultCosting()) ? null : new 
DrillCostBase.DrillCostFactory();
-    this.validator = new DrillValidator(opTab, catalog, typeFactory, 
SqlConformanceEnum.DEFAULT);
+    this.validator = new DrillValidator(opTab, catalog, typeFactory, 
parserConfig.conformance());
     validator.setIdentifierExpansion(true);
     cluster = null;
   }
@@ -159,7 +161,7 @@ private SqlConverter(SqlConverter parent, SchemaPlus 
defaultSchema, SchemaPlus r
     this.catalog = catalog;
     this.opTab = parent.opTab;
     this.planner = parent.planner;
-    this.validator = new DrillValidator(opTab, catalog, typeFactory, 
SqlConformanceEnum.DEFAULT);
+    this.validator = new DrillValidator(opTab, catalog, typeFactory, 
parserConfig.conformance());
     this.temporarySchema = parent.temporarySchema;
     this.session = parent.session;
     this.drillConfig = parent.drillConfig;
@@ -240,7 +242,7 @@ public void useRootSchemaAsDefault(boolean useRoot) {
   private class DrillValidator extends SqlValidatorImpl {
 
     protected DrillValidator(SqlOperatorTable opTab, SqlValidatorCatalogReader 
catalogReader,
-        RelDataTypeFactory typeFactory, SqlConformanceEnum conformance) {
+        RelDataTypeFactory typeFactory, SqlConformance conformance) {
       super(opTab, catalogReader, typeFactory, conformance);
     }
 
@@ -250,20 +252,22 @@ protected void validateFrom(
         RelDataType targetRowType,
         SqlValidatorScope scope) {
       switch (node.getKind()) {
-      case AS:
-        if (((SqlCall) node).operand(0) instanceof SqlIdentifier) {
-          SqlIdentifier tempNode = ((SqlCall) node).operand(0);
-          DrillCalciteCatalogReader catalogReader = 
(SqlConverter.DrillCalciteCatalogReader) getCatalogReader();
-
-          // Check the schema and throw a valid SchemaNotFound exception 
instead of TableNotFound exception.
-          if (catalogReader.getTable(Lists.newArrayList(tempNode.names)) == 
null) {
-            catalogReader.isValidSchema(tempNode.names);
+        case AS:
+          if (((SqlCall) node).operand(0) instanceof SqlIdentifier) {
+            SqlIdentifier tempNode = ((SqlCall) node).operand(0);
+            DrillCalciteCatalogReader catalogReader = 
(SqlConverter.DrillCalciteCatalogReader) getCatalogReader();
+
+            // Check the schema and throw a valid SchemaNotFound exception 
instead of TableNotFound exception.
+            if (catalogReader.getTable(Lists.newArrayList(tempNode.names)) == 
null) {
+              catalogReader.isValidSchema(tempNode.names);
+            }
+            changeNamesIfTableIsTemporary(tempNode);
           }
-          changeNamesIfTableIsTemporary(tempNode);
-        }
-      default:
-        super.validateFrom(node, targetRowType, scope);
+          break;
+        default:
+          break;
       }
+      super.validateFrom(node, targetRowType, scope);
     }
 
     @Override
diff --git 
a/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestConformance.java 
b/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestConformance.java
new file mode 100644
index 0000000000..4af1a84b84
--- /dev/null
+++ 
b/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestConformance.java
@@ -0,0 +1,46 @@
+/*
+ * 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 may not 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 applicable law 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.drill.exec.sql;
+
+import org.apache.drill.PlanTestBase;
+import org.apache.drill.categories.SqlTest;
+import org.apache.drill.test.BaseTestQuery;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+@Category(SqlTest.class)
+public class TestConformance extends BaseTestQuery {
+
+  @Test
+  public void testApply() throws Exception{
+
+    //cross join is not support yet in Drill: DRILL-1921, so we are testing 
OUTER APPLY only
+    String query = "SELECT c.c_nationkey, o.orderdate from " +
+      "cp.`tpch/customer.parquet` c outer apply " +
+      "cp.`tpch/orders.parquet` o " +
+      "where c.c_custkey = o.o_custkey";
+
+    PlanTestBase.testPlanMatchingPatterns(query,
+        new String[] {"Join"}, new String[] {}
+    );
+
+    return;
+  }
+
+
+}


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


> Lateral Join: Planning changes - enable submitting physical plan
> ----------------------------------------------------------------
>
>                 Key: DRILL-6321
>                 URL: https://issues.apache.org/jira/browse/DRILL-6321
>             Project: Apache Drill
>          Issue Type: Task
>            Reporter: Parth Chandra
>            Assignee: Chunhui Shi
>            Priority: Major
>              Labels: ready-to-commit
>             Fix For: 1.14.0
>
>
> Implement changes to enable submitting a physical plan containing lateral and 
> unnest.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to