cloud-fan commented on a change in pull request #27199: [SPARK-30508][SQL] Add 
DataFrameReader.executeCommand API for external datasource
URL: https://github.com/apache/spark/pull/27199#discussion_r366328908
 
 

 ##########
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/command/commands.scala
 ##########
 @@ -183,3 +184,21 @@ case class StreamingExplainCommand(
     ("Error occurred during query planning: \n" + 
cause.getMessage).split("\n").map(Row(_))
   }
 }
+
+/**
+ * Used to execute users' DDL/DML command inside an external execution engine 
rather than Spark.
+ * Please check [[ExternalCommandRunnableProvider]] for details.
+ */
+case class ExternalCommandExecutor(
+    command: String,
+    parameters: Map[String, String],
+    provider: ExternalCommandRunnableProvider) extends RunnableCommand {
+
+  override def output: Seq[Attribute] =
+    Seq(AttributeReference("command_output", StringType)())
+
+  override def run(sparkSession: SparkSession): Seq[Row] = {
+    val output = provider.executeCommand(command, parameters)
+    Seq(Row(output.mkString("\n")))
 
 Review comment:
   we can output each string as one row: `output.map(Row(_))`

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

Reply via email to