-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-20213][SQL] Fix DataFrameWriter operations in SQL UI tab #18064
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b355c6d
Fix DataFrameWriter operations in SQL UI tab
cloud-fan c76c30c
fix test
cloud-fan 984bab7
fix kafka
cloud-fan ea06a0c
address comments
cloud-fan 513bb9b
fix streaming
cloud-fan bc7608a
one more fix
cloud-fan f479221
last fix
cloud-fan f49a0b3
more improvement
cloud-fan 6c7d259
Merge remote-tracking branch 'origin/master' into execution
cloud-fan baef6ec
Merge remote-tracking branch 'origin/master' into execution
cloud-fan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -179,9 +179,9 @@ class Dataset[T] private[sql]( | |
| // to happen right away to let these side effects take place eagerly. | ||
| queryExecution.analyzed match { | ||
| case c: Command => | ||
| LocalRelation(c.output, queryExecution.executedPlan.executeCollect()) | ||
| LocalRelation(c.output, withAction("command", queryExecution)(_.executeCollect())) | ||
| case u @ Union(children) if children.forall(_.isInstanceOf[Command]) => | ||
| LocalRelation(u.output, queryExecution.executedPlan.executeCollect()) | ||
| LocalRelation(u.output, withAction("command", queryExecution)(_.executeCollect())) | ||
| case _ => | ||
| queryExecution.analyzed | ||
| } | ||
|
|
@@ -242,9 +242,12 @@ class Dataset[T] private[sql]( | |
| * @param vertical If set to true, prints output rows vertically (one line per column value). | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems to add a |
||
| */ | ||
| private[sql] def showString( | ||
| _numRows: Int, truncate: Int = 20, vertical: Boolean = false): String = { | ||
| _numRows: Int, | ||
| truncate: Int = 20, | ||
| vertical: Boolean = false, | ||
| isInternal: Boolean = false): String = { | ||
| val numRows = _numRows.max(0) | ||
| val takeResult = toDF().take(numRows + 1) | ||
| val takeResult = if (isInternal) toDF().takeInternal(numRows + 1) else toDF().take(numRows + 1) | ||
| val hasMoreData = takeResult.length > numRows | ||
| val data = takeResult.take(numRows) | ||
|
|
||
|
|
@@ -683,6 +686,15 @@ class Dataset[T] private[sql]( | |
| } | ||
| // scalastyle:on println | ||
|
|
||
| // scalastyle:off println | ||
| // An internal version of `show`, which won't set execution id and trigger listeners. | ||
| private[sql] def showInternal(numRows: Int, truncate: Boolean): Unit = if (truncate) { | ||
| println(showString(numRows, truncate = 20, isInternal = true)) | ||
| } else { | ||
| println(showString(numRows, truncate = 0, isInternal = true)) | ||
| } | ||
| // scalastyle:on println | ||
|
|
||
| /** | ||
| * Displays the Dataset in a tabular form. For example: | ||
| * {{{ | ||
|
|
@@ -2450,6 +2462,11 @@ class Dataset[T] private[sql]( | |
| */ | ||
| def take(n: Int): Array[T] = head(n) | ||
|
|
||
| // An internal version of `take`, which won't set execution id and trigger listeners. | ||
| private[sql] def takeInternal(n: Int): Array[T] = { | ||
| collectFromPlan(limit(n).queryExecution.executedPlan) | ||
| } | ||
|
|
||
| /** | ||
| * Returns the first `n` rows in the Dataset as a list. | ||
| * | ||
|
|
@@ -2474,6 +2491,11 @@ class Dataset[T] private[sql]( | |
| */ | ||
| def collect(): Array[T] = withAction("collect", queryExecution)(collectFromPlan) | ||
|
|
||
| // An internal version of `collect`, which won't set execution id and trigger listeners. | ||
| private[sql] def collectInternal(): Array[T] = { | ||
| collectFromPlan(queryExecution.executedPlan) | ||
| } | ||
|
|
||
| /** | ||
| * Returns a Java list that contains all rows in this Dataset. | ||
| * | ||
|
|
@@ -2515,6 +2537,11 @@ class Dataset[T] private[sql]( | |
| plan.executeCollect().head.getLong(0) | ||
| } | ||
|
|
||
| // An internal version of `count`, which won't set execution id and trigger listeners. | ||
| private[sql] def countInternal(): Long = { | ||
| groupBy().count().queryExecution.executedPlan.executeCollect().head.getLong(0) | ||
| } | ||
|
|
||
| /** | ||
| * Returns a new Dataset that has exactly `numPartitions` partitions. | ||
| * | ||
|
|
@@ -2744,7 +2771,7 @@ class Dataset[T] private[sql]( | |
| createTempViewCommand(viewName, replace = false, global = true) | ||
| } | ||
|
|
||
| private def createTempViewCommand( | ||
| private[sql] def createTempViewCommand( | ||
| viewName: String, | ||
| replace: Boolean, | ||
| global: Boolean): CreateViewCommand = { | ||
|
|
@@ -2937,17 +2964,17 @@ class Dataset[T] private[sql]( | |
| } | ||
|
|
||
| /** A convenient function to wrap a logical plan and produce a DataFrame. */ | ||
| @inline private def withPlan(logicalPlan: => LogicalPlan): DataFrame = { | ||
| @inline private def withPlan(logicalPlan: LogicalPlan): DataFrame = { | ||
| Dataset.ofRows(sparkSession, logicalPlan) | ||
| } | ||
|
|
||
| /** A convenient function to wrap a logical plan and produce a Dataset. */ | ||
| @inline private def withTypedPlan[U : Encoder](logicalPlan: => LogicalPlan): Dataset[U] = { | ||
| @inline private def withTypedPlan[U : Encoder](logicalPlan: LogicalPlan): Dataset[U] = { | ||
| Dataset(sparkSession, logicalPlan) | ||
| } | ||
|
|
||
| /** A convenient function to wrap a set based logical plan and produce a Dataset. */ | ||
| @inline private def withSetOperator[U : Encoder](logicalPlan: => LogicalPlan): Dataset[U] = { | ||
| @inline private def withSetOperator[U : Encoder](logicalPlan: LogicalPlan): Dataset[U] = { | ||
| if (classTag.runtimeClass.isAssignableFrom(classOf[Row])) { | ||
| // Set operators widen types (change the schema), so we cannot reuse the row encoder. | ||
| Dataset.ofRows(sparkSession, logicalPlan).asInstanceOf[Dataset[U]] | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After removing this, can
KafkaSinkstill track its streaming writing?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea, because it's used in
KafkaProviderwhich is run withSaveIntoDataSourceCommand, and all commands will be wrapped bySQLExecution.withNewExecutionIdThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you mean
KafkaSourceProvider, is it the same code path asKafkaSink? InKafkaSink.addBath,KafkaWriter.writeis also called to write into Kafka.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
KafkaSink.addBathis also wrapped withSQLExecution.withNewExecutionIdinStreamExecution: https://github.com/apache/spark/pull/18064/files#diff-6532dd3b63bdab0364fbcf2303e290e4R658