-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[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
Changes from all commits
b929651
b4d816e
65f69ba
0a6c574
de41b19
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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._ | ||
|
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. Why did you put this import here instead of the top?
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.
Copy from
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. Ur, I see. Its okay as it is. |
||
|
|
||
| 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))) | ||
| } | ||
| } | ||
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.
Ah, I see. This update looks okay.