You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "itholic (via GitHub)" <gi...@apache.org> on 2024/04/04 07:31:23 UTC

[PR] [SPARK-47586][SQL] Hive module: Migrate logError with variables to structured logging framework [spark]

itholic opened a new pull request, #45876:
URL: https://github.com/apache/spark/pull/45876

   ### What changes were proposed in this pull request?
   
   This PR proposes to migrate `logError` with variables of Hive module to structured logging framework.
   
   
   ### Why are the changes needed?
   
   To improve the existing logging system by migrating into structured logging.
   
   
   ### Does this PR introduce _any_ user-facing change?
   
   No API changes, but the SQL catalyst logs will contain MDC(Mapped Diagnostic Context) from now.
   
   
   ### How was this patch tested?
   
   Run Scala auto formatting and style check. Also the existing CI should pass.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   No.
   
   


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-47586][SQL] Hive module: Migrate logError with variables to structured logging framework [spark]

Posted by "itholic (via GitHub)" <gi...@apache.org>.
itholic commented on PR #45876:
URL: https://github.com/apache/spark/pull/45876#issuecomment-2041778287

   @panbingkun sure! Thanks for the notice :-)


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-47586][SQL] Hive module: Migrate logError with variables to structured logging framework [spark]

Posted by "gengliangwang (via GitHub)" <gi...@apache.org>.
gengliangwang commented on code in PR #45876:
URL: https://github.com/apache/spark/pull/45876#discussion_r1556958805


##########
common/utils/src/main/scala/org/apache/spark/internal/LogKey.scala:
##########
@@ -40,7 +40,9 @@ object LogKey extends Enumeration {
   val CONFIG2 = Value
   val CONTAINER_ID = Value
   val COUNT = Value
+  val DB_NAME = Value

Review Comment:
   let's make it DATABASE_NAME 



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-47586][SQL] Hive module: Migrate logError with variables to structured logging framework [spark]

Posted by "itholic (via GitHub)" <gi...@apache.org>.
itholic commented on code in PR #45876:
URL: https://github.com/apache/spark/pull/45876#discussion_r1554809227


##########
common/utils/src/main/scala/org/apache/spark/internal/LogKey.scala:
##########
@@ -112,6 +113,7 @@ object LogKey extends Enumeration {
   val URI = Value
   val USER_ID = Value
   val USER_NAME = Value
+  val VERSION = Value

Review Comment:
   Thanks for the suggestion! Using `PYTHON_VERSION` sounds good to me for clarity.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-47586][SQL] Hive module: Migrate logError with variables to structured logging framework [spark]

Posted by "itholic (via GitHub)" <gi...@apache.org>.
itholic commented on code in PR #45876:
URL: https://github.com/apache/spark/pull/45876#discussion_r1554809227


##########
common/utils/src/main/scala/org/apache/spark/internal/LogKey.scala:
##########
@@ -112,6 +113,7 @@ object LogKey extends Enumeration {
   val URI = Value
   val USER_ID = Value
   val USER_NAME = Value
+  val VERSION = Value

Review Comment:
   Thanks for the suggestion! Using `PYTHON_VERSION` sounds good to me this case for clarity.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-47586][SQL] Hive module: Migrate logError with variables to structured logging framework [spark]

Posted by "panbingkun (via GitHub)" <gi...@apache.org>.
panbingkun commented on code in PR #45876:
URL: https://github.com/apache/spark/pull/45876#discussion_r1558957480


