You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by tdas <gi...@git.apache.org> on 2016/04/08 01:25:27 UTC

[GitHub] spark pull request: [SPARK-14473][SQL]

GitHub user tdas opened a pull request:

    https://github.com/apache/spark/pull/12246

    [SPARK-14473][SQL]

    ## What changes were proposed in this pull request?
    
    There are many operations that are currently not supported in the streaming execution. For example:
     - joining two streams
     - unioning a stream and a batch source
     - sorting
     - window functions (not time windows)
     - distinct aggregates
    
    Furthermore, executing a query with a stream source as a batch query should also fail.
    
    This patch add an additional step after analysis in the QueryExecution which will check that all the operations in the analyzed logical plan is supported or not.
    
    ## How was this patch tested?
    unit tests.


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/tdas/spark SPARK-14473

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/12246.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #12246
    
----
commit 87b97828d43a648d10b84fe098cecc1a26cd1817
Author: Tathagata Das <ta...@gmail.com>
Date:   2016-04-07T23:18:32Z

    First few rules for unsupported operations

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-210287115
  
    Merged build finished. Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [WIP, DO-NOT-MERGE][SPARK-14473][SQL] Define a...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-208623948
  
    **[Test build #55553 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/55553/consoleFull)** for PR 12246 at commit [`cc7baab`](https://github.com/apache/spark/commit/cc7baab4d74c8cc84e27df74cb6d4d4b2540ebd3).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by zsxwing <gi...@git.apache.org>.
Github user zsxwing commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-211506802
  
    Thanks, merging into master


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [WIP, DO-NOT-MERGE][SPARK-14473][SQL] Define a...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-207678194
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/55406/
    Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by zsxwing <gi...@git.apache.org>.
Github user zsxwing commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12246#discussion_r59931914
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/UnsupportedOperationChecker.scala ---
    @@ -0,0 +1,145 @@
    +/*
    + * 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.spark.sql.catalyst.analysis
    +
    +import org.apache.spark.sql.AnalysisException
    +import org.apache.spark.sql.catalyst.plans._
    +import org.apache.spark.sql.catalyst.plans.logical._
    +
    +/**
    + * Analyzes the presence of unsupported operations in a logical plan.
    + */
    +object UnsupportedOperationChecker {
    +
    +  def checkForBatch(plan: LogicalPlan): Unit = {
    +    plan.foreachUp {
    +      case p if p.isStreaming =>
    +        throwError(
    +          "Queries with streaming sources must be executed with write.startStream()")(p)
    +
    +      case _ =>
    +    }
    +  }
    +
    +  def checkForStreaming(plan: LogicalPlan, outputMode: OutputMode): Unit = {
    +
    +    if (!plan.isStreaming) {
    +      throwError(
    +        "Queries without streaming sources cannot be executed with write.startStream()")(plan)
    +    }
    +
    +    plan.foreachUp { implicit plan =>
    +
    +      // Operations that cannot exists anywhere in a streaming plan
    +      plan match {
    +
    +        case _: Command =>
    +          throwError("Commands like CreateTable*, AlterTable*, Show* are not supported with " +
    +            "streaming DataFrames/Datasets")
    +
    +        case _: InsertIntoTable =>
    +          throwError("InsertIntoTable is not supported with streaming DataFrames/Datasets")
    +
    +        case Aggregate(_, _, child) if child.isStreaming && outputMode == Append =>
    +          throwError(
    +            "Aggregations are not supported on streaming DataFrames/Datasets in " +
    +              "Append output mode. Consider changing output mode to Update.")
    +
    +        case Join(left, right, joinType, _) =>
    +
    +          joinType match {
    +
    +            case Inner =>
    +              if (left.isStreaming && right.isStreaming) {
    +                throwError("Inner join between two streaming DataFrames/Datasets is not supported")
    +              }
    +
    +            case FullOuter =>
    +              if (left.isStreaming || right.isStreaming) {
    +                throwError("Full outer joins with streaming DataFrames/Datasets are not supported")
    +              }
    +
    +
    +            case LeftOuter | LeftSemi | LeftAnti =>
    +              if (right.isStreaming) {
    +                throwError("Left outer/semi/anti joins with a streaming DataFrame/Dataset " +
    +                    "on the right is not supported")
    +              }
    +
    +            case RightOuter =>
    +              if (left.isStreaming) {
    +                throwError("Right outer join with a streaming DataFrame/Dataset on the left is " +
    +                    "not supported")
    +              }
    +
    +            case NaturalJoin(_) | UsingJoin(_, _) =>
    +              // They should not appear in an analyzed plan.
    +
    +            case _ =>
    +              throwError(s"Join type $joinType is not supported with streaming DataFrame/Dataset")
    +          }
    +
    +        case c: CoGroup if plan.children.exists(_.isStreaming) =>
    +          throwError("CoGrouping between two streaming DataFrames/Datasets is not supported")
    --- End diff --
    
    nit: CoGroup is not supported on streaming DataFrames/Datasets


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by zsxwing <gi...@git.apache.org>.
Github user zsxwing commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12246#discussion_r59931552
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/UnsupportedOperationChecker.scala ---
    @@ -0,0 +1,145 @@
    +/*
    + * 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.spark.sql.catalyst.analysis
    +
    +import org.apache.spark.sql.AnalysisException
    +import org.apache.spark.sql.catalyst.plans._
    +import org.apache.spark.sql.catalyst.plans.logical._
    +
    +/**
    + * Analyzes the presence of unsupported operations in a logical plan.
    + */
    +object UnsupportedOperationChecker {
    +
    +  def checkForBatch(plan: LogicalPlan): Unit = {
    +    plan.foreachUp {
    --- End diff --
    
    nit: Just call `plan.isStreaming` is enough.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [WIP, DO-NOT-MERGE][SPARK-14473][SQL] Define a...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-208610845
  
    **[Test build #55547 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/55547/consoleFull)** for PR 12246 at commit [`cbcb69d`](https://github.com/apache/spark/commit/cbcb69d399b0de242008c34f2e9ac480ec212f79).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [WIP, DO-NOT-MERGE][SPARK-14473][SQL] Define a...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-208659003
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/55553/
    Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by zsxwing <gi...@git.apache.org>.
Github user zsxwing commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12246#discussion_r59935095
  
    --- Diff: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/UnsupportedOperationsSuite.scala ---
    @@ -0,0 +1,378 @@
    +/*
    + * 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.spark.sql.catalyst.analysis
    +
    +import org.apache.spark.SparkFunSuite
    +import org.apache.spark.sql.AnalysisException
    +import org.apache.spark.sql.catalyst.dsl.expressions._
    +import org.apache.spark.sql.catalyst.dsl.plans._
    +import org.apache.spark.sql.catalyst.encoders.ExpressionEncoder
    +import org.apache.spark.sql.catalyst.expressions.{Attribute, AttributeReference}
    +import org.apache.spark.sql.catalyst.plans._
    +import org.apache.spark.sql.catalyst.plans.logical._
    +import org.apache.spark.sql.types.IntegerType
    +
    +class UnsupportedOperationsSuite extends SparkFunSuite {
    +
    +  val attribute = AttributeReference("a", IntegerType, nullable = true)()
    +  val batchRelation = LocalRelation(attribute)
    +  val streamRelation = new TestStreamingRelation(attribute)
    +
    +  /*
    +    =======================================================================================
    +                                     BATCH QUERIES
    +    =======================================================================================
    +   */
    +
    +  assertSupportedForBatch("local relation", batchRelation)
    +
    +  assertNotSupportedForBatch(
    +    "streaming source",
    +    streamRelation,
    +    Seq("with streaming source", "startStream"))
    +
    +  assertNotSupportedForBatch(
    +    "select on streaming source",
    +    streamRelation.select($"count(*)"),
    +    Seq("with streaming source", "startStream"))
    +
    +
    +  /*
    +    =======================================================================================
    +                                     STREAMING QUERIES
    +    =======================================================================================
    +   */
    +
    +  // Batch plan in streaming query
    +  testError("batch source", Seq("without streaming source", "startStream")) {
    +    UnsupportedOperationChecker.checkForStreaming(batchRelation.select($"count(*)"), Append)
    +  }
    +
    +  // Commands
    +  assertNotSupportedForStreaming(
    +    "commmands",
    +    DescribeFunction("func", true),
    +    outputMode = Append,
    +    expectedMsgs = "commands" :: Nil)
    +
    +  // Aggregates: Not supported on streams in Append mode
    +  assertSupportedForStreaming(
    +    "aggregate - stream with update output mode",
    +    batchRelation.groupBy("a")("count(*)"),
    +    outputMode = Update)
    +
    +  assertSupportedForStreaming(
    +    "aggregate - batch with update output mode",
    +    streamRelation.groupBy("a")("count(*)"),
    +    outputMode = Update)
    +
    +  assertSupportedForStreaming(
    --- End diff --
    
    assertSupportedForBatch?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by tdas <gi...@git.apache.org>.
Github user tdas commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12246#discussion_r59912290
  
    --- Diff: sql/core/src/test/scala/org/apache/spark/sql/StreamTest.scala ---
    @@ -75,6 +76,8 @@ trait StreamTest extends QueryTest with Timeouts {
       /** How long to wait for an active stream to catch up when checking a result. */
       val streamingTimeout = 10.seconds
     
    +  val outputMode: OutputMode = Append
    --- End diff --
    
    Can add this later when we have more support for more output modes and mixed suites


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [WIP, DO-NOT-MERGE][SPARK-14473][SQL] Define a...

Posted by tdas <gi...@git.apache.org>.
Github user tdas commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12246#discussion_r59311020
  
    --- Diff: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/plans/LogicalPlanSuite.scala ---
    @@ -68,4 +70,23 @@ class LogicalPlanSuite extends SparkFunSuite {
     
         assert(invocationCount === 1)
       }
    +
    +  test("needsIncrementalExecution") {
    --- End diff --
    
    rename this.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by zsxwing <gi...@git.apache.org>.
Github user zsxwing commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-210677909
  
    Looks `MemorySinkSuite` is still flakey...


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [WIP, DO-NOT-MERGE][SPARK-14473][SQL] Define a...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-207136916
  
    **[Test build #55271 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/55271/consoleFull)** for PR 12246 at commit [`de3e298`](https://github.com/apache/spark/commit/de3e29852a1eecd1828abedc128c4e441823fffb).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-210601612
  
    Merged build finished. Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by zsxwing <gi...@git.apache.org>.
Github user zsxwing commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12246#discussion_r59933234
  
    --- Diff: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/UnsupportedOperationsSuite.scala ---
    @@ -0,0 +1,378 @@
    +/*
    + * 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.spark.sql.catalyst.analysis
    +
    +import org.apache.spark.SparkFunSuite
    +import org.apache.spark.sql.AnalysisException
    +import org.apache.spark.sql.catalyst.dsl.expressions._
    +import org.apache.spark.sql.catalyst.dsl.plans._
    +import org.apache.spark.sql.catalyst.encoders.ExpressionEncoder
    +import org.apache.spark.sql.catalyst.expressions.{Attribute, AttributeReference}
    +import org.apache.spark.sql.catalyst.plans._
    +import org.apache.spark.sql.catalyst.plans.logical._
    +import org.apache.spark.sql.types.IntegerType
    +
    +class UnsupportedOperationsSuite extends SparkFunSuite {
    +
    +  val attribute = AttributeReference("a", IntegerType, nullable = true)()
    +  val batchRelation = LocalRelation(attribute)
    +  val streamRelation = new TestStreamingRelation(attribute)
    +
    +  /*
    +    =======================================================================================
    +                                     BATCH QUERIES
    +    =======================================================================================
    +   */
    +
    +  assertSupportedForBatch("local relation", batchRelation)
    +
    +  assertNotSupportedForBatch(
    +    "streaming source",
    +    streamRelation,
    +    Seq("with streaming source", "startStream"))
    +
    +  assertNotSupportedForBatch(
    +    "select on streaming source",
    +    streamRelation.select($"count(*)"),
    +    Seq("with streaming source", "startStream"))
    +
    +
    +  /*
    +    =======================================================================================
    +                                     STREAMING QUERIES
    +    =======================================================================================
    +   */
    +
    +  // Batch plan in streaming query
    +  testError("batch source", Seq("without streaming source", "startStream")) {
    +    UnsupportedOperationChecker.checkForStreaming(batchRelation.select($"count(*)"), Append)
    +  }
    +
    +  // Commands
    +  assertNotSupportedForStreaming(
    +    "commmands",
    +    DescribeFunction("func", true),
    +    outputMode = Append,
    +    expectedMsgs = "commands" :: Nil)
    +
    +  // Aggregates: Not supported on streams in Append mode
    +  assertSupportedForStreaming(
    +    "aggregate - stream with update output mode",
    +    batchRelation.groupBy("a")("count(*)"),
    +    outputMode = Update)
    +
    +  assertSupportedForStreaming(
    +    "aggregate - batch with update output mode",
    --- End diff --
    
    nit: batch -> stream


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-210635885
  
    **[Test build #55956 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/55956/consoleFull)** for PR 12246 at commit [`8a71835`](https://github.com/apache/spark/commit/8a71835f4011a3570990669346a65dcea51adb4f).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by marmbrus <gi...@git.apache.org>.
Github user marmbrus commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12246#discussion_r59763939
  
    --- Diff: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/UnsupportedOperationsSuite.scala ---
    @@ -0,0 +1,379 @@
    +/*
    + * 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.spark.sql.catalyst.analysis
    +
    +import org.apache.spark.SparkFunSuite
    +import org.apache.spark.sql.AnalysisException
    +import org.apache.spark.sql.catalyst.dsl.expressions._
    +import org.apache.spark.sql.catalyst.dsl.plans._
    +import org.apache.spark.sql.catalyst.encoders.ExpressionEncoder
    +import org.apache.spark.sql.catalyst.expressions.AttributeReference
    +import org.apache.spark.sql.catalyst.plans._
    +import org.apache.spark.sql.catalyst.plans.logical._
    +import org.apache.spark.sql.types.IntegerType
    +
    +class UnsupportedOperationsSuite extends SparkFunSuite {
    +
    +  val batchRelation = LocalRelation(AttributeReference("a", IntegerType, nullable = true)())
    +
    +  val streamRelation = new LocalRelation(
    +    Seq(AttributeReference("a", IntegerType, nullable = true)())) {
    +    override def isStreaming: Boolean = true
    +  }
    +
    +  /*
    +    =======================================================================================
    +                                     BATCH QUERIES
    +    =======================================================================================
    +   */
    +
    +  assertSupportedForBatch("local relation", batchRelation)
    +
    +  assertNotSupportedForBatch(
    +    "streaming source",
    +    streamRelation,
    +    Seq("with streaming source", "startStream"))
    +
    +  assertNotSupportedForBatch(
    +    "select on streaming source",
    +    streamRelation.select($"count(*)"),
    +    Seq("with streaming source", "startStream"))
    +
    +
    +  /*
    +    =======================================================================================
    +                                     STREAMING QUERIES
    +    =======================================================================================
    +   */
    +
    +  // Batch plan in streaming query
    +  testError("batch source", Seq("without streaming source", "startStream")) {
    +    UnsupportedOperationChecker.checkForStreaming(batchRelation.select($"count(*)"), Append)
    +  }
    +
    +  // Commands
    +  assertNotSupportedForStreaming(
    +    "commmands",
    +    DescribeFunction("func", true),
    +    outputMode = Append,
    +    expectedMsgs = "commands" :: Nil)
    +
    +  // Aggregates: Not supported on streams in Append mode
    +  assertSupportedForStreaming(
    +    "aggregate - stream with update output mode",
    +    batchRelation.groupBy("a")("count(*)"),
    +    outputMode = Update)
    +
    +  assertSupportedForStreaming(
    +    "aggregate - batch with update output mode",
    +    streamRelation.groupBy("a")("count(*)"),
    +    outputMode = Update)
    +
    +  assertSupportedForStreaming(
    +    "aggregate - batch with append output mode",
    +    batchRelation.groupBy("a")("count(*)"),
    +    outputMode = Append)
    +
    +  assertNotSupportedForStreaming(
    +    "aggregate - stream with append output mode",
    +    streamRelation.groupBy("a")("count(*)"),
    +    outputMode = Append,
    +    Seq("aggregation", "append output mode"))
    +
    +  // Inner joins: Stream-stream not supported
    +  testBinaryOperationForStreaming(
    +    "inner join",
    +    _.join(_, joinType = Inner),
    +    streamStreamSupported = false)
    +
    +  // Full outer joins: only batch-batch is allowed
    +  testBinaryOperationForStreaming(
    +    "full outer join",
    +    _.join(_, joinType = FullOuter),
    +    streamStreamSupported = false,
    +    batchStreamSupported = false,
    +    streamBatchSupported = false)
    +
    +  // Left outer joins: *-stream not allowed
    +  testBinaryOperationForStreaming(
    +    "left outer join",
    +    _.join(_, joinType = LeftOuter),
    +    streamStreamSupported = false,
    +    batchStreamSupported = false,
    +    expectedMsg = "left outer/semi/anti joins")
    +
    +  // Left semi joins: stream-* not allowed
    +  testBinaryOperationForStreaming(
    +    "left semi join",
    +    _.join(_, joinType = LeftSemi),
    +    streamStreamSupported = false,
    +    batchStreamSupported = false,
    +    expectedMsg = "left outer/semi/anti joins")
    +
    +  // Left anti joins: stream-* not allowed
    +  testBinaryOperationForStreaming(
    +    "left anti join",
    +    _.join(_, joinType = LeftAnti),
    +    streamStreamSupported = false,
    +    batchStreamSupported = false,
    +    expectedMsg = "left outer/semi/anti joins")
    +
    +  // Right outer joins: stream-* not allowed
    +  testBinaryOperationForStreaming(
    +    "right outer join",
    +    _.join(_, joinType = RightOuter),
    +    streamStreamSupported = false,
    +    streamBatchSupported = false)
    +
    +  // Cogroup: only batch-batch is allowed
    +  testBinaryOperationForStreaming(
    +    "cogroup",
    +    genCogroup,
    +    streamStreamSupported = false,
    +    batchStreamSupported = false,
    +    streamBatchSupported = false)
    +
    +  def genCogroup(left: LogicalPlan, right: LogicalPlan): LogicalPlan = {
    --- End diff --
    
    These should probably just be added to the DSL.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by marmbrus <gi...@git.apache.org>.
Github user marmbrus commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12246#discussion_r59763010
  
    --- Diff: sql/core/src/test/scala/org/apache/spark/sql/StreamTest.scala ---
    @@ -75,6 +76,8 @@ trait StreamTest extends QueryTest with Timeouts {
       /** How long to wait for an active stream to catch up when checking a result. */
       val streamingTimeout = 10.seconds
     
    +  val outputMode: OutputMode = Append
    --- End diff --
    
    We might want to make this an argument to `streamTest` with a default.  I think in a single suite we might want to be able to have more than one kind of test.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by tdas <gi...@git.apache.org>.
Github user tdas commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12246#discussion_r59936215
  
    --- Diff: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/UnsupportedOperationsSuite.scala ---
    @@ -0,0 +1,378 @@
    +/*
    + * 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.spark.sql.catalyst.analysis
    +
    +import org.apache.spark.SparkFunSuite
    +import org.apache.spark.sql.AnalysisException
    +import org.apache.spark.sql.catalyst.dsl.expressions._
    +import org.apache.spark.sql.catalyst.dsl.plans._
    +import org.apache.spark.sql.catalyst.encoders.ExpressionEncoder
    +import org.apache.spark.sql.catalyst.expressions.{Attribute, AttributeReference}
    +import org.apache.spark.sql.catalyst.plans._
    +import org.apache.spark.sql.catalyst.plans.logical._
    +import org.apache.spark.sql.types.IntegerType
    +
    +class UnsupportedOperationsSuite extends SparkFunSuite {
    +
    +  val attribute = AttributeReference("a", IntegerType, nullable = true)()
    +  val batchRelation = LocalRelation(attribute)
    +  val streamRelation = new TestStreamingRelation(attribute)
    +
    +  /*
    +    =======================================================================================
    +                                     BATCH QUERIES
    +    =======================================================================================
    +   */
    +
    +  assertSupportedForBatch("local relation", batchRelation)
    +
    +  assertNotSupportedForBatch(
    +    "streaming source",
    +    streamRelation,
    +    Seq("with streaming source", "startStream"))
    +
    +  assertNotSupportedForBatch(
    +    "select on streaming source",
    +    streamRelation.select($"count(*)"),
    +    Seq("with streaming source", "startStream"))
    +
    +
    +  /*
    +    =======================================================================================
    +                                     STREAMING QUERIES
    +    =======================================================================================
    +   */
    +
    +  // Batch plan in streaming query
    +  testError("batch source", Seq("without streaming source", "startStream")) {
    +    UnsupportedOperationChecker.checkForStreaming(batchRelation.select($"count(*)"), Append)
    +  }
    +
    +  // Commands
    +  assertNotSupportedForStreaming(
    +    "commmands",
    +    DescribeFunction("func", true),
    +    outputMode = Append,
    +    expectedMsgs = "commands" :: Nil)
    +
    +  // Aggregates: Not supported on streams in Append mode
    +  assertSupportedForStreaming(
    --- End diff --
    
    I am renaming `assertSupportedForStreaming` to `assertSupportedInStreamingPlan` to make it unambiguous.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-210697523
  
    **[Test build #55976 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/55976/consoleFull)** for PR 12246 at commit [`8a71835`](https://github.com/apache/spark/commit/8a71835f4011a3570990669346a65dcea51adb4f).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [WIP, DO-NOT-MERGE][SPARK-14473][SQL] Define a...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-207137893
  
    **[Test build #55273 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/55273/consoleFull)** for PR 12246 at commit [`edd1ac1`](https://github.com/apache/spark/commit/edd1ac1c954c38ee019792715c0c1cfec0cce519).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [WIP, DO-NOT-MERGE][SPARK-14473][SQL] Define a...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-208662269
  
    **[Test build #55572 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/55572/consoleFull)** for PR 12246 at commit [`64ed243`](https://github.com/apache/spark/commit/64ed24347de349e8e734ad50c11392eb17237d4e).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [WIP, DO-NOT-MERGE][SPARK-14473][SQL] Define a...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-207195067
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/55306/
    Test FAILed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by tdas <gi...@git.apache.org>.
Github user tdas commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12246#discussion_r59932564
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/UnsupportedOperationChecker.scala ---
    @@ -0,0 +1,145 @@
    +/*
    + * 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.spark.sql.catalyst.analysis
    +
    +import org.apache.spark.sql.AnalysisException
    +import org.apache.spark.sql.catalyst.plans._
    +import org.apache.spark.sql.catalyst.plans.logical._
    +
    +/**
    + * Analyzes the presence of unsupported operations in a logical plan.
    + */
    +object UnsupportedOperationChecker {
    +
    +  def checkForBatch(plan: LogicalPlan): Unit = {
    +    plan.foreachUp {
    +      case p if p.isStreaming =>
    +        throwError(
    +          "Queries with streaming sources must be executed with write.startStream()")(p)
    +
    +      case _ =>
    +    }
    +  }
    +
    +  def checkForStreaming(plan: LogicalPlan, outputMode: OutputMode): Unit = {
    +
    +    if (!plan.isStreaming) {
    +      throwError(
    +        "Queries without streaming sources cannot be executed with write.startStream()")(plan)
    +    }
    +
    +    plan.foreachUp { implicit plan =>
    +
    +      // Operations that cannot exists anywhere in a streaming plan
    +      plan match {
    +
    +        case _: Command =>
    +          throwError("Commands like CreateTable*, AlterTable*, Show* are not supported with " +
    +            "streaming DataFrames/Datasets")
    +
    +        case _: InsertIntoTable =>
    +          throwError("InsertIntoTable is not supported with streaming DataFrames/Datasets")
    +
    +        case Aggregate(_, _, child) if child.isStreaming && outputMode == Append =>
    +          throwError(
    +            "Aggregations are not supported on streaming DataFrames/Datasets in " +
    +              "Append output mode. Consider changing output mode to Update.")
    +
    +        case Join(left, right, joinType, _) =>
    +
    +          joinType match {
    +
    +            case Inner =>
    +              if (left.isStreaming && right.isStreaming) {
    +                throwError("Inner join between two streaming DataFrames/Datasets is not supported")
    +              }
    +
    +            case FullOuter =>
    +              if (left.isStreaming || right.isStreaming) {
    +                throwError("Full outer joins with streaming DataFrames/Datasets are not supported")
    +              }
    +
    +
    +            case LeftOuter | LeftSemi | LeftAnti =>
    +              if (right.isStreaming) {
    +                throwError("Left outer/semi/anti joins with a streaming DataFrame/Dataset " +
    +                    "on the right is not supported")
    +              }
    +
    +            case RightOuter =>
    +              if (left.isStreaming) {
    +                throwError("Right outer join with a streaming DataFrame/Dataset on the left is " +
    +                    "not supported")
    +              }
    +
    +            case NaturalJoin(_) | UsingJoin(_, _) =>
    +              // They should not appear in an analyzed plan.
    +
    +            case _ =>
    +              throwError(s"Join type $joinType is not supported with streaming DataFrame/Dataset")
    +          }
    +
    +        case c: CoGroup if plan.children.exists(_.isStreaming) =>
    +          throwError("CoGrouping between two streaming DataFrames/Datasets is not supported")
    +
    +        case u: Union if u.children.count(_.isStreaming) == 1 =>
    --- End diff --
    
    No ... union between two batch relations is fine, union between two streaming relation is also fine. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-210660210
  
    **[Test build #55956 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/55956/consoleFull)** for PR 12246 at commit [`8a71835`](https://github.com/apache/spark/commit/8a71835f4011a3570990669346a65dcea51adb4f).
     * This patch **fails Spark unit tests**.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [WIP, DO-NOT-MERGE][SPARK-14473][SQL] Define a...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-208659002
  
    Merged build finished. Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by tdas <gi...@git.apache.org>.
Github user tdas commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12246#discussion_r59933260
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/UnsupportedOperationChecker.scala ---
    @@ -0,0 +1,145 @@
    +/*
    + * 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.spark.sql.catalyst.analysis
    +
    +import org.apache.spark.sql.AnalysisException
    +import org.apache.spark.sql.catalyst.plans._
    +import org.apache.spark.sql.catalyst.plans.logical._
    +
    +/**
    + * Analyzes the presence of unsupported operations in a logical plan.
    + */
    +object UnsupportedOperationChecker {
    +
    +  def checkForBatch(plan: LogicalPlan): Unit = {
    +    plan.foreachUp {
    +      case p if p.isStreaming =>
    +        throwError(
    +          "Queries with streaming sources must be executed with write.startStream()")(p)
    +
    +      case _ =>
    +    }
    +  }
    +
    +  def checkForStreaming(plan: LogicalPlan, outputMode: OutputMode): Unit = {
    +
    +    if (!plan.isStreaming) {
    +      throwError(
    +        "Queries without streaming sources cannot be executed with write.startStream()")(plan)
    +    }
    +
    +    plan.foreachUp { implicit plan =>
    +
    +      // Operations that cannot exists anywhere in a streaming plan
    +      plan match {
    +
    +        case _: Command =>
    +          throwError("Commands like CreateTable*, AlterTable*, Show* are not supported with " +
    +            "streaming DataFrames/Datasets")
    +
    +        case _: InsertIntoTable =>
    +          throwError("InsertIntoTable is not supported with streaming DataFrames/Datasets")
    +
    +        case Aggregate(_, _, child) if child.isStreaming && outputMode == Append =>
    +          throwError(
    +            "Aggregations are not supported on streaming DataFrames/Datasets in " +
    +              "Append output mode. Consider changing output mode to Update.")
    +
    +        case Join(left, right, joinType, _) =>
    +
    +          joinType match {
    +
    +            case Inner =>
    +              if (left.isStreaming && right.isStreaming) {
    +                throwError("Inner join between two streaming DataFrames/Datasets is not supported")
    +              }
    +
    +            case FullOuter =>
    +              if (left.isStreaming || right.isStreaming) {
    +                throwError("Full outer joins with streaming DataFrames/Datasets are not supported")
    +              }
    +
    +
    +            case LeftOuter | LeftSemi | LeftAnti =>
    +              if (right.isStreaming) {
    +                throwError("Left outer/semi/anti joins with a streaming DataFrame/Dataset " +
    +                    "on the right is not supported")
    +              }
    +
    +            case RightOuter =>
    +              if (left.isStreaming) {
    +                throwError("Right outer join with a streaming DataFrame/Dataset on the left is " +
    +                    "not supported")
    +              }
    +
    +            case NaturalJoin(_) | UsingJoin(_, _) =>
    +              // They should not appear in an analyzed plan.
    +
    +            case _ =>
    +              throwError(s"Join type $joinType is not supported with streaming DataFrame/Dataset")
    +          }
    +
    +        case c: CoGroup if plan.children.exists(_.isStreaming) =>
    +          throwError("CoGrouping between two streaming DataFrames/Datasets is not supported")
    +
    +        case u: Union if u.children.count(_.isStreaming) == 1 =>
    +          throwError("Union between streaming and batch DataFrames/Datasets is not supported")
    +
    +        case Except(left, right) if right.isStreaming =>
    +          throwError("Except with a streaming DataFrame/Dataset on the right is not supported")
    +
    +        case Intersect(left, right) if left.isStreaming && right.isStreaming =>
    +          throwError("Intersect between two streaming DataFrames/Datasets is not supported")
    +
    +        case GroupingSets(_, _, child, _) if child.isStreaming =>
    +          throwError("GroupingSets is not supported on streaming DataFrames/Datasets")
    +
    +        case GlobalLimit(_, _) | LocalLimit(_, _) if plan.children.forall(_.isStreaming) =>
    --- End diff --
    
    whats the difference between forall and exists when there is one child?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-210560723
  
    **[Test build #55939 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/55939/consoleFull)** for PR 12246 at commit [`a5d180e`](https://github.com/apache/spark/commit/a5d180e8772d203ba9354ab33ec438b545daf329).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [WIP, DO-NOT-MERGE][SPARK-14473][SQL] Define a...

Posted by tdas <gi...@git.apache.org>.
Github user tdas commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12246#discussion_r59310999
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/UnsupportedOperationChecker.scala ---
    @@ -0,0 +1,146 @@
    +/*
    + * 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.spark.sql.catalyst.analysis
    +
    +import org.apache.spark.sql.AnalysisException
    +import org.apache.spark.sql.catalyst.plans._
    +import org.apache.spark.sql.catalyst.plans.logical._
    +
    +/**
    + * Analyzes the presence of unsupported operations in a logical plan.
    + */
    +object UnsupportedOperationChecker {
    +
    +  def checkForBatch(plan: LogicalPlan): Unit = {
    +    plan.foreachUp {
    +      case p if p.isStreaming =>
    +        throwError(
    +          "Queries with streaming sources must be executed with write.startStream()")(p)
    +
    +      case _ =>
    +    }
    +  }
    +
    +  def checkForStreaming(plan: LogicalPlan, outputMode: OutputMode): Unit = {
    +
    +    if (!plan.isStreaming) {
    +      throwError(
    +        "Queries without streaming sources cannot be executed with write.startStream()")(plan)
    +    }
    +
    +    plan.foreachUp { implicit plan =>
    +
    +      // Operations that cannot exists anywhere in a streaming plan
    +      plan match {
    +
    +        case _: Command =>
    +          throwError("Commands like CreateTable*, AlterTable*, Show* are not supported with " +
    +            "streaming DataFrames/Datasets")
    +
    +        case _: InsertIntoTable =>
    +          throwError("InsertIntoTable is not supported with streaming DataFrames/Datasets")
    +
    +        case Aggregate(_, _, child) if child.isStreaming && outputMode == Append =>
    +          throwError(
    +            "Aggregations are not supported on streaming DataFrames/Datasets in " +
    +              "Append output mode. Consider changing output mode to Update.")
    +
    +        case Join(left, right, joinType, _) =>
    +
    +          joinType match {
    +
    +            case Inner =>
    +              throwErrorIf(
    +                left.isStreaming && right.isStreaming,
    +                "Inner join between two streaming DataFrames/Datasets is not supported")
    +
    +            case FullOuter =>
    +              throwErrorIf(
    +                left.isStreaming || right.isStreaming,
    +                "Full outer joins with streaming DataFrames/Datasets are not supported")
    +
    +            case LeftOuter | LeftSemi | LeftAnti =>
    +              throwErrorIf(
    +                right.isStreaming,
    +                "Left outer/semi/anti joins with a streaming DataFrame/Dataset " +
    +                "on the right is not supported")
    +
    +            case RightOuter =>
    +              throwErrorIf(
    +                left.isStreaming,
    +                "Right outer join with a streaming DataFrame/Dataset on the left is not supported")
    +
    +            case NaturalJoin(_) | UsingJoin(_, _) =>
    +              // They should not appear in an analyzed plan.
    +
    +            case _ =>
    +              throwError(s"Join type $joinType is not supported with streaming DataFrame/Dataset")
    +          }
    +
    +        case c: CoGroup if plan.children.exists(_.isStreaming) =>
    +          throwError("CoGrouping between two streaming DataFrames/Datasets is not supported")
    +
    +        case u: Union if u.children.count(_.isStreaming) == 1 =>
    +          throwError("Union between streaming and batch DataFrames/Datasets is not supported")
    +
    +        case Except(left, right) if right.isStreaming =>
    +          throwError("Except with a streaming DataFrame/Dataset on the right is not supported")
    +
    +        case Intersect(left, right) if left.isStreaming && right.isStreaming =>
    +          throwError("Intersect between two streaming DataFrames/Datasets is not supported")
    +
    +        case GroupingSets(_, _, child, _) if child.isStreaming =>
    +          throwError("GroupingSets is not supported on streaming DataFrames/Datasets")
    +
    +        case GlobalLimit(_, _) | LocalLimit(_, _) if plan.children.forall(_.isStreaming) =>
    +          throwError("Limits are not supported on streaming DataFrames/Datasets")
    +
    +        case Distinct(child) if child.isStreaming =>
    --- End diff --
    
    Should remove Distinct


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [WIP, DO-NOT-MERGE][SPARK-14473][SQL] Define a...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-207195056
  
    **[Test build #55306 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/55306/consoleFull)** for PR 12246 at commit [`6e8c957`](https://github.com/apache/spark/commit/6e8c957d6025907eb2b1864275da49d468449ddd).
     * This patch **fails to build**.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-210287017
  
    **[Test build #55890 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/55890/consoleFull)** for PR 12246 at commit [`3f1353e`](https://github.com/apache/spark/commit/3f1353e96e94f11c431c1d1f75f9782731fafc53).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by tdas <gi...@git.apache.org>.
Github user tdas commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12246#discussion_r59932821
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/UnsupportedOperationChecker.scala ---
    @@ -0,0 +1,145 @@
    +/*
    + * 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.spark.sql.catalyst.analysis
    +
    +import org.apache.spark.sql.AnalysisException
    +import org.apache.spark.sql.catalyst.plans._
    +import org.apache.spark.sql.catalyst.plans.logical._
    +
    +/**
    + * Analyzes the presence of unsupported operations in a logical plan.
    + */
    +object UnsupportedOperationChecker {
    +
    +  def checkForBatch(plan: LogicalPlan): Unit = {
    +    plan.foreachUp {
    --- End diff --
    
    I want to highlight the specific sub-tree of the plan that is the culprint. Thats why i am doing foreachUp, so that I can give more specific error messages to the user.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [WIP, DO-NOT-MERGE][SPARK-14473][SQL] Define a...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-207137208
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/55271/
    Test FAILed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [WIP, DO-NOT-MERGE][SPARK-14473][SQL] Define a...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-208612531
  
    **[Test build #55547 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/55547/consoleFull)** for PR 12246 at commit [`cbcb69d`](https://github.com/apache/spark/commit/cbcb69d399b0de242008c34f2e9ac480ec212f79).
     * This patch **fails to build**.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by zsxwing <gi...@git.apache.org>.
Github user zsxwing commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12246#discussion_r59932341
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/UnsupportedOperationChecker.scala ---
    @@ -0,0 +1,145 @@
    +/*
    + * 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.spark.sql.catalyst.analysis
    +
    +import org.apache.spark.sql.AnalysisException
    +import org.apache.spark.sql.catalyst.plans._
    +import org.apache.spark.sql.catalyst.plans.logical._
    +
    +/**
    + * Analyzes the presence of unsupported operations in a logical plan.
    + */
    +object UnsupportedOperationChecker {
    +
    +  def checkForBatch(plan: LogicalPlan): Unit = {
    +    plan.foreachUp {
    +      case p if p.isStreaming =>
    +        throwError(
    +          "Queries with streaming sources must be executed with write.startStream()")(p)
    +
    +      case _ =>
    +    }
    +  }
    +
    +  def checkForStreaming(plan: LogicalPlan, outputMode: OutputMode): Unit = {
    +
    +    if (!plan.isStreaming) {
    +      throwError(
    +        "Queries without streaming sources cannot be executed with write.startStream()")(plan)
    +    }
    +
    +    plan.foreachUp { implicit plan =>
    +
    +      // Operations that cannot exists anywhere in a streaming plan
    +      plan match {
    +
    +        case _: Command =>
    +          throwError("Commands like CreateTable*, AlterTable*, Show* are not supported with " +
    +            "streaming DataFrames/Datasets")
    +
    +        case _: InsertIntoTable =>
    +          throwError("InsertIntoTable is not supported with streaming DataFrames/Datasets")
    +
    +        case Aggregate(_, _, child) if child.isStreaming && outputMode == Append =>
    +          throwError(
    +            "Aggregations are not supported on streaming DataFrames/Datasets in " +
    +              "Append output mode. Consider changing output mode to Update.")
    +
    +        case Join(left, right, joinType, _) =>
    +
    +          joinType match {
    +
    +            case Inner =>
    +              if (left.isStreaming && right.isStreaming) {
    +                throwError("Inner join between two streaming DataFrames/Datasets is not supported")
    +              }
    +
    +            case FullOuter =>
    +              if (left.isStreaming || right.isStreaming) {
    +                throwError("Full outer joins with streaming DataFrames/Datasets are not supported")
    +              }
    +
    +
    +            case LeftOuter | LeftSemi | LeftAnti =>
    +              if (right.isStreaming) {
    +                throwError("Left outer/semi/anti joins with a streaming DataFrame/Dataset " +
    +                    "on the right is not supported")
    +              }
    +
    +            case RightOuter =>
    +              if (left.isStreaming) {
    +                throwError("Right outer join with a streaming DataFrame/Dataset on the left is " +
    +                    "not supported")
    +              }
    +
    +            case NaturalJoin(_) | UsingJoin(_, _) =>
    +              // They should not appear in an analyzed plan.
    +
    +            case _ =>
    +              throwError(s"Join type $joinType is not supported with streaming DataFrame/Dataset")
    +          }
    +
    +        case c: CoGroup if plan.children.exists(_.isStreaming) =>
    +          throwError("CoGrouping between two streaming DataFrames/Datasets is not supported")
    +
    +        case u: Union if u.children.count(_.isStreaming) == 1 =>
    +          throwError("Union between streaming and batch DataFrames/Datasets is not supported")
    +
    +        case Except(left, right) if right.isStreaming =>
    +          throwError("Except with a streaming DataFrame/Dataset on the right is not supported")
    +
    +        case Intersect(left, right) if left.isStreaming && right.isStreaming =>
    +          throwError("Intersect between two streaming DataFrames/Datasets is not supported")
    +
    +        case GroupingSets(_, _, child, _) if child.isStreaming =>
    +          throwError("GroupingSets is not supported on streaming DataFrames/Datasets")
    +
    +        case GlobalLimit(_, _) | LocalLimit(_, _) if plan.children.forall(_.isStreaming) =>
    --- End diff --
    
    `plan.children.forall(_.isStreaming)` is wrong. However, `plan.children.forall(_.isStreaming)` can be removed since `plan.isStreaming` is true.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [WIP, DO-NOT-MERGE][SPARK-14473][SQL] Define a...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-207137206
  
    Merged build finished. Test FAILed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-210269363
  
    **[Test build #55890 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/55890/consoleFull)** for PR 12246 at commit [`3f1353e`](https://github.com/apache/spark/commit/3f1353e96e94f11c431c1d1f75f9782731fafc53).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-210660409
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/55956/
    Test FAILed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-210697628
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/55976/
    Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by marmbrus <gi...@git.apache.org>.
Github user marmbrus commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12246#discussion_r59763849
  
    --- Diff: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/UnsupportedOperationsSuite.scala ---
    @@ -0,0 +1,379 @@
    +/*
    + * 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.spark.sql.catalyst.analysis
    +
    +import org.apache.spark.SparkFunSuite
    +import org.apache.spark.sql.AnalysisException
    +import org.apache.spark.sql.catalyst.dsl.expressions._
    +import org.apache.spark.sql.catalyst.dsl.plans._
    +import org.apache.spark.sql.catalyst.encoders.ExpressionEncoder
    +import org.apache.spark.sql.catalyst.expressions.AttributeReference
    +import org.apache.spark.sql.catalyst.plans._
    +import org.apache.spark.sql.catalyst.plans.logical._
    +import org.apache.spark.sql.types.IntegerType
    +
    +class UnsupportedOperationsSuite extends SparkFunSuite {
    +
    +  val batchRelation = LocalRelation(AttributeReference("a", IntegerType, nullable = true)())
    +
    +  val streamRelation = new LocalRelation(
    --- End diff --
    
    Extending case classes is not really supported / might be deprecated.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [WIP, DO-NOT-MERGE][SPARK-14473][SQL] Define a...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-207194503
  
    **[Test build #55306 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/55306/consoleFull)** for PR 12246 at commit [`6e8c957`](https://github.com/apache/spark/commit/6e8c957d6025907eb2b1864275da49d468449ddd).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [WIP, DO-NOT-MERGE][SPARK-14473][SQL] Define a...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-207678192
  
    Merged build finished. Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [WIP, DO-NOT-MERGE][SPARK-14473][SQL] Define a...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-207139833
  
    Merged build finished. Test FAILed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by zsxwing <gi...@git.apache.org>.
Github user zsxwing commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12246#discussion_r59932993
  
    --- Diff: sql/core/src/test/scala/org/apache/spark/sql/streaming/StreamSuite.scala ---
    @@ -108,6 +107,36 @@ class StreamSuite extends StreamTest with SharedSQLContext {
         assertDF(df)
         assertDF(df)
       }
    +
    +  test("unsupported queries") {
    +    val c = sqlContext
    --- End diff --
    
    nit: redundant line


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by zsxwing <gi...@git.apache.org>.
Github user zsxwing commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-210677864
  
    retest this please


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by marmbrus <gi...@git.apache.org>.
Github user marmbrus commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12246#discussion_r59942192
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/UnsupportedOperationChecker.scala ---
    @@ -0,0 +1,145 @@
    +/*
    + * 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.spark.sql.catalyst.analysis
    +
    +import org.apache.spark.sql.AnalysisException
    +import org.apache.spark.sql.catalyst.plans._
    +import org.apache.spark.sql.catalyst.plans.logical._
    +
    +/**
    + * Analyzes the presence of unsupported operations in a logical plan.
    + */
    +object UnsupportedOperationChecker {
    +
    +  def checkForBatch(plan: LogicalPlan): Unit = {
    +    plan.foreachUp {
    +      case p if p.isStreaming =>
    +        throwError(
    +          "Queries with streaming sources must be executed with write.startStream()")(p)
    +
    +      case _ =>
    +    }
    +  }
    +
    +  def checkForStreaming(plan: LogicalPlan, outputMode: OutputMode): Unit = {
    +
    +    if (!plan.isStreaming) {
    +      throwError(
    +        "Queries without streaming sources cannot be executed with write.startStream()")(plan)
    +    }
    +
    +    plan.foreachUp { implicit plan =>
    +
    +      // Operations that cannot exists anywhere in a streaming plan
    +      plan match {
    +
    +        case _: Command =>
    +          throwError("Commands like CreateTable*, AlterTable*, Show* are not supported with " +
    +            "streaming DataFrames/Datasets")
    +
    +        case _: InsertIntoTable =>
    +          throwError("InsertIntoTable is not supported with streaming DataFrames/Datasets")
    +
    +        case Aggregate(_, _, child) if child.isStreaming && outputMode == Append =>
    +          throwError(
    +            "Aggregations are not supported on streaming DataFrames/Datasets in " +
    +              "Append output mode. Consider changing output mode to Update.")
    +
    +        case Join(left, right, joinType, _) =>
    +
    +          joinType match {
    +
    +            case Inner =>
    +              if (left.isStreaming && right.isStreaming) {
    +                throwError("Inner join between two streaming DataFrames/Datasets is not supported")
    +              }
    +
    +            case FullOuter =>
    +              if (left.isStreaming || right.isStreaming) {
    +                throwError("Full outer joins with streaming DataFrames/Datasets are not supported")
    +              }
    +
    +
    +            case LeftOuter | LeftSemi | LeftAnti =>
    +              if (right.isStreaming) {
    +                throwError("Left outer/semi/anti joins with a streaming DataFrame/Dataset " +
    +                    "on the right is not supported")
    +              }
    +
    +            case RightOuter =>
    +              if (left.isStreaming) {
    +                throwError("Right outer join with a streaming DataFrame/Dataset on the left is " +
    +                    "not supported")
    +              }
    +
    +            case NaturalJoin(_) | UsingJoin(_, _) =>
    +              // They should not appear in an analyzed plan.
    +
    +            case _ =>
    +              throwError(s"Join type $joinType is not supported with streaming DataFrame/Dataset")
    +          }
    +
    +        case c: CoGroup if plan.children.exists(_.isStreaming) =>
    +          throwError("CoGrouping between two streaming DataFrames/Datasets is not supported")
    --- End diff --
    
    hmmm is cogrouping supported at all?  typically the two iterators should have all the data for a group.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-208752097
  
    **[Test build #55590 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/55590/consoleFull)** for PR 12246 at commit [`6aa5554`](https://github.com/apache/spark/commit/6aa5554d4969c4c3b061194c3fe6d685d8912b92).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by tdas <gi...@git.apache.org>.
Github user tdas commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-210269322
  
    There was a critical bug that made it not test the non-supported cases. Fixed it and updated the PR. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-208662558
  
    **[Test build #55572 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/55572/consoleFull)** for PR 12246 at commit [`64ed243`](https://github.com/apache/spark/commit/64ed24347de349e8e734ad50c11392eb17237d4e).
     * This patch **fails Scala style tests**.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by tdas <gi...@git.apache.org>.
Github user tdas commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12246#discussion_r59932855
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/UnsupportedOperationChecker.scala ---
    @@ -0,0 +1,145 @@
    +/*
    + * 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.spark.sql.catalyst.analysis
    +
    +import org.apache.spark.sql.AnalysisException
    +import org.apache.spark.sql.catalyst.plans._
    +import org.apache.spark.sql.catalyst.plans.logical._
    +
    +/**
    + * Analyzes the presence of unsupported operations in a logical plan.
    + */
    +object UnsupportedOperationChecker {
    +
    +  def checkForBatch(plan: LogicalPlan): Unit = {
    +    plan.foreachUp {
    +      case p if p.isStreaming =>
    +        throwError(
    +          "Queries with streaming sources must be executed with write.startStream()")(p)
    +
    +      case _ =>
    +    }
    +  }
    +
    +  def checkForStreaming(plan: LogicalPlan, outputMode: OutputMode): Unit = {
    +
    +    if (!plan.isStreaming) {
    +      throwError(
    +        "Queries without streaming sources cannot be executed with write.startStream()")(plan)
    +    }
    +
    +    plan.foreachUp { implicit plan =>
    +
    +      // Operations that cannot exists anywhere in a streaming plan
    +      plan match {
    +
    +        case _: Command =>
    +          throwError("Commands like CreateTable*, AlterTable*, Show* are not supported with " +
    +            "streaming DataFrames/Datasets")
    +
    +        case _: InsertIntoTable =>
    +          throwError("InsertIntoTable is not supported with streaming DataFrames/Datasets")
    +
    +        case Aggregate(_, _, child) if child.isStreaming && outputMode == Append =>
    +          throwError(
    +            "Aggregations are not supported on streaming DataFrames/Datasets in " +
    +              "Append output mode. Consider changing output mode to Update.")
    +
    +        case Join(left, right, joinType, _) =>
    +
    +          joinType match {
    +
    +            case Inner =>
    +              if (left.isStreaming && right.isStreaming) {
    +                throwError("Inner join between two streaming DataFrames/Datasets is not supported")
    +              }
    +
    +            case FullOuter =>
    +              if (left.isStreaming || right.isStreaming) {
    +                throwError("Full outer joins with streaming DataFrames/Datasets are not supported")
    +              }
    +
    +
    +            case LeftOuter | LeftSemi | LeftAnti =>
    +              if (right.isStreaming) {
    +                throwError("Left outer/semi/anti joins with a streaming DataFrame/Dataset " +
    +                    "on the right is not supported")
    +              }
    +
    +            case RightOuter =>
    +              if (left.isStreaming) {
    +                throwError("Right outer join with a streaming DataFrame/Dataset on the left is " +
    +                    "not supported")
    +              }
    +
    +            case NaturalJoin(_) | UsingJoin(_, _) =>
    +              // They should not appear in an analyzed plan.
    +
    +            case _ =>
    +              throwError(s"Join type $joinType is not supported with streaming DataFrame/Dataset")
    +          }
    +
    +        case c: CoGroup if plan.children.exists(_.isStreaming) =>
    +          throwError("CoGrouping between two streaming DataFrames/Datasets is not supported")
    --- End diff --
    
    updated.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [WIP, DO-NOT-MERGE][SPARK-14473][SQL] Define a...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-207139810
  
    **[Test build #55273 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/55273/consoleFull)** for PR 12246 at commit [`edd1ac1`](https://github.com/apache/spark/commit/edd1ac1c954c38ee019792715c0c1cfec0cce519).
     * This patch **fails MiMa tests**.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-210678035
  
    **[Test build #55976 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/55976/consoleFull)** for PR 12246 at commit [`8a71835`](https://github.com/apache/spark/commit/8a71835f4011a3570990669346a65dcea51adb4f).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by marmbrus <gi...@git.apache.org>.
Github user marmbrus commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12246#discussion_r59762314
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/UnsupportedOperationChecker.scala ---
    @@ -0,0 +1,143 @@
    +/*
    + * 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.spark.sql.catalyst.analysis
    +
    +import org.apache.spark.sql.AnalysisException
    +import org.apache.spark.sql.catalyst.plans._
    +import org.apache.spark.sql.catalyst.plans.logical._
    +
    +/**
    + * Analyzes the presence of unsupported operations in a logical plan.
    + */
    +object UnsupportedOperationChecker {
    +
    +  def checkForBatch(plan: LogicalPlan): Unit = {
    +    plan.foreachUp {
    +      case p if p.isStreaming =>
    +        throwError(
    +          "Queries with streaming sources must be executed with write.startStream()")(p)
    +
    +      case _ =>
    +    }
    +  }
    +
    +  def checkForStreaming(plan: LogicalPlan, outputMode: OutputMode): Unit = {
    +
    +    if (!plan.isStreaming) {
    +      throwError(
    +        "Queries without streaming sources cannot be executed with write.startStream()")(plan)
    +    }
    +
    +    plan.foreachUp { implicit plan =>
    +
    +      // Operations that cannot exists anywhere in a streaming plan
    +      plan match {
    +
    +        case _: Command =>
    +          throwError("Commands like CreateTable*, AlterTable*, Show* are not supported with " +
    +            "streaming DataFrames/Datasets")
    +
    +        case _: InsertIntoTable =>
    +          throwError("InsertIntoTable is not supported with streaming DataFrames/Datasets")
    +
    +        case Aggregate(_, _, child) if child.isStreaming && outputMode == Append =>
    +          throwError(
    +            "Aggregations are not supported on streaming DataFrames/Datasets in " +
    +              "Append output mode. Consider changing output mode to Update.")
    +
    +        case Join(left, right, joinType, _) =>
    +
    +          joinType match {
    +
    +            case Inner =>
    +              throwErrorIf(
    --- End diff --
    
    Half of this file is putting the `if` as `


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by tdas <gi...@git.apache.org>.
Github user tdas commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12246#discussion_r59932690
  
    --- Diff: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/UnsupportedOperationsSuite.scala ---
    @@ -0,0 +1,379 @@
    +/*
    + * 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.spark.sql.catalyst.analysis
    +
    +import org.apache.spark.SparkFunSuite
    +import org.apache.spark.sql.AnalysisException
    +import org.apache.spark.sql.catalyst.dsl.expressions._
    +import org.apache.spark.sql.catalyst.dsl.plans._
    +import org.apache.spark.sql.catalyst.encoders.ExpressionEncoder
    +import org.apache.spark.sql.catalyst.expressions.AttributeReference
    +import org.apache.spark.sql.catalyst.plans._
    +import org.apache.spark.sql.catalyst.plans.logical._
    +import org.apache.spark.sql.types.IntegerType
    +
    +class UnsupportedOperationsSuite extends SparkFunSuite {
    +
    +  val batchRelation = LocalRelation(AttributeReference("a", IntegerType, nullable = true)())
    +
    +  val streamRelation = new LocalRelation(
    +    Seq(AttributeReference("a", IntegerType, nullable = true)())) {
    +    override def isStreaming: Boolean = true
    +  }
    +
    +  /*
    +    =======================================================================================
    +                                     BATCH QUERIES
    +    =======================================================================================
    +   */
    +
    +  assertSupportedForBatch("local relation", batchRelation)
    +
    +  assertNotSupportedForBatch(
    +    "streaming source",
    +    streamRelation,
    +    Seq("with streaming source", "startStream"))
    +
    +  assertNotSupportedForBatch(
    +    "select on streaming source",
    +    streamRelation.select($"count(*)"),
    +    Seq("with streaming source", "startStream"))
    +
    +
    +  /*
    +    =======================================================================================
    +                                     STREAMING QUERIES
    +    =======================================================================================
    +   */
    +
    +  // Batch plan in streaming query
    +  testError("batch source", Seq("without streaming source", "startStream")) {
    +    UnsupportedOperationChecker.checkForStreaming(batchRelation.select($"count(*)"), Append)
    +  }
    +
    +  // Commands
    +  assertNotSupportedForStreaming(
    +    "commmands",
    +    DescribeFunction("func", true),
    +    outputMode = Append,
    +    expectedMsgs = "commands" :: Nil)
    +
    +  // Aggregates: Not supported on streams in Append mode
    +  assertSupportedForStreaming(
    +    "aggregate - stream with update output mode",
    +    batchRelation.groupBy("a")("count(*)"),
    +    outputMode = Update)
    +
    +  assertSupportedForStreaming(
    +    "aggregate - batch with update output mode",
    +    streamRelation.groupBy("a")("count(*)"),
    +    outputMode = Update)
    +
    +  assertSupportedForStreaming(
    +    "aggregate - batch with append output mode",
    +    batchRelation.groupBy("a")("count(*)"),
    +    outputMode = Append)
    +
    +  assertNotSupportedForStreaming(
    +    "aggregate - stream with append output mode",
    +    streamRelation.groupBy("a")("count(*)"),
    +    outputMode = Append,
    +    Seq("aggregation", "append output mode"))
    +
    +  // Inner joins: Stream-stream not supported
    +  testBinaryOperationForStreaming(
    +    "inner join",
    +    _.join(_, joinType = Inner),
    +    streamStreamSupported = false)
    +
    +  // Full outer joins: only batch-batch is allowed
    +  testBinaryOperationForStreaming(
    +    "full outer join",
    +    _.join(_, joinType = FullOuter),
    +    streamStreamSupported = false,
    +    batchStreamSupported = false,
    +    streamBatchSupported = false)
    +
    +  // Left outer joins: *-stream not allowed
    +  testBinaryOperationForStreaming(
    +    "left outer join",
    +    _.join(_, joinType = LeftOuter),
    +    streamStreamSupported = false,
    +    batchStreamSupported = false,
    +    expectedMsg = "left outer/semi/anti joins")
    +
    +  // Left semi joins: stream-* not allowed
    +  testBinaryOperationForStreaming(
    +    "left semi join",
    +    _.join(_, joinType = LeftSemi),
    +    streamStreamSupported = false,
    +    batchStreamSupported = false,
    +    expectedMsg = "left outer/semi/anti joins")
    +
    +  // Left anti joins: stream-* not allowed
    +  testBinaryOperationForStreaming(
    +    "left anti join",
    +    _.join(_, joinType = LeftAnti),
    +    streamStreamSupported = false,
    +    batchStreamSupported = false,
    +    expectedMsg = "left outer/semi/anti joins")
    +
    +  // Right outer joins: stream-* not allowed
    +  testBinaryOperationForStreaming(
    +    "right outer join",
    +    _.join(_, joinType = RightOuter),
    +    streamStreamSupported = false,
    +    streamBatchSupported = false)
    +
    +  // Cogroup: only batch-batch is allowed
    +  testBinaryOperationForStreaming(
    +    "cogroup",
    +    genCogroup,
    +    streamStreamSupported = false,
    +    batchStreamSupported = false,
    +    streamBatchSupported = false)
    +
    +  def genCogroup(left: LogicalPlan, right: LogicalPlan): LogicalPlan = {
    --- End diff --
    
    I added cogroup, but still the interface has to be very similar as CoGroup.apply. So does not help much


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by marmbrus <gi...@git.apache.org>.
Github user marmbrus commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12246#discussion_r59762181
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/OutputMode.scala ---
    @@ -0,0 +1,23 @@
    +/*
    + * 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.spark.sql.catalyst.analysis
    +
    +trait OutputMode
    --- End diff --
    
    `sealed`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/spark/pull/12246


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [WIP, DO-NOT-MERGE][SPARK-14473][SQL] Define a...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-207136294
  
    Merged build finished. Test FAILed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by marmbrus <gi...@git.apache.org>.
Github user marmbrus commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-210081598
  
    Some minor comments, otherwise LGTM.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [WIP, DO-NOT-MERGE][SPARK-14473][SQL] Define a...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-207659224
  
    **[Test build #55406 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/55406/consoleFull)** for PR 12246 at commit [`bbf9f27`](https://github.com/apache/spark/commit/bbf9f27dbd72de5efef3c22711f7a57cfd04fe17).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by tdas <gi...@git.apache.org>.
Github user tdas commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12246#discussion_r59936839
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/UnsupportedOperationChecker.scala ---
    @@ -0,0 +1,145 @@
    +/*
    + * 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.spark.sql.catalyst.analysis
    +
    +import org.apache.spark.sql.AnalysisException
    +import org.apache.spark.sql.catalyst.plans._
    +import org.apache.spark.sql.catalyst.plans.logical._
    +
    +/**
    + * Analyzes the presence of unsupported operations in a logical plan.
    + */
    +object UnsupportedOperationChecker {
    +
    +  def checkForBatch(plan: LogicalPlan): Unit = {
    +    plan.foreachUp {
    +      case p if p.isStreaming =>
    +        throwError(
    +          "Queries with streaming sources must be executed with write.startStream()")(p)
    +
    +      case _ =>
    +    }
    +  }
    +
    +  def checkForStreaming(plan: LogicalPlan, outputMode: OutputMode): Unit = {
    +
    +    if (!plan.isStreaming) {
    +      throwError(
    +        "Queries without streaming sources cannot be executed with write.startStream()")(plan)
    +    }
    +
    +    plan.foreachUp { implicit plan =>
    +
    +      // Operations that cannot exists anywhere in a streaming plan
    +      plan match {
    +
    +        case _: Command =>
    +          throwError("Commands like CreateTable*, AlterTable*, Show* are not supported with " +
    +            "streaming DataFrames/Datasets")
    +
    +        case _: InsertIntoTable =>
    +          throwError("InsertIntoTable is not supported with streaming DataFrames/Datasets")
    +
    +        case Aggregate(_, _, child) if child.isStreaming && outputMode == Append =>
    +          throwError(
    +            "Aggregations are not supported on streaming DataFrames/Datasets in " +
    +              "Append output mode. Consider changing output mode to Update.")
    +
    +        case Join(left, right, joinType, _) =>
    +
    +          joinType match {
    +
    +            case Inner =>
    +              if (left.isStreaming && right.isStreaming) {
    +                throwError("Inner join between two streaming DataFrames/Datasets is not supported")
    +              }
    +
    +            case FullOuter =>
    +              if (left.isStreaming || right.isStreaming) {
    +                throwError("Full outer joins with streaming DataFrames/Datasets are not supported")
    +              }
    +
    +
    +            case LeftOuter | LeftSemi | LeftAnti =>
    +              if (right.isStreaming) {
    +                throwError("Left outer/semi/anti joins with a streaming DataFrame/Dataset " +
    +                    "on the right is not supported")
    +              }
    +
    +            case RightOuter =>
    +              if (left.isStreaming) {
    +                throwError("Right outer join with a streaming DataFrame/Dataset on the left is " +
    +                    "not supported")
    +              }
    +
    +            case NaturalJoin(_) | UsingJoin(_, _) =>
    +              // They should not appear in an analyzed plan.
    +
    +            case _ =>
    +              throwError(s"Join type $joinType is not supported with streaming DataFrame/Dataset")
    +          }
    +
    +        case c: CoGroup if plan.children.exists(_.isStreaming) =>
    +          throwError("CoGrouping between two streaming DataFrames/Datasets is not supported")
    +
    +        case u: Union if u.children.count(_.isStreaming) == 1 =>
    --- End diff --
    
    Correction. I didnt realize that union can have multiple children, not just two. Fixed the bug.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by zsxwing <gi...@git.apache.org>.
Github user zsxwing commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12246#discussion_r59932237
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/UnsupportedOperationChecker.scala ---
    @@ -0,0 +1,145 @@
    +/*
    + * 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.spark.sql.catalyst.analysis
    +
    +import org.apache.spark.sql.AnalysisException
    +import org.apache.spark.sql.catalyst.plans._
    +import org.apache.spark.sql.catalyst.plans.logical._
    +
    +/**
    + * Analyzes the presence of unsupported operations in a logical plan.
    + */
    +object UnsupportedOperationChecker {
    +
    +  def checkForBatch(plan: LogicalPlan): Unit = {
    +    plan.foreachUp {
    +      case p if p.isStreaming =>
    +        throwError(
    +          "Queries with streaming sources must be executed with write.startStream()")(p)
    +
    +      case _ =>
    +    }
    +  }
    +
    +  def checkForStreaming(plan: LogicalPlan, outputMode: OutputMode): Unit = {
    +
    +    if (!plan.isStreaming) {
    +      throwError(
    +        "Queries without streaming sources cannot be executed with write.startStream()")(plan)
    +    }
    +
    +    plan.foreachUp { implicit plan =>
    +
    +      // Operations that cannot exists anywhere in a streaming plan
    +      plan match {
    +
    +        case _: Command =>
    +          throwError("Commands like CreateTable*, AlterTable*, Show* are not supported with " +
    +            "streaming DataFrames/Datasets")
    +
    +        case _: InsertIntoTable =>
    +          throwError("InsertIntoTable is not supported with streaming DataFrames/Datasets")
    +
    +        case Aggregate(_, _, child) if child.isStreaming && outputMode == Append =>
    +          throwError(
    +            "Aggregations are not supported on streaming DataFrames/Datasets in " +
    +              "Append output mode. Consider changing output mode to Update.")
    +
    +        case Join(left, right, joinType, _) =>
    +
    +          joinType match {
    +
    +            case Inner =>
    +              if (left.isStreaming && right.isStreaming) {
    +                throwError("Inner join between two streaming DataFrames/Datasets is not supported")
    +              }
    +
    +            case FullOuter =>
    +              if (left.isStreaming || right.isStreaming) {
    +                throwError("Full outer joins with streaming DataFrames/Datasets are not supported")
    +              }
    +
    +
    +            case LeftOuter | LeftSemi | LeftAnti =>
    +              if (right.isStreaming) {
    +                throwError("Left outer/semi/anti joins with a streaming DataFrame/Dataset " +
    +                    "on the right is not supported")
    +              }
    +
    +            case RightOuter =>
    +              if (left.isStreaming) {
    +                throwError("Right outer join with a streaming DataFrame/Dataset on the left is " +
    +                    "not supported")
    +              }
    +
    +            case NaturalJoin(_) | UsingJoin(_, _) =>
    +              // They should not appear in an analyzed plan.
    +
    +            case _ =>
    +              throwError(s"Join type $joinType is not supported with streaming DataFrame/Dataset")
    +          }
    +
    +        case c: CoGroup if plan.children.exists(_.isStreaming) =>
    --- End diff --
    
    nit: `if plan.children.exists(_.isStreaming)` can be removed since `plan. isStreaming` is true.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-208752569
  
    Merged build finished. Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by zsxwing <gi...@git.apache.org>.
Github user zsxwing commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12246#discussion_r59933665
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/UnsupportedOperationChecker.scala ---
    @@ -0,0 +1,145 @@
    +/*
    + * 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.spark.sql.catalyst.analysis
    +
    +import org.apache.spark.sql.AnalysisException
    +import org.apache.spark.sql.catalyst.plans._
    +import org.apache.spark.sql.catalyst.plans.logical._
    +
    +/**
    + * Analyzes the presence of unsupported operations in a logical plan.
    + */
    +object UnsupportedOperationChecker {
    +
    +  def checkForBatch(plan: LogicalPlan): Unit = {
    +    plan.foreachUp {
    +      case p if p.isStreaming =>
    +        throwError(
    +          "Queries with streaming sources must be executed with write.startStream()")(p)
    +
    +      case _ =>
    +    }
    +  }
    +
    +  def checkForStreaming(plan: LogicalPlan, outputMode: OutputMode): Unit = {
    +
    +    if (!plan.isStreaming) {
    +      throwError(
    +        "Queries without streaming sources cannot be executed with write.startStream()")(plan)
    +    }
    +
    +    plan.foreachUp { implicit plan =>
    +
    +      // Operations that cannot exists anywhere in a streaming plan
    +      plan match {
    +
    +        case _: Command =>
    +          throwError("Commands like CreateTable*, AlterTable*, Show* are not supported with " +
    +            "streaming DataFrames/Datasets")
    +
    +        case _: InsertIntoTable =>
    +          throwError("InsertIntoTable is not supported with streaming DataFrames/Datasets")
    +
    +        case Aggregate(_, _, child) if child.isStreaming && outputMode == Append =>
    +          throwError(
    +            "Aggregations are not supported on streaming DataFrames/Datasets in " +
    +              "Append output mode. Consider changing output mode to Update.")
    +
    +        case Join(left, right, joinType, _) =>
    +
    +          joinType match {
    +
    +            case Inner =>
    +              if (left.isStreaming && right.isStreaming) {
    +                throwError("Inner join between two streaming DataFrames/Datasets is not supported")
    +              }
    +
    +            case FullOuter =>
    +              if (left.isStreaming || right.isStreaming) {
    +                throwError("Full outer joins with streaming DataFrames/Datasets are not supported")
    +              }
    +
    +
    +            case LeftOuter | LeftSemi | LeftAnti =>
    +              if (right.isStreaming) {
    +                throwError("Left outer/semi/anti joins with a streaming DataFrame/Dataset " +
    +                    "on the right is not supported")
    +              }
    +
    +            case RightOuter =>
    +              if (left.isStreaming) {
    +                throwError("Right outer join with a streaming DataFrame/Dataset on the left is " +
    +                    "not supported")
    +              }
    +
    +            case NaturalJoin(_) | UsingJoin(_, _) =>
    +              // They should not appear in an analyzed plan.
    +
    +            case _ =>
    +              throwError(s"Join type $joinType is not supported with streaming DataFrame/Dataset")
    +          }
    +
    +        case c: CoGroup if plan.children.exists(_.isStreaming) =>
    +          throwError("CoGrouping between two streaming DataFrames/Datasets is not supported")
    +
    +        case u: Union if u.children.count(_.isStreaming) == 1 =>
    +          throwError("Union between streaming and batch DataFrames/Datasets is not supported")
    +
    +        case Except(left, right) if right.isStreaming =>
    +          throwError("Except with a streaming DataFrame/Dataset on the right is not supported")
    +
    +        case Intersect(left, right) if left.isStreaming && right.isStreaming =>
    +          throwError("Intersect between two streaming DataFrames/Datasets is not supported")
    +
    +        case GroupingSets(_, _, child, _) if child.isStreaming =>
    +          throwError("GroupingSets is not supported on streaming DataFrames/Datasets")
    +
    +        case GlobalLimit(_, _) | LocalLimit(_, _) if plan.children.forall(_.isStreaming) =>
    --- End diff --
    
    > whats the difference between forall and exists when there is one child?
    
    didn't notice it. They are same.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by zsxwing <gi...@git.apache.org>.
Github user zsxwing commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12246#discussion_r59932041
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/UnsupportedOperationChecker.scala ---
    @@ -0,0 +1,145 @@
    +/*
    + * 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.spark.sql.catalyst.analysis
    +
    +import org.apache.spark.sql.AnalysisException
    +import org.apache.spark.sql.catalyst.plans._
    +import org.apache.spark.sql.catalyst.plans.logical._
    +
    +/**
    + * Analyzes the presence of unsupported operations in a logical plan.
    + */
    +object UnsupportedOperationChecker {
    +
    +  def checkForBatch(plan: LogicalPlan): Unit = {
    +    plan.foreachUp {
    +      case p if p.isStreaming =>
    +        throwError(
    +          "Queries with streaming sources must be executed with write.startStream()")(p)
    +
    +      case _ =>
    +    }
    +  }
    +
    +  def checkForStreaming(plan: LogicalPlan, outputMode: OutputMode): Unit = {
    +
    +    if (!plan.isStreaming) {
    +      throwError(
    +        "Queries without streaming sources cannot be executed with write.startStream()")(plan)
    +    }
    +
    +    plan.foreachUp { implicit plan =>
    +
    +      // Operations that cannot exists anywhere in a streaming plan
    +      plan match {
    +
    +        case _: Command =>
    +          throwError("Commands like CreateTable*, AlterTable*, Show* are not supported with " +
    +            "streaming DataFrames/Datasets")
    +
    +        case _: InsertIntoTable =>
    +          throwError("InsertIntoTable is not supported with streaming DataFrames/Datasets")
    +
    +        case Aggregate(_, _, child) if child.isStreaming && outputMode == Append =>
    +          throwError(
    +            "Aggregations are not supported on streaming DataFrames/Datasets in " +
    +              "Append output mode. Consider changing output mode to Update.")
    +
    +        case Join(left, right, joinType, _) =>
    +
    +          joinType match {
    +
    +            case Inner =>
    +              if (left.isStreaming && right.isStreaming) {
    +                throwError("Inner join between two streaming DataFrames/Datasets is not supported")
    +              }
    +
    +            case FullOuter =>
    +              if (left.isStreaming || right.isStreaming) {
    +                throwError("Full outer joins with streaming DataFrames/Datasets are not supported")
    +              }
    +
    +
    +            case LeftOuter | LeftSemi | LeftAnti =>
    +              if (right.isStreaming) {
    +                throwError("Left outer/semi/anti joins with a streaming DataFrame/Dataset " +
    +                    "on the right is not supported")
    +              }
    +
    +            case RightOuter =>
    +              if (left.isStreaming) {
    +                throwError("Right outer join with a streaming DataFrame/Dataset on the left is " +
    +                    "not supported")
    +              }
    +
    +            case NaturalJoin(_) | UsingJoin(_, _) =>
    +              // They should not appear in an analyzed plan.
    +
    +            case _ =>
    +              throwError(s"Join type $joinType is not supported with streaming DataFrame/Dataset")
    +          }
    +
    +        case c: CoGroup if plan.children.exists(_.isStreaming) =>
    +          throwError("CoGrouping between two streaming DataFrames/Datasets is not supported")
    +
    +        case u: Union if u.children.count(_.isStreaming) == 1 =>
    --- End diff --
    
    should be `!u.children.forall(_.isStreaming)`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [WIP, DO-NOT-MERGE][SPARK-14473][SQL] Define a...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-208612546
  
    Merged build finished. Test FAILed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-210287120
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/55890/
    Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [WIP, DO-NOT-MERGE][SPARK-14473][SQL] Define a...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-208612551
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/55547/
    Test FAILed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [WIP, DO-NOT-MERGE][SPARK-14473][SQL] Define a...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-207136112
  
    **[Test build #55267 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/55267/consoleFull)** for PR 12246 at commit [`87b9782`](https://github.com/apache/spark/commit/87b97828d43a648d10b84fe098cecc1a26cd1817).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-210697627
  
    Merged build finished. Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [WIP, DO-NOT-MERGE][SPARK-14473][SQL] Define a...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-207136296
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/55267/
    Test FAILed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by zsxwing <gi...@git.apache.org>.
Github user zsxwing commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-210634397
  
    LGTM


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [WIP, DO-NOT-MERGE][SPARK-14473][SQL] Define a...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-208658808
  
    **[Test build #55553 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/55553/consoleFull)** for PR 12246 at commit [`cc7baab`](https://github.com/apache/spark/commit/cc7baab4d74c8cc84e27df74cb6d4d4b2540ebd3).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-208720591
  
    **[Test build #55590 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/55590/consoleFull)** for PR 12246 at commit [`6aa5554`](https://github.com/apache/spark/commit/6aa5554d4969c4c3b061194c3fe6d685d8912b92).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-208662563
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/55572/
    Test FAILed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by marmbrus <gi...@git.apache.org>.
Github user marmbrus commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12246#discussion_r59764187
  
    --- Diff: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/UnsupportedOperationsSuite.scala ---
    @@ -0,0 +1,379 @@
    +/*
    + * 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.spark.sql.catalyst.analysis
    +
    +import org.apache.spark.SparkFunSuite
    +import org.apache.spark.sql.AnalysisException
    +import org.apache.spark.sql.catalyst.dsl.expressions._
    +import org.apache.spark.sql.catalyst.dsl.plans._
    +import org.apache.spark.sql.catalyst.encoders.ExpressionEncoder
    +import org.apache.spark.sql.catalyst.expressions.AttributeReference
    +import org.apache.spark.sql.catalyst.plans._
    +import org.apache.spark.sql.catalyst.plans.logical._
    +import org.apache.spark.sql.types.IntegerType
    +
    +class UnsupportedOperationsSuite extends SparkFunSuite {
    +
    +  val batchRelation = LocalRelation(AttributeReference("a", IntegerType, nullable = true)())
    +
    +  val streamRelation = new LocalRelation(
    +    Seq(AttributeReference("a", IntegerType, nullable = true)())) {
    +    override def isStreaming: Boolean = true
    +  }
    +
    +  /*
    +    =======================================================================================
    +                                     BATCH QUERIES
    +    =======================================================================================
    +   */
    +
    +  assertSupportedForBatch("local relation", batchRelation)
    +
    +  assertNotSupportedForBatch(
    +    "streaming source",
    +    streamRelation,
    +    Seq("with streaming source", "startStream"))
    +
    +  assertNotSupportedForBatch(
    +    "select on streaming source",
    +    streamRelation.select($"count(*)"),
    +    Seq("with streaming source", "startStream"))
    +
    +
    +  /*
    +    =======================================================================================
    +                                     STREAMING QUERIES
    +    =======================================================================================
    +   */
    +
    +  // Batch plan in streaming query
    +  testError("batch source", Seq("without streaming source", "startStream")) {
    +    UnsupportedOperationChecker.checkForStreaming(batchRelation.select($"count(*)"), Append)
    +  }
    +
    +  // Commands
    +  assertNotSupportedForStreaming(
    +    "commmands",
    +    DescribeFunction("func", true),
    +    outputMode = Append,
    +    expectedMsgs = "commands" :: Nil)
    +
    +  // Aggregates: Not supported on streams in Append mode
    +  assertSupportedForStreaming(
    +    "aggregate - stream with update output mode",
    +    batchRelation.groupBy("a")("count(*)"),
    +    outputMode = Update)
    +
    +  assertSupportedForStreaming(
    +    "aggregate - batch with update output mode",
    +    streamRelation.groupBy("a")("count(*)"),
    +    outputMode = Update)
    +
    +  assertSupportedForStreaming(
    +    "aggregate - batch with append output mode",
    +    batchRelation.groupBy("a")("count(*)"),
    +    outputMode = Append)
    +
    +  assertNotSupportedForStreaming(
    +    "aggregate - stream with append output mode",
    +    streamRelation.groupBy("a")("count(*)"),
    +    outputMode = Append,
    +    Seq("aggregation", "append output mode"))
    +
    +  // Inner joins: Stream-stream not supported
    +  testBinaryOperationForStreaming(
    +    "inner join",
    +    _.join(_, joinType = Inner),
    +    streamStreamSupported = false)
    +
    +  // Full outer joins: only batch-batch is allowed
    +  testBinaryOperationForStreaming(
    +    "full outer join",
    +    _.join(_, joinType = FullOuter),
    +    streamStreamSupported = false,
    +    batchStreamSupported = false,
    +    streamBatchSupported = false)
    +
    +  // Left outer joins: *-stream not allowed
    +  testBinaryOperationForStreaming(
    +    "left outer join",
    +    _.join(_, joinType = LeftOuter),
    +    streamStreamSupported = false,
    +    batchStreamSupported = false,
    +    expectedMsg = "left outer/semi/anti joins")
    +
    +  // Left semi joins: stream-* not allowed
    +  testBinaryOperationForStreaming(
    +    "left semi join",
    +    _.join(_, joinType = LeftSemi),
    +    streamStreamSupported = false,
    +    batchStreamSupported = false,
    +    expectedMsg = "left outer/semi/anti joins")
    +
    +  // Left anti joins: stream-* not allowed
    +  testBinaryOperationForStreaming(
    +    "left anti join",
    +    _.join(_, joinType = LeftAnti),
    +    streamStreamSupported = false,
    +    batchStreamSupported = false,
    +    expectedMsg = "left outer/semi/anti joins")
    +
    +  // Right outer joins: stream-* not allowed
    +  testBinaryOperationForStreaming(
    +    "right outer join",
    +    _.join(_, joinType = RightOuter),
    +    streamStreamSupported = false,
    +    streamBatchSupported = false)
    +
    +  // Cogroup: only batch-batch is allowed
    +  testBinaryOperationForStreaming(
    +    "cogroup",
    +    genCogroup,
    +    streamStreamSupported = false,
    +    batchStreamSupported = false,
    +    streamBatchSupported = false)
    +
    +  def genCogroup(left: LogicalPlan, right: LogicalPlan): LogicalPlan = {
    +    def func(k: Int, left: Iterator[Int], right: Iterator[Int]): Iterator[Int] = {
    +      Iterator.empty
    +    }
    +    implicit val intEncoder = ExpressionEncoder[Int]
    +    CoGroup[Int, Int, Int, Int](
    +      func,
    +      AppendColumns[Int, Int]((x: Int) => x, left).newColumns,
    +      AppendColumns[Int, Int]((x: Int) => x, right).newColumns,
    +      left.output,
    +      right.output,
    +      left,
    +      right
    +    )
    +  }
    +
    +  // Union: Mixing between stream and batch not supported
    +  testBinaryOperationForStreaming(
    +    "union",
    +    _.union(_),
    +    streamBatchSupported = false,
    +    batchStreamSupported = false)
    +
    +  // Except: *-stream not supported
    +  testBinaryOperationForStreaming(
    +    "except",
    +    _.except(_),
    +    streamStreamSupported = false,
    +    batchStreamSupported = false)
    +
    +  // Intersect: stream-stream not supported
    +  testBinaryOperationForStreaming(
    +    "intersect",
    +    _.intersect(_),
    +    streamStreamSupported = false)
    +
    +
    +  // Unary operations
    +  testUnaryOperatorForStreaming("sort", Sort(Nil, true, _))
    +  testUnaryOperatorForStreaming("sort partitions", SortPartitions(Nil, _), expectedMsg = "sort")
    +  testUnaryOperatorForStreaming("sample", Sample(0.1, 1, true, 1L, _)(), expectedMsg = "sampling")
    +  testUnaryOperatorForStreaming(
    +    "window", Window(Nil, Nil, Nil, _), expectedMsg = "non-time-based windows")
    +
    +
    +  /*
    +    =======================================================================================
    +                                     TESTING FUNCTIONS
    +    =======================================================================================
    +   */
    +
    +  /**
    +   * Test that an unary operator correctly fails support check when it has a streaming child plan,
    +   * but not when it has batch child plan. There can be batch sub-plans inside a streaming plan,
    +   * so it is valid for the operator to have a batch child plan.
    +   *
    +   * This test wraps the logical plan in a fake operator that makes the whole plan look like
    +   * a streaming plan even if the child plan is a batch plan. This is to test that the operator
    +   * supports having a batch child plan, forming a batch subplan inside a streaming plan.
    +   */
    +  def testUnaryOperatorForStreaming(
    +    operationName: String,
    +    logicalPlanGenerator: LogicalPlan => LogicalPlan,
    +    outputMode: OutputMode = Append,
    +    expectedMsg: String = ""): Unit = {
    +
    +    val expectedMsgs = if (expectedMsg.isEmpty) Seq(operationName) else Seq(expectedMsg)
    +
    +    assertNotSupportedForStreaming(
    +      s"$operationName with stream relation",
    +      wrapInStreaming(logicalPlanGenerator(streamRelation)),
    +      outputMode,
    +      expectedMsgs)
    +
    +    assertSupportedForStreaming(
    +      s"$operationName with batch relation",
    +      wrapInStreaming(logicalPlanGenerator(batchRelation)),
    +      outputMode)
    +  }
    +
    +
    +  /**
    +   * Test that a binary operator correctly fails support check when it has combinations of
    +   * streaming and batch child plans. There can be batch sub-plans inside a streaming plan,
    +   * so it is valid for the operator to have a batch child plan.
    +   */
    +  def testBinaryOperationForStreaming(
    +      operationName: String,
    +      planGenerator: (LogicalPlan, LogicalPlan) => LogicalPlan,
    +      outputMode: OutputMode = Append,
    +      streamStreamSupported: Boolean = true,
    +      streamBatchSupported: Boolean = true,
    +      batchStreamSupported: Boolean = true,
    +      expectedMsg: String = ""): Unit = {
    +
    +    val expectedMsgs = if (expectedMsg.isEmpty) Seq(operationName) else Seq(expectedMsg)
    +
    +    if (streamStreamSupported) {
    +      assertSupportedForStreaming(
    +        s"$operationName with stream-stream relations",
    +        planGenerator(streamRelation, streamRelation),
    +        outputMode)
    +    } else {
    +      assertNotSupportedForStreaming(
    +        s"$operationName with stream-stream relations",
    +        planGenerator(streamRelation, streamRelation),
    +        outputMode,
    +        expectedMsgs)
    +    }
    +
    +    if (streamBatchSupported) {
    +      assertSupportedForStreaming(
    +        s"$operationName with stream-batch relations",
    +        planGenerator(streamRelation, batchRelation),
    +        outputMode)
    +    } else {
    +      assertNotSupportedForStreaming(
    +        s"$operationName with stream-batch relations",
    +        planGenerator(streamRelation, batchRelation),
    +        outputMode,
    +        expectedMsgs)
    +    }
    +
    +    if (batchStreamSupported) {
    +      assertSupportedForStreaming(
    +        s"$operationName with batch-stream relations",
    +        planGenerator(batchRelation, streamRelation),
    +        outputMode)
    +    } else {
    +      assertNotSupportedForStreaming(
    +        s"$operationName with batch-stream relations",
    +        planGenerator(batchRelation, streamRelation),
    +        outputMode,
    +        expectedMsgs)
    +    }
    +
    +    assertSupportedForStreaming(
    +      s"$operationName with batch-batch relations",
    +      planGenerator(batchRelation, batchRelation),
    +      outputMode)
    +  }
    +
    +  /**
    +   * Assert that the logical plan is supported as subplan insider a streaming plan.
    +   *
    +   * To test this correctly, the given logical plan is wrapped in a fake operator that makes the
    +   * whole plan look like a streaming plan. Otherwise, a batch plan may throw not supported
    +   * exception simply for not being a streaming plan, even though that plan could exists as batch
    +   * subplan inside some streaming plan.
    +   */
    +  def assertSupportedForStreaming(name: String, plan: LogicalPlan, outputMode: OutputMode): Unit = {
    +    test(s"streaming plan - $name: supported") {
    +      UnsupportedOperationChecker.checkForStreaming(wrapInStreaming(plan), outputMode)
    +    }
    +  }
    +
    +  /**
    +   * Assert that the logical plan is not supported inside a streaming plan.
    +   *
    +   * To test this correctly, the given logical plan is wrapped in a fake operator that makes the
    +   * whole plan look like a streaming plan. Otherwise, a batch plan may throw not supported
    +   * exception simply for not being a streaming plan, even though that plan could exists as batch
    +   * subplan inside some streaming plan.
    +   */
    +  def assertNotSupportedForStreaming(
    +      name: String,
    +      plan: LogicalPlan,
    +      outputMode: OutputMode,
    +      expectedMsgs: Seq[String]): Unit = {
    +    testError(
    +      s"streaming plan - $name: not supported",
    +      expectedMsgs :+ "streaming" :+ "DataFrame" :+ "Dataset" :+ "not supported") {
    +      UnsupportedOperationChecker.checkForStreaming(wrapInStreaming(plan), outputMode)
    +    }
    +  }
    +
    +  /** Assert that the logical plan is supported as a batch plan */
    +  def assertSupportedForBatch(name: String, plan: LogicalPlan): Unit = {
    +    test(s"batch plan - $name: supported") {
    +      UnsupportedOperationChecker.checkForBatch(plan)
    +    }
    +  }
    +
    +  /** Assert that the logical plan is not supported as a batch plan */
    +  def assertNotSupportedForBatch(
    +      name: String,
    +      plan: LogicalPlan,
    +      expectedMsgs: Seq[String]): Unit = {
    +    testError(s"batch plan - $name: not supported", expectedMsgs) {
    +      UnsupportedOperationChecker.checkForBatch(plan)
    +    }
    +  }
    +
    +  /**
    +   * Test whether the body of code will fail. If it does fail, then check if it has expected
    +   * messages.
    +   */
    +  def testError(testName: String, expectedMsgs: Seq[String])(testBody: => Unit): Unit = {
    +
    +    val e = intercept[AnalysisException] {
    +      testBody
    +    }
    +
    +    if (!expectedMsgs.map(_.toLowerCase).forall(e.getMessage.toLowerCase.contains)) {
    +      fail(
    +        s"""Exception message should contain the following substrings:
    +          |
    +          |  ${expectedMsgs.mkString("\n  ")}
    +          |
    +          |Actual exception message:
    +          |
    +          |  ${e.getMessage}
    +          """.stripMargin)
    +    }
    +  }
    +
    +  def wrapInStreaming(plan: LogicalPlan): LogicalPlan = {
    +    new StreamingPlanWrapper(plan)
    +  }
    +
    +  class StreamingPlanWrapper(plan: LogicalPlan) extends MapPartitions(
    --- End diff --
    
    Same concern about extending a case class.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [WIP, DO-NOT-MERGE][SPARK-14473][SQL] Define a...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-207137199
  
    **[Test build #55271 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/55271/consoleFull)** for PR 12246 at commit [`de3e298`](https://github.com/apache/spark/commit/de3e29852a1eecd1828abedc128c4e441823fffb).
     * This patch **fails Scala style tests**.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by tdas <gi...@git.apache.org>.
Github user tdas commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12246#discussion_r59933111
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/UnsupportedOperationChecker.scala ---
    @@ -0,0 +1,145 @@
    +/*
    + * 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.spark.sql.catalyst.analysis
    +
    +import org.apache.spark.sql.AnalysisException
    +import org.apache.spark.sql.catalyst.plans._
    +import org.apache.spark.sql.catalyst.plans.logical._
    +
    +/**
    + * Analyzes the presence of unsupported operations in a logical plan.
    + */
    +object UnsupportedOperationChecker {
    +
    +  def checkForBatch(plan: LogicalPlan): Unit = {
    +    plan.foreachUp {
    +      case p if p.isStreaming =>
    +        throwError(
    +          "Queries with streaming sources must be executed with write.startStream()")(p)
    +
    +      case _ =>
    +    }
    +  }
    +
    +  def checkForStreaming(plan: LogicalPlan, outputMode: OutputMode): Unit = {
    +
    +    if (!plan.isStreaming) {
    +      throwError(
    +        "Queries without streaming sources cannot be executed with write.startStream()")(plan)
    +    }
    +
    +    plan.foreachUp { implicit plan =>
    +
    +      // Operations that cannot exists anywhere in a streaming plan
    +      plan match {
    +
    +        case _: Command =>
    +          throwError("Commands like CreateTable*, AlterTable*, Show* are not supported with " +
    +            "streaming DataFrames/Datasets")
    +
    +        case _: InsertIntoTable =>
    +          throwError("InsertIntoTable is not supported with streaming DataFrames/Datasets")
    +
    +        case Aggregate(_, _, child) if child.isStreaming && outputMode == Append =>
    +          throwError(
    +            "Aggregations are not supported on streaming DataFrames/Datasets in " +
    +              "Append output mode. Consider changing output mode to Update.")
    +
    +        case Join(left, right, joinType, _) =>
    +
    +          joinType match {
    +
    +            case Inner =>
    +              if (left.isStreaming && right.isStreaming) {
    +                throwError("Inner join between two streaming DataFrames/Datasets is not supported")
    +              }
    +
    +            case FullOuter =>
    +              if (left.isStreaming || right.isStreaming) {
    +                throwError("Full outer joins with streaming DataFrames/Datasets are not supported")
    +              }
    +
    +
    +            case LeftOuter | LeftSemi | LeftAnti =>
    +              if (right.isStreaming) {
    +                throwError("Left outer/semi/anti joins with a streaming DataFrame/Dataset " +
    +                    "on the right is not supported")
    +              }
    +
    +            case RightOuter =>
    +              if (left.isStreaming) {
    +                throwError("Right outer join with a streaming DataFrame/Dataset on the left is " +
    +                    "not supported")
    +              }
    +
    +            case NaturalJoin(_) | UsingJoin(_, _) =>
    +              // They should not appear in an analyzed plan.
    +
    +            case _ =>
    +              throwError(s"Join type $joinType is not supported with streaming DataFrame/Dataset")
    +          }
    +
    +        case c: CoGroup if plan.children.exists(_.isStreaming) =>
    --- End diff --
    
    I replaced `plan` with `c` to make it less confusing. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [WIP, DO-NOT-MERGE][SPARK-14473][SQL] Define a...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-207136291
  
    **[Test build #55267 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/55267/consoleFull)** for PR 12246 at commit [`87b9782`](https://github.com/apache/spark/commit/87b97828d43a648d10b84fe098cecc1a26cd1817).
     * This patch **fails Scala style tests**.
     * This patch merges cleanly.
     * This patch adds the following public classes _(experimental)_:
      * `trait UnsupportedOperationChecker `
      * `class QueryExecution(val sqlContext: SQLContext, val logical: LogicalPlan)`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [WIP, DO-NOT-MERGE][SPARK-14473][SQL] Define a...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-207195066
  
    Merged build finished. Test FAILed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [WIP, DO-NOT-MERGE][SPARK-14473][SQL] Define a...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-207139835
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/55273/
    Test FAILed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-208752572
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/55590/
    Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by zsxwing <gi...@git.apache.org>.
Github user zsxwing commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12246#discussion_r59935088
  
    --- Diff: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/UnsupportedOperationsSuite.scala ---
    @@ -0,0 +1,378 @@
    +/*
    + * 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.spark.sql.catalyst.analysis
    +
    +import org.apache.spark.SparkFunSuite
    +import org.apache.spark.sql.AnalysisException
    +import org.apache.spark.sql.catalyst.dsl.expressions._
    +import org.apache.spark.sql.catalyst.dsl.plans._
    +import org.apache.spark.sql.catalyst.encoders.ExpressionEncoder
    +import org.apache.spark.sql.catalyst.expressions.{Attribute, AttributeReference}
    +import org.apache.spark.sql.catalyst.plans._
    +import org.apache.spark.sql.catalyst.plans.logical._
    +import org.apache.spark.sql.types.IntegerType
    +
    +class UnsupportedOperationsSuite extends SparkFunSuite {
    +
    +  val attribute = AttributeReference("a", IntegerType, nullable = true)()
    +  val batchRelation = LocalRelation(attribute)
    +  val streamRelation = new TestStreamingRelation(attribute)
    +
    +  /*
    +    =======================================================================================
    +                                     BATCH QUERIES
    +    =======================================================================================
    +   */
    +
    +  assertSupportedForBatch("local relation", batchRelation)
    +
    +  assertNotSupportedForBatch(
    +    "streaming source",
    +    streamRelation,
    +    Seq("with streaming source", "startStream"))
    +
    +  assertNotSupportedForBatch(
    +    "select on streaming source",
    +    streamRelation.select($"count(*)"),
    +    Seq("with streaming source", "startStream"))
    +
    +
    +  /*
    +    =======================================================================================
    +                                     STREAMING QUERIES
    +    =======================================================================================
    +   */
    +
    +  // Batch plan in streaming query
    +  testError("batch source", Seq("without streaming source", "startStream")) {
    +    UnsupportedOperationChecker.checkForStreaming(batchRelation.select($"count(*)"), Append)
    +  }
    +
    +  // Commands
    +  assertNotSupportedForStreaming(
    +    "commmands",
    +    DescribeFunction("func", true),
    +    outputMode = Append,
    +    expectedMsgs = "commands" :: Nil)
    +
    +  // Aggregates: Not supported on streams in Append mode
    +  assertSupportedForStreaming(
    --- End diff --
    
    assertSupportedForBatch?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-210601615
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/55939/
    Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by marmbrus <gi...@git.apache.org>.
Github user marmbrus commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12246#discussion_r59762679
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/LogicalPlan.scala ---
    @@ -42,6 +42,9 @@ abstract class LogicalPlan extends QueryPlan[LogicalPlan] with Logging {
        */
       def analyzed: Boolean = _analyzed
     
    +  /** Whether this logical plan requires incremental execution */
    --- End diff --
    
    Returns true if this subtree contains any streaming data sources.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-210660407
  
    Merged build finished. Test FAILed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [WIP, DO-NOT-MERGE][SPARK-14473][SQL] Define a...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-207678063
  
    **[Test build #55406 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/55406/consoleFull)** for PR 12246 at commit [`bbf9f27`](https://github.com/apache/spark/commit/bbf9f27dbd72de5efef3c22711f7a57cfd04fe17).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-208662560
  
    Merged build finished. Test FAILed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by zsxwing <gi...@git.apache.org>.
Github user zsxwing commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12246#discussion_r59932379
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/UnsupportedOperationChecker.scala ---
    @@ -0,0 +1,145 @@
    +/*
    + * 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.spark.sql.catalyst.analysis
    +
    +import org.apache.spark.sql.AnalysisException
    +import org.apache.spark.sql.catalyst.plans._
    +import org.apache.spark.sql.catalyst.plans.logical._
    +
    +/**
    + * Analyzes the presence of unsupported operations in a logical plan.
    + */
    +object UnsupportedOperationChecker {
    +
    +  def checkForBatch(plan: LogicalPlan): Unit = {
    +    plan.foreachUp {
    +      case p if p.isStreaming =>
    +        throwError(
    +          "Queries with streaming sources must be executed with write.startStream()")(p)
    +
    +      case _ =>
    +    }
    +  }
    +
    +  def checkForStreaming(plan: LogicalPlan, outputMode: OutputMode): Unit = {
    +
    +    if (!plan.isStreaming) {
    +      throwError(
    +        "Queries without streaming sources cannot be executed with write.startStream()")(plan)
    +    }
    +
    +    plan.foreachUp { implicit plan =>
    +
    +      // Operations that cannot exists anywhere in a streaming plan
    +      plan match {
    +
    +        case _: Command =>
    +          throwError("Commands like CreateTable*, AlterTable*, Show* are not supported with " +
    +            "streaming DataFrames/Datasets")
    +
    +        case _: InsertIntoTable =>
    +          throwError("InsertIntoTable is not supported with streaming DataFrames/Datasets")
    +
    +        case Aggregate(_, _, child) if child.isStreaming && outputMode == Append =>
    +          throwError(
    +            "Aggregations are not supported on streaming DataFrames/Datasets in " +
    +              "Append output mode. Consider changing output mode to Update.")
    +
    +        case Join(left, right, joinType, _) =>
    +
    +          joinType match {
    +
    +            case Inner =>
    +              if (left.isStreaming && right.isStreaming) {
    +                throwError("Inner join between two streaming DataFrames/Datasets is not supported")
    +              }
    +
    +            case FullOuter =>
    +              if (left.isStreaming || right.isStreaming) {
    +                throwError("Full outer joins with streaming DataFrames/Datasets are not supported")
    +              }
    +
    +
    +            case LeftOuter | LeftSemi | LeftAnti =>
    +              if (right.isStreaming) {
    +                throwError("Left outer/semi/anti joins with a streaming DataFrame/Dataset " +
    +                    "on the right is not supported")
    +              }
    +
    +            case RightOuter =>
    +              if (left.isStreaming) {
    +                throwError("Right outer join with a streaming DataFrame/Dataset on the left is " +
    +                    "not supported")
    +              }
    +
    +            case NaturalJoin(_) | UsingJoin(_, _) =>
    +              // They should not appear in an analyzed plan.
    +
    +            case _ =>
    +              throwError(s"Join type $joinType is not supported with streaming DataFrame/Dataset")
    +          }
    +
    +        case c: CoGroup if plan.children.exists(_.isStreaming) =>
    +          throwError("CoGrouping between two streaming DataFrames/Datasets is not supported")
    +
    +        case u: Union if u.children.count(_.isStreaming) == 1 =>
    +          throwError("Union between streaming and batch DataFrames/Datasets is not supported")
    +
    +        case Except(left, right) if right.isStreaming =>
    +          throwError("Except with a streaming DataFrame/Dataset on the right is not supported")
    +
    +        case Intersect(left, right) if left.isStreaming && right.isStreaming =>
    +          throwError("Intersect between two streaming DataFrames/Datasets is not supported")
    +
    +        case GroupingSets(_, _, child, _) if child.isStreaming =>
    +          throwError("GroupingSets is not supported on streaming DataFrames/Datasets")
    +
    +        case GlobalLimit(_, _) | LocalLimit(_, _) if plan.children.forall(_.isStreaming) =>
    +          throwError("Limits are not supported on streaming DataFrames/Datasets")
    +
    +        case Sort(_, _, _) | SortPartitions(_, _) if plan.children.forall(_.isStreaming) =>
    --- End diff --
    
    Same as `GlobalLimit(_, _) | LocalLimit(_, _)`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/12246#issuecomment-210600906
  
    **[Test build #55939 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/55939/consoleFull)** for PR 12246 at commit [`a5d180e`](https://github.com/apache/spark/commit/a5d180e8772d203ba9354ab33ec438b545daf329).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14473][SQL] Define analysis rules to ca...

Posted by tdas <gi...@git.apache.org>.
Github user tdas commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12246#discussion_r59935847
  
    --- Diff: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/UnsupportedOperationsSuite.scala ---
    @@ -0,0 +1,378 @@
    +/*
    + * 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.spark.sql.catalyst.analysis
    +
    +import org.apache.spark.SparkFunSuite
    +import org.apache.spark.sql.AnalysisException
    +import org.apache.spark.sql.catalyst.dsl.expressions._
    +import org.apache.spark.sql.catalyst.dsl.plans._
    +import org.apache.spark.sql.catalyst.encoders.ExpressionEncoder
    +import org.apache.spark.sql.catalyst.expressions.{Attribute, AttributeReference}
    +import org.apache.spark.sql.catalyst.plans._
    +import org.apache.spark.sql.catalyst.plans.logical._
    +import org.apache.spark.sql.types.IntegerType
    +
    +class UnsupportedOperationsSuite extends SparkFunSuite {
    +
    +  val attribute = AttributeReference("a", IntegerType, nullable = true)()
    +  val batchRelation = LocalRelation(attribute)
    +  val streamRelation = new TestStreamingRelation(attribute)
    +
    +  /*
    +    =======================================================================================
    +                                     BATCH QUERIES
    +    =======================================================================================
    +   */
    +
    +  assertSupportedForBatch("local relation", batchRelation)
    +
    +  assertNotSupportedForBatch(
    +    "streaming source",
    +    streamRelation,
    +    Seq("with streaming source", "startStream"))
    +
    +  assertNotSupportedForBatch(
    +    "select on streaming source",
    +    streamRelation.select($"count(*)"),
    +    Seq("with streaming source", "startStream"))
    +
    +
    +  /*
    +    =======================================================================================
    +                                     STREAMING QUERIES
    +    =======================================================================================
    +   */
    +
    +  // Batch plan in streaming query
    +  testError("batch source", Seq("without streaming source", "startStream")) {
    +    UnsupportedOperationChecker.checkForStreaming(batchRelation.select($"count(*)"), Append)
    +  }
    +
    +  // Commands
    +  assertNotSupportedForStreaming(
    +    "commmands",
    +    DescribeFunction("func", true),
    +    outputMode = Append,
    +    expectedMsgs = "commands" :: Nil)
    +
    +  // Aggregates: Not supported on streams in Append mode
    +  assertSupportedForStreaming(
    --- End diff --
    
    No no ... its a test aggregate on a batch relation inside a streaming plan.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org