-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-32608][SQL] Script Transform ROW FORMAT DELIMIT value should format value #29428
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 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b929651
[SPARK-32608][SQL] Script Transform ROW FORMAT DELIMIT value should f…
AngersZhuuuu b4d816e
Update SparkSqlParserSuite.scala
AngersZhuuuu 65f69ba
Update BaseScriptTransformationSuite.scala
AngersZhuuuu 0a6c574
Update BaseScriptTransformationSuite.scala
AngersZhuuuu de41b19
make entry as common method
AngersZhuuuu 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,8 +24,8 @@ import org.apache.spark.sql.SaveMode | |
| import org.apache.spark.sql.catalyst.TableIdentifier | ||
| import org.apache.spark.sql.catalyst.analysis.{AnalysisTest, UnresolvedAlias, UnresolvedAttribute, UnresolvedRelation, UnresolvedStar} | ||
| import org.apache.spark.sql.catalyst.catalog.{BucketSpec, CatalogStorageFormat, CatalogTable, CatalogTableType} | ||
| import org.apache.spark.sql.catalyst.expressions.{Ascending, Concat, SortOrder} | ||
| import org.apache.spark.sql.catalyst.plans.logical.{LogicalPlan, Project, RepartitionByExpression, Sort} | ||
| import org.apache.spark.sql.catalyst.expressions.{Ascending, AttributeReference, Concat, SortOrder} | ||
| import org.apache.spark.sql.catalyst.plans.logical._ | ||
| import org.apache.spark.sql.execution.command._ | ||
| import org.apache.spark.sql.execution.datasources.{CreateTable, RefreshResource} | ||
| import org.apache.spark.sql.internal.{HiveSerDe, SQLConf, StaticSQLConf} | ||
|
|
@@ -38,6 +38,7 @@ import org.apache.spark.sql.types.{IntegerType, LongType, StringType, StructType | |
| * defined in the Catalyst module. | ||
| */ | ||
| class SparkSqlParserSuite extends AnalysisTest { | ||
| import org.apache.spark.sql.catalyst.dsl.expressions._ | ||
|
|
||
| val newConf = new SQLConf | ||
| private lazy val parser = new SparkSqlParser(newConf) | ||
|
|
@@ -330,4 +331,44 @@ class SparkSqlParserSuite extends AnalysisTest { | |
| assertEqual("ADD FILE /path with space/abc.txt", AddFileCommand("/path with space/abc.txt")) | ||
| assertEqual("ADD JAR /path with space/abc.jar", AddJarCommand("/path with space/abc.jar")) | ||
| } | ||
|
|
||
| test("SPARK-32608: script transform with row format delimit") { | ||
| assertEqual( | ||
|
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. Could you add end-2-end tests, too?
Contributor
Author
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.
Added in |
||
| """ | ||
| |SELECT TRANSFORM(a, b, c) | ||
| | ROW FORMAT DELIMITED | ||
| | FIELDS TERMINATED BY ',' | ||
| | COLLECTION ITEMS TERMINATED BY '#' | ||
| | MAP KEYS TERMINATED BY '@' | ||
| | LINES TERMINATED BY '\n' | ||
| | NULL DEFINED AS 'null' | ||
| | USING 'cat' AS (a, b, c) | ||
| | ROW FORMAT DELIMITED | ||
| | FIELDS TERMINATED BY ',' | ||
| | COLLECTION ITEMS TERMINATED BY '#' | ||
| | MAP KEYS TERMINATED BY '@' | ||
| | LINES TERMINATED BY '\n' | ||
| | NULL DEFINED AS 'NULL' | ||
| |FROM testData | ||
| """.stripMargin, | ||
| ScriptTransformation( | ||
| Seq('a, 'b, 'c), | ||
| "cat", | ||
| Seq(AttributeReference("a", StringType)(), | ||
| AttributeReference("b", StringType)(), | ||
| AttributeReference("c", StringType)()), | ||
| UnresolvedRelation(TableIdentifier("testData")), | ||
| ScriptInputOutputSchema( | ||
| Seq(("TOK_TABLEROWFORMATFIELD", ","), | ||
| ("TOK_TABLEROWFORMATCOLLITEMS", "#"), | ||
| ("TOK_TABLEROWFORMATMAPKEYS", "@"), | ||
| ("TOK_TABLEROWFORMATLINES", "\n"), | ||
| ("TOK_TABLEROWFORMATNULL", "null")), | ||
| Seq(("TOK_TABLEROWFORMATFIELD", ","), | ||
| ("TOK_TABLEROWFORMATCOLLITEMS", "#"), | ||
| ("TOK_TABLEROWFORMATMAPKEYS", "@"), | ||
| ("TOK_TABLEROWFORMATLINES", "\n"), | ||
| ("TOK_TABLEROWFORMATNULL", "NULL")), None, None, | ||
| List.empty, List.empty, None, None, false))) | ||
| } | ||
| } | ||
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.
Why did you put this import here instead of the top?
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.
Copy from
PlanParserSuite.....Should I move this line to top in
PlanParserSuitein pr #29414There 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.
Ur, I see. Its okay as it is.