##########
sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveClientImpl.scala:
##########
@@ -686,17 +687,19 @@ private[hive] class HiveClientImpl(
       } catch {
         case e: Exception =>
           val remainingParts = matchingParts.toBuffer --= droppedParts
+          // scalastyle:off line.size.limit
           logError(
             s"""
                |======================
-               |Attempt to drop the partition specs in table '$table' database '$db':
+               |Attempt to drop the partition specs in table '${MDC(TABLE_NAME, table)}' database '${MDC(DB_NAME, db)}':
                |${specs.mkString("\n")}
                |In this attempt, the following partitions have been dropped successfully:
                |${droppedParts.mkString("\n")}
                |The remaining partitions have not been dropped:
                |${remainingParts.mkString("\n")}

Review Comment:
   yeah
   sorry for late comment reply



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-47586][SQL] Hive module: Migrate logError with variables to structured logging framework [spark]

Posted by "gengliangwang (via GitHub)" <gi...@apache.org>.
gengliangwang closed pull request #45876: [SPARK-47586][SQL] Hive module: Migrate logError with variables to structured logging framework
URL: https://github.com/apache/spark/pull/45876


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-47586][SQL] Hive module: Migrate logError with variables to structured logging framework [spark]

Posted by "gengliangwang (via GitHub)" <gi...@apache.org>.
gengliangwang commented on PR #45876:
URL: https://github.com/apache/spark/pull/45876#issuecomment-2046286778

   Thanks, merging to master


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-47586][SQL] Hive module: Migrate logError with variables to structured logging framework [spark]

Posted by "panbingkun (via GitHub)" <gi...@apache.org>.
panbingkun commented on PR #45876:
URL: https://github.com/apache/spark/pull/45876#issuecomment-2041711117

   @itholic Can you retrigger the workflow again?
   I believe it can turn green this time, haha


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-47586][SQL] Hive module: Migrate logError with variables to structured logging framework [spark]

Posted by "panbingkun (via GitHub)" <gi...@apache.org>.
panbingkun commented on code in PR #45876:
URL: https://github.com/apache/spark/pull/45876#discussion_r1552635940


##########
sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveExternalCatalogVersionsSuite.scala:
##########
@@ -200,7 +202,8 @@ class HiveExternalCatalogVersionsSuite extends SparkSubmitTestUtils {
           logInfo("Skip tests because old Spark versions don't support Java 21.")
         }
       } else {
-        logError(s"Python version <  ${TestUtils.minimumPythonSupportedVersion}, " +
+        logError(
+          log"Python version <  ${MDC(VERSION, TestUtils.minimumPythonSupportedVersion)}, " +

Review Comment:
   ```suggestion
             log"Python version < ${MDC(VERSION, TestUtils.minimumPythonSupportedVersion)}, " +
   ```



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-47586][SQL] Hive module: Migrate logError with variables to structured logging framework [spark]

Posted by "itholic (via GitHub)" <gi...@apache.org>.
itholic commented on code in PR #45876:
URL: https://github.com/apache/spark/pull/45876#discussion_r1556625020


##########
sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveExternalCatalogVersionsSuite.scala:
##########
@@ -200,8 +202,9 @@ class HiveExternalCatalogVersionsSuite extends SparkSubmitTestUtils {
           logInfo("Skip tests because old Spark versions don't support Java 21.")
         }
       } else {
-        logError(s"Python version <  ${TestUtils.minimumPythonSupportedVersion}, " +
-          "the running environment is unavailable.")
+        logError(

Review Comment:
   Oh, I see.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-47586][SQL] Hive module: Migrate logError with variables to structured logging framework [spark]

Posted by "itholic (via GitHub)" <gi...@apache.org>.
itholic commented on PR #45876:
URL: https://github.com/apache/spark/pull/45876#issuecomment-2046329098

   Thanks @gengliangwang @panbingkun @pan3793 for the review :-)


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-47586][SQL] Hive module: Migrate logError with variables to structured logging framework [spark]

Posted by "gengliangwang (via GitHub)" <gi...@apache.org>.
gengliangwang commented on PR #45876:
URL: https://github.com/apache/spark/pull/45876#issuecomment-2044206013

   LGTM except one comment


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-47586][SQL] Hive module: Migrate logError with variables to structured logging framework [spark]

Posted by "itholic (via GitHub)" <gi...@apache.org>.
itholic commented on code in PR #45876:
URL: https://github.com/apache/spark/pull/45876#discussion_r1556661227


##########
sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveClientImpl.scala:
##########
@@ -686,17 +687,19 @@ private[hive] class HiveClientImpl(
       } catch {
         case e: Exception =>
           val remainingParts = matchingParts.toBuffer --= droppedParts
+          // scalastyle:off line.size.limit
           logError(
             s"""
                |======================
-               |Attempt to drop the partition specs in table '$table' database '$db':
+               |Attempt to drop the partition specs in table '${MDC(TABLE_NAME, table)}' database '${MDC(DB_NAME, db)}':
                |${specs.mkString("\n")}
                |In this attempt, the following partitions have been dropped successfully:
                |${droppedParts.mkString("\n")}
                |The remaining partitions have not been dropped:
                |${remainingParts.mkString("\n")}

Review Comment:
   Hi, @panbingkun I wonder if you could advise me how can we handle those variables which are made via `mkString`.
   
   They would contains multiple items split by `"\n"`, but can we still just make them as a `LogKey`??



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-47586][SQL] Hive module: Migrate logError with variables to structured logging framework [spark]

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #45876:
URL: https://github.com/apache/spark/pull/45876#discussion_r1554808552


##########
common/utils/src/main/scala/org/apache/spark/internal/LogKey.scala:
##########
@@ -112,6 +113,7 @@ object LogKey extends Enumeration {
   val URI = Value
   val USER_ID = Value
   val USER_NAME = Value
+  val VERSION = Value

Review Comment:
   should it be PYTHON_VERSION, SPARK_VERSION, HIVE_VERSION, JAVA_VERSION etc. ?



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-47586][SQL] Hive module: Migrate logError with variables to structured logging framework [spark]

Posted by "panbingkun (via GitHub)" <gi...@apache.org>.
panbingkun commented on code in PR #45876:
URL: https://github.com/apache/spark/pull/45876#discussion_r1552636077


##########
sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveExternalCatalogVersionsSuite.scala:
##########
@@ -31,6 +31,8 @@ import org.scalatest.time.SpanSugar._
 
 import org.apache.spark.{SparkConf, TestUtils}
 import org.apache.spark.deploy.SparkSubmitTestUtils
+import org.apache.spark.internal.LogKey._

Review Comment:
   ```suggestion
   import org.apache.spark.internal.LogKey.VERSION
   ```



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-47586][SQL] Hive module: Migrate logError with variables to structured logging framework [spark]

Posted by "itholic (via GitHub)" <gi...@apache.org>.
itholic commented on code in PR #45876:
URL: https://github.com/apache/spark/pull/45876#discussion_r1554808391


##########
sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveExternalCatalogVersionsSuite.scala:
##########
@@ -200,7 +202,8 @@ class HiveExternalCatalogVersionsSuite extends SparkSubmitTestUtils {
           logInfo("Skip tests because old Spark versions don't support Java 21.")
         }
       } else {
-        logError(s"Python version <  ${TestUtils.minimumPythonSupportedVersion}, " +
+        logError(
+          log"Python version < ${MDC(VERSION, TestUtils.minimumPythonSupportedVersion)}, " +
           "the running environment is unavailable.")

Review Comment:
   Oh, thanks for the correction!



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-47586][SQL] Hive module: Migrate logError with variables to structured logging framework [spark]

Posted by "gengliangwang (via GitHub)" <gi...@apache.org>.
gengliangwang commented on code in PR #45876:
URL: https://github.com/apache/spark/pull/45876#discussion_r1552175720


##########
sql/hive/src/main/scala/org/apache/spark/sql/hive/TableReader.scala:
##########
@@ -518,7 +519,9 @@ private[hive] object HadoopTableReader extends HiveInspectors with Logging {
           i += 1
         } catch {
           case ex: Throwable =>
-            logError(s"Exception thrown in field <${fieldRefs(i).getFieldName}>")
+            logError(
+              log"Exception thrown in field <${MDC(FIELD_NAME, fieldRefs(i).getFieldName)}>"

Review Comment:
   nit: let's log the exception as well.
   logError(log"...", ex)



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-47586][SQL] Hive module: Migrate logError with variables to structured logging framework [spark]

Posted by "panbingkun (via GitHub)" <gi...@apache.org>.
panbingkun commented on code in PR #45876:
URL: https://github.com/apache/spark/pull/45876#discussion_r1558957480


##########
sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveClientImpl.scala:
##########
@@ -686,17 +687,19 @@ private[hive] class HiveClientImpl(
       } catch {
         case e: Exception =>
           val remainingParts = matchingParts.toBuffer --= droppedParts
+          // scalastyle:off line.size.limit
           logError(
             s"""
                |======================
-               |Attempt to drop the partition specs in table '$table' database '$db':
+               |Attempt to drop the partition specs in table '${MDC(TABLE_NAME, table)}' database '${MDC(DB_NAME, db)}':
                |${specs.mkString("\n")}
                |In this attempt, the following partitions have been dropped successfully:
                |${droppedParts.mkString("\n")}
                |The remaining partitions have not been dropped:
                |${remainingParts.mkString("\n")}

Review Comment:
   yeah



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-47586][SQL] Hive module: Migrate logError with variables to structured logging framework [spark]

Posted by "itholic (via GitHub)" <gi...@apache.org>.
itholic commented on code in PR #45876:
URL: https://github.com/apache/spark/pull/45876#discussion_r1559174377


##########
sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveClientImpl.scala:
##########
@@ -686,17 +687,19 @@ private[hive] class HiveClientImpl(
       } catch {
         case e: Exception =>
           val remainingParts = matchingParts.toBuffer --= droppedParts
+          // scalastyle:off line.size.limit
           logError(
             s"""
                |======================
-               |Attempt to drop the partition specs in table '$table' database '$db':
+               |Attempt to drop the partition specs in table '${MDC(TABLE_NAME, table)}' database '${MDC(DB_NAME, db)}':
                |${specs.mkString("\n")}
                |In this attempt, the following partitions have been dropped successfully:
                |${droppedParts.mkString("\n")}
                |The remaining partitions have not been dropped:
                |${remainingParts.mkString("\n")}

Review Comment:
   No problem. Thanks for your all reviews!



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-47586][SQL] Hive module: Migrate logError with variables to structured logging framework [spark]

Posted by "itholic (via GitHub)" <gi...@apache.org>.
itholic commented on PR #45876:
URL: https://github.com/apache/spark/pull/45876#issuecomment-2036400940

   cc @gengliangwang @panbingkun @pan3793 🙏 


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-47586][SQL] Hive module: Migrate logError with variables to structured logging framework [spark]

Posted by "gengliangwang (via GitHub)" <gi...@apache.org>.
gengliangwang commented on PR #45876:
URL: https://github.com/apache/spark/pull/45876#issuecomment-2043432284

   @itholic we need more migrations:
   ```
   $ grep -r logError\( *|grep -v test
   src/main/scala/org/apache/spark/sql/hive/TableReader.scala:            logError(s"Exception thrown in field <${fieldRefs(i).getFieldName}>")
   src/main/scala/org/apache/spark/sql/hive/client/HiveClientImpl.scala:          logError(
   src/main/scala/org/apache/spark/sql/hive/client/HiveClientImpl.scala:        logError(
   ```


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-47586][SQL] Hive module: Migrate logError with variables to structured logging framework [spark]

Posted by "panbingkun (via GitHub)" <gi...@apache.org>.
panbingkun commented on code in PR #45876:
URL: https://github.com/apache/spark/pull/45876#discussion_r1553455082


##########
sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveExternalCatalogVersionsSuite.scala:
##########
@@ -200,7 +202,8 @@ class HiveExternalCatalogVersionsSuite extends SparkSubmitTestUtils {
           logInfo("Skip tests because old Spark versions don't support Java 21.")
         }
       } else {
-        logError(s"Python version <  ${TestUtils.minimumPythonSupportedVersion}, " +
+        logError(
+          log"Python version < ${MDC(VERSION, TestUtils.minimumPythonSupportedVersion)}, " +
           "the running environment is unavailable.")

Review Comment:
   @itholic I guess you need to write it this way because `MDC` + `String` is not currently supported, 😄
   "the running environment is unavailable." -> log"the running environment is unavailable."



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-47586][SQL] Hive module: Migrate logError with variables to structured logging framework [spark]

Posted by "itholic (via GitHub)" <gi...@apache.org>.
itholic commented on code in PR #45876:
URL: https://github.com/apache/spark/pull/45876#discussion_r1556686231


##########
sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveClientImpl.scala:
##########
@@ -686,17 +687,19 @@ private[hive] class HiveClientImpl(
       } catch {
         case e: Exception =>
           val remainingParts = matchingParts.toBuffer --= droppedParts
+          // scalastyle:off line.size.limit
           logError(
             s"""
                |======================
-               |Attempt to drop the partition specs in table '$table' database '$db':
+               |Attempt to drop the partition specs in table '${MDC(TABLE_NAME, table)}' database '${MDC(DB_NAME, db)}':
                |${specs.mkString("\n")}
                |In this attempt, the following partitions have been dropped successfully:
                |${droppedParts.mkString("\n")}
                |The remaining partitions have not been dropped:
                |${remainingParts.mkString("\n")}

Review Comment:
   Oh, nvm. I found some examples. I think we can just make them as an `LogKey`.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-47586][SQL] Hive module: Migrate logError with variables to structured logging framework [spark]

Posted by "itholic (via GitHub)" <gi...@apache.org>.
itholic commented on code in PR #45876:
URL: https://github.com/apache/spark/pull/45876#discussion_r1556970668


##########
common/utils/src/main/scala/org/apache/spark/internal/LogKey.scala:
##########
@@ -40,7 +40,9 @@ object LogKey extends Enumeration {
   val CONFIG2 = Value
   val CONTAINER_ID = Value
   val COUNT = Value
+  val DB_NAME = Value

Review Comment:
   Adjusted. Thanks!



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-47586][SQL] Hive module: Migrate logError with variables to structured logging framework [spark]

Posted by "itholic (via GitHub)" <gi...@apache.org>.
itholic commented on PR #45876:
URL: https://github.com/apache/spark/pull/45876#issuecomment-2039225481

   Hm, I'm not sure why CI is complaining about the negative Scala style result since it is passed form my local envs. Let me just try re-triggering the CI.


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-47586][SQL] Hive module: Migrate logError with variables to structured logging framework [spark]

Posted by "itholic (via GitHub)" <gi...@apache.org>.
itholic commented on PR #45876:
URL: https://github.com/apache/spark/pull/45876#issuecomment-2038997555

   Thanks @gengliangwang and @panbingkun for the review! Just address the comments.


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-47586][SQL] Hive module: Migrate logError with variables to structured logging framework [spark]

Posted by "itholic (via GitHub)" <gi...@apache.org>.
itholic commented on PR #45876:
URL: https://github.com/apache/spark/pull/45876#issuecomment-2043911366

   > @itholic we need more migrations:
   
   I belive `src/main/scala/org/apache/spark/sql/hive/TableReader.scala` is already addressed.
   Just migrated `src/main/scala/org/apache/spark/sql/hive/client/HiveClientImpl.scala`. Thanks!


-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-47586][SQL] Hive module: Migrate logError with variables to structured logging framework [spark]

Posted by "itholic (via GitHub)" <gi...@apache.org>.
itholic commented on code in PR #45876:
URL: https://github.com/apache/spark/pull/45876#discussion_r1556661227


##########
sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveClientImpl.scala:
##########
@@ -686,17 +687,19 @@ private[hive] class HiveClientImpl(
       } catch {
         case e: Exception =>
           val remainingParts = matchingParts.toBuffer --= droppedParts
+          // scalastyle:off line.size.limit
           logError(
             s"""
                |======================
-               |Attempt to drop the partition specs in table '$table' database '$db':
+               |Attempt to drop the partition specs in table '${MDC(TABLE_NAME, table)}' database '${MDC(DB_NAME, db)}':
                |${specs.mkString("\n")}
                |In this attempt, the following partitions have been dropped successfully:
                |${droppedParts.mkString("\n")}
                |The remaining partitions have not been dropped:
                |${remainingParts.mkString("\n")}

Review Comment:
   Hi, @panbingkun I wonder if you could advise me how can we handle those variables which are made via `mkString`.
   
   They would contains multiple items split by `"\n"`, but can we still just consider them as a `LogKey`??



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-47586][SQL] Hive module: Migrate logError with variables to structured logging framework [spark]

Posted by "gengliangwang (via GitHub)" <gi...@apache.org>.
gengliangwang commented on code in PR #45876:
URL: https://github.com/apache/spark/pull/45876#discussion_r1556267923


##########
sql/hive/src/test/scala/org/apache/spark/sql/hive/HiveExternalCatalogVersionsSuite.scala:
##########
@@ -200,8 +202,9 @@ class HiveExternalCatalogVersionsSuite extends SparkSubmitTestUtils {
           logInfo("Skip tests because old Spark versions don't support Java 21.")
         }
       } else {
-        logError(s"Python version <  ${TestUtils.minimumPythonSupportedVersion}, " +
-          "the running environment is unavailable.")
+        logError(

Review Comment:
   We don't need to migrate the test changes.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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