Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,12 @@ class SparkSqlAstBuilder extends AstBuilder {
} else {
None
}
(Seq.empty, Option(name), props.toSeq, recordHandler)
val finalProps = if (!props.contains("field.delim")) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this case sensitive?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this case sensitive?

Yes, case sensitive
image

props.toSeq ++ Seq("field.delim" -> "\t")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the behavior now? which delimiter do we use by default before this PR?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the behavior now? which delimiter do we use by default before this PR?

No default we use '\u0001'

} else {
props.toSeq
}
(Seq.empty, Option(name), finalProps, recordHandler)

case null =>
// Use default (serde) format.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import org.apache.hadoop.hive.serde2.`lazy`.LazySimpleSerDe
import org.scalatest.exceptions.TestFailedException

import org.apache.spark.{SparkException, TestUtils}
import org.apache.spark.sql.Row
import org.apache.spark.sql.catalyst.expressions.{Attribute, AttributeReference, Expression}
import org.apache.spark.sql.execution._
import org.apache.spark.sql.functions._
Expand Down Expand Up @@ -438,4 +439,66 @@ class HiveScriptTransformationSuite extends BaseScriptTransformationSuite with T
assert(e2.contains("array<double> cannot be converted to Hive TypeInfo"))
}
}

test("SPARK-32685: When use specified serde, filed.delim's default value is '\t'") {
val query1 = sql(
"""
|SELECT split(value, "\t") FROM (
|SELECT TRANSFORM(a, b, c)
|USING 'cat'
|FROM (SELECT 1 AS a, 2 AS b, 3 AS c) t
|) temp;
""".stripMargin)
checkAnswer(query1, identity, Row(Seq("2", "3")) :: Nil)

val query2 = sql(
"""
|SELECT split(value, "\t") FROM (
|SELECT TRANSFORM(a, b, c)
| ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
|USING 'cat'
| ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
| WITH SERDEPROPERTIES (
| 'serialization.last.column.takes.rest' = 'true'
| )
|FROM (SELECT 1 AS a, 2 AS b, 3 AS c) t
|) temp;
""".stripMargin)
checkAnswer(query2, identity, Row(Seq("2", "3")) :: Nil)

val query3 = sql(
"""
|SELECT split(value, "&") FROM (
|SELECT TRANSFORM(a, b, c)
| ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
| WITH SERDEPROPERTIES (
| 'field.delim' = '&'
| )
|USING 'cat'
| ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
| WITH SERDEPROPERTIES (
| 'serialization.last.column.takes.rest' = 'true',
| 'field.delim' = '&'
| )
|FROM (SELECT 1 AS a, 2 AS b, 3 AS c) t
|) temp;
""".stripMargin)
checkAnswer(query3, identity, Row(Seq("2", "3")) :: Nil)

val query4 = sql(
"""
|SELECT split(value, "&") FROM (
|SELECT TRANSFORM(a, b, c)
| ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
|USING 'cat'
| ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
| WITH SERDEPROPERTIES (
| 'serialization.last.column.takes.rest' = 'true',
| 'field.delim' = '&'
| )
|FROM (SELECT 1 AS a, 2 AS b, 3 AS c) t
|) temp;
""".stripMargin)
checkAnswer(query4, identity, Row(null) :: Nil)
}
}