WweiL commented on code in PR #41026:
URL: https://github.com/apache/spark/pull/41026#discussion_r1195753208


##########
sql/core/src/main/scala/org/apache/spark/sql/streaming/DataStreamWriter.scala:
##########
@@ -354,7 +355,8 @@ final class DataStreamWriter[T] private[sql](ds: 
Dataset[T]) {
       query
     } else if (source == SOURCE_NAME_FOREACH) {
       assertNotPartitioned(SOURCE_NAME_FOREACH)
-      val sink = ForeachWriterTable[T](foreachWriter, ds.exprEnc)
+      val sink = ForeachWriterTable[Any](foreachWriter,
+        ds.exprEnc.asInstanceOf[ExpressionEncoder[Any]])

Review Comment:
   I tried making 
   ` private var foreachWriter: ForeachWriter[_] = null`
   
   Then here if I do
   ```
   val sink = ForeachWriterTable[_](foreachWriter, ds.exprEnc)
   ```
   I get:
   ```
   [error] 
/home/wei.liu/oss-spark/sql/core/src/main/scala/org/apache/spark/sql/streaming/DataStreamWriter.scala:358:37:
 unbound wildcard type
   [error]       val sink = ForeachWriterTable[_](foreachWriter, ds.exprEnc)
   [error]                                     ^
   [error] one error found
   ```
   
   If I do 
   ```
   val sink = ForeachWriterTable[Any](foreachWriter, ds.exprEnc)
   ```
   I get:
   ```
   [error] 
/home/wei.liu/oss-spark/sql/core/src/main/scala/org/apache/spark/sql/streaming/DataStreamWriter.scala:358:36:
 overloaded method value apply with alternatives:
   [error]   (writer: org.apache.spark.sql.ForeachWriter[Any],converter: 
Either[org.apache.spark.sql.catalyst.encoders.ExpressionEncoder[Any],org.apache.spark.sql.catalyst.InternalRow
 => 
Any])org.apache.spark.sql.execution.streaming.sources.ForeachWriterTable[Any] 
<and>
   [error]   (writer: org.apache.spark.sql.ForeachWriter[Any],encoder: 
org.apache.spark.sql.catalyst.encoders.ExpressionEncoder[Any])org.apache.spark.sql.execution.streaming.sources.ForeachWriterTable[_]
   [error]  cannot be applied to (org.apache.spark.sql.ForeachWriter[_$2], 
org.apache.spark.sql.catalyst.encoders.ExpressionEncoder[T])
   [error]       val sink = ForeachWriterTable[Any](foreachWriter, ds.exprEnc)
   [error]                                    ^
   [error] one error found
   ```



-- 
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-unsubscr...@spark.apache.org

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


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

Reply via email to