[GitHub] [spark] gatorsmile commented on a change in pull request #24800: [SPARK-27947][SQL] ParsedStatement subclass toString may throw ClassCastException
gatorsmile commented on a change in pull request #24800: [SPARK-27947][SQL] ParsedStatement subclass toString may throw ClassCastException URL: https://github.com/apache/spark/pull/24800#discussion_r291457845 ## File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/sql/ParsedStatement.scala ## @@ -36,8 +38,11 @@ import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan private[sql] abstract class ParsedStatement extends LogicalPlan { // Redact properties and options when parsed nodes are used by generic methods like toString override def productIterator: Iterator[Any] = super.productIterator.map { -case mapArg: Map[_, _] => conf.redactOptions(mapArg.asInstanceOf[Map[String, String]]) -case other => other +case mapArg: Map[_, _] => + // May match any Map type, e.g. Map[String, Int], due to type erasure + Try(conf.redactOptions(mapArg.asInstanceOf[Map[String, String]])).getOrElse(mapArg) Review comment: In Spark source code, we always try to avoid rely on the exception handling if we can possibly avoid it. Also, we try our best to avoid make an assumption in the utility class. I think we can enhance these Utils redact methods in this PR. 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] [spark] gatorsmile commented on a change in pull request #24800: [SPARK-27947][SQL] ParsedStatement subclass toString may throw ClassCastException
gatorsmile commented on a change in pull request #24800: [SPARK-27947][SQL] ParsedStatement subclass toString may throw ClassCastException URL: https://github.com/apache/spark/pull/24800#discussion_r291457845 ## File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/sql/ParsedStatement.scala ## @@ -36,8 +38,11 @@ import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan private[sql] abstract class ParsedStatement extends LogicalPlan { // Redact properties and options when parsed nodes are used by generic methods like toString override def productIterator: Iterator[Any] = super.productIterator.map { -case mapArg: Map[_, _] => conf.redactOptions(mapArg.asInstanceOf[Map[String, String]]) -case other => other +case mapArg: Map[_, _] => + // May match any Map type, e.g. Map[String, Int], due to type erasure + Try(conf.redactOptions(mapArg.asInstanceOf[Map[String, String]])).getOrElse(mapArg) Review comment: In Spark source code, we always try to avoid rely on the exception handling if we can possibly avoid it. Also, we try our best to avoid making a hidden assumption in the utility class. I think we can enhance these Utils redact methods in this PR. 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] [spark] gatorsmile commented on a change in pull request #24800: [SPARK-27947][SQL] ParsedStatement subclass toString may throw ClassCastException
gatorsmile commented on a change in pull request #24800: [SPARK-27947][SQL] ParsedStatement subclass toString may throw ClassCastException URL: https://github.com/apache/spark/pull/24800#discussion_r290594606 ## File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/sql/ParsedStatement.scala ## @@ -36,8 +38,11 @@ import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan private[sql] abstract class ParsedStatement extends LogicalPlan { // Redact properties and options when parsed nodes are used by generic methods like toString override def productIterator: Iterator[Any] = super.productIterator.map { -case mapArg: Map[_, _] => conf.redactOptions(mapArg.asInstanceOf[Map[String, String]]) -case other => other +case mapArg: Map[_, _] => + // May match any Map type, e.g. Map[String, Int], due to type erasure + Try(conf.redactOptions(mapArg.asInstanceOf[Map[String, String]])).getOrElse(mapArg) Review comment: ParsedStatement is an abstract class, we might not be able to know how it will be used in the future. We should try our best to avoid adding any assumption here. Could you try it? I think it is not a hard problem. 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] [spark] gatorsmile commented on a change in pull request #24800: [SPARK-27947][SQL] ParsedStatement subclass toString may throw ClassCastException
gatorsmile commented on a change in pull request #24800: [SPARK-27947][SQL] ParsedStatement subclass toString may throw ClassCastException URL: https://github.com/apache/spark/pull/24800#discussion_r290585629 ## File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/sql/ParsedStatement.scala ## @@ -36,8 +38,11 @@ import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan private[sql] abstract class ParsedStatement extends LogicalPlan { // Redact properties and options when parsed nodes are used by generic methods like toString override def productIterator: Iterator[Any] = super.productIterator.map { -case mapArg: Map[_, _] => conf.redactOptions(mapArg.asInstanceOf[Map[String, String]]) -case other => other +case mapArg: Map[_, _] => + // May match any Map type, e.g. Map[String, Int], due to type erasure + Try(conf.redactOptions(mapArg.asInstanceOf[Map[String, String]])).getOrElse(mapArg) Review comment: but, my question is should we still redact the string key when the value is not string, or redact the string value when the key is not string? 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] [spark] gatorsmile commented on a change in pull request #24800: [SPARK-27947][SQL] ParsedStatement subclass toString may throw ClassCastException
gatorsmile commented on a change in pull request #24800: [SPARK-27947][SQL] ParsedStatement subclass toString may throw ClassCastException URL: https://github.com/apache/spark/pull/24800#discussion_r290585465 ## File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/sql/ParsedStatement.scala ## @@ -36,8 +38,11 @@ import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan private[sql] abstract class ParsedStatement extends LogicalPlan { // Redact properties and options when parsed nodes are used by generic methods like toString override def productIterator: Iterator[Any] = super.productIterator.map { -case mapArg: Map[_, _] => conf.redactOptions(mapArg.asInstanceOf[Map[String, String]]) -case other => other +case mapArg: Map[_, _] => + // May match any Map type, e.g. Map[String, Int], due to type erasure + Try(conf.redactOptions(mapArg.asInstanceOf[Map[String, String]])).getOrElse(mapArg) Review comment: Is this what you want? ``` case mapArg: Map[String, String] => conf.redactOptions(mapArg) case other => other ``` 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org