viirya commented on code in PR #60411:
URL: https://github.com/apache/spark/pull/60411#discussion_r4559269916


##########
sql/core/src/test/scala/org/apache/spark/sql/execution/joins/SortMergeAsOfJoinScannerSuite.scala:
##########
@@ -41,6 +42,29 @@ class SortMergeAsOfJoinScannerSuite extends SparkFunSuite 
with LocalSparkContext
   private val factoryModes =
     Seq(CodegenObjectFactoryMode.CODEGEN_ONLY, 
CodegenObjectFactoryMode.NO_CODEGEN)
 
+  test("only backward and forward joins have a scan strategy") {
+    assert(AsOfScanStrategy.of(Backward).contains(AsOfScanStrategy.LastMatch))
+    assert(AsOfScanStrategy.of(Forward).contains(AsOfScanStrategy.FirstMatch))
+    assert(AsOfScanStrategy.of(Nearest).isEmpty)
+    assert(AsOfScanStrategy(Backward) == AsOfScanStrategy.LastMatch)
+    assert(AsOfScanStrategy(Forward) == AsOfScanStrategy.FirstMatch)
+    checkError(
+      exception = intercept[SparkException](AsOfScanStrategy(Nearest)),
+      condition = "INTERNAL_ERROR",
+      parameters = Map("message" -> "The Nearest AS-OF join has no ordered 
scan"))
+  }
+
+  test("nearest join has no cursor scan") {
+    val leftKey = AttributeReference("leftKey", IntegerType)()
+    val rightKey = AttributeReference("rightKey", IntegerType)()
+    // A scanner built by hand must fail, not run the cursor of another 
direction.
+    val error = intercept[SparkException] {
+      runScan(Seq(5), Seq(1, 9), leftKey, rightKey, Literal.TrueLiteral, 
Nearest,
+        useCursorScan = true)
+    }
+    assert(error.getMessage.contains("The Nearest AS-OF join has no ordered 
scan"))

Review Comment:
   Done, it checks the cause with `checkError`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to