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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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

Reply via email to