kori73 commented on code in PR #40991:
URL: https://github.com/apache/spark/pull/40991#discussion_r1181071857


##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/rules/RuleIdCollectionSuite.scala:
##########
@@ -0,0 +1,34 @@
+/*
+ * 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.rules
+
+import org.apache.spark.{SparkException, SparkFunSuite}
+
+class RuleIdCollectionSuite extends SparkFunSuite {
+
+    test("SPARK-42330: rule id not found") {
+        checkError(
+            exception = intercept[SparkException] {
+                RuleIdCollection.getRuleId("incorrect")

Review Comment:
   As far as I can understand this error is thrown when someone adds a `Rule` 
to apache spark source code and uses a method that requires `ruleId` such as 
follows:
   
   
[Analyzer.scala#L379](https://github.com/apache/spark/blob/master/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala#L379-L380)
   
   ```
     object ResolveBinaryArithmetic extends Rule[LogicalPlan] {
       override def apply(plan: LogicalPlan): LogicalPlan = 
plan.resolveOperatorsUpWithPruning(
         _.containsPattern(BINARY_ARITHMETIC), ruleId) { ... }
   ```
   
   Then the developer will need to add this rule to 
`RuleIdCollection.rulesNeedingIds`.
   
   
[RuleIdCollection.scala](https://github.com/apache/spark/blob/master/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/rules/RuleIdCollection.scala).
   
   However, I can't see any way that a user can add an element to 
`RuleIdCollection.rulesNeedingIds`.
   
   I might try to extend the Catalyst by injecting a rule which uses a method 
requiring `ruleId`. But the user will not be able to fix the error as described 
in the error message:
   
   `Rule id not found for <ruleName>. Please modify RuleIdCollection.scala if 
you are adding a new rule.`
   
   So, I think this error class/message is intended for spark developers 
although I might be completely wrong.
   
   Also pinging the author @sigmod 
   



-- 
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