Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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 @@ -183,9 +183,9 @@ object CharVarcharUtils extends Logging {

private def raiseError(expr: Expression, typeName: String, length: Int): Expression = {
val errorMsg = Concat(Seq(
Literal("input string '"),
expr,
Literal(s"' exceeds $typeName type length limitation: $length")))
Literal("input string of length "),
Cast(Length(expr), StringType),
Literal(s" exceeds $typeName type length limitation: $length")))
Cast(RaiseError(errorMsg), StringType)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ trait CharVarcharTestSuite extends QueryTest with SQLTestUtils {
checkAnswer(spark.table("t"), Row(null))
val e = intercept[SparkException](sql("INSERT INTO t VALUES ('123456')"))
assert(e.getCause.getMessage.contains(
s"input string '123456' exceeds $typeName type length limitation: 5"))
s"input string of length 6 exceeds $typeName type length limitation: 5"))
}
}

Expand All @@ -203,7 +203,7 @@ trait CharVarcharTestSuite extends QueryTest with SQLTestUtils {
checkAnswer(spark.table("t"), Row(1, null))
val e = intercept[SparkException](sql("INSERT INTO t VALUES (1, '123456')"))
assert(e.getCause.getMessage.contains(
s"input string '123456' exceeds $typeName type length limitation: 5"))
s"input string of length 6 exceeds $typeName type length limitation: 5"))
}
}
}
Expand All @@ -215,7 +215,7 @@ trait CharVarcharTestSuite extends QueryTest with SQLTestUtils {
checkAnswer(spark.table("t"), Row(Row(null)))
val e = intercept[SparkException](sql("INSERT INTO t SELECT struct('123456')"))
assert(e.getCause.getMessage.contains(
s"input string '123456' exceeds $typeName type length limitation: 5"))
s"input string of length 6 exceeds $typeName type length limitation: 5"))
}
}

Expand All @@ -226,7 +226,7 @@ trait CharVarcharTestSuite extends QueryTest with SQLTestUtils {
checkAnswer(spark.table("t"), Row(Seq(null)))
val e = intercept[SparkException](sql("INSERT INTO t VALUES (array('a', '123456'))"))
assert(e.getCause.getMessage.contains(
s"input string '123456' exceeds $typeName type length limitation: 5"))
s"input string of length 6 exceeds $typeName type length limitation: 5"))
}
}

Expand All @@ -235,7 +235,7 @@ trait CharVarcharTestSuite extends QueryTest with SQLTestUtils {
sql(s"CREATE TABLE t(c MAP<$typeName(5), STRING>) USING $format")
val e = intercept[SparkException](sql("INSERT INTO t VALUES (map('123456', 'a'))"))
assert(e.getCause.getMessage.contains(
s"input string '123456' exceeds $typeName type length limitation: 5"))
s"input string of length 6 exceeds $typeName type length limitation: 5"))
}
}

Expand All @@ -246,7 +246,7 @@ trait CharVarcharTestSuite extends QueryTest with SQLTestUtils {
checkAnswer(spark.table("t"), Row(Map("a" -> null)))
val e = intercept[SparkException](sql("INSERT INTO t VALUES (map('a', '123456'))"))
assert(e.getCause.getMessage.contains(
s"input string '123456' exceeds $typeName type length limitation: 5"))
s"input string of length 6 exceeds $typeName type length limitation: 5"))
}
}

Expand All @@ -255,10 +255,10 @@ trait CharVarcharTestSuite extends QueryTest with SQLTestUtils {
sql(s"CREATE TABLE t(c MAP<$typeName(5), $typeName(5)>) USING $format")
val e1 = intercept[SparkException](sql("INSERT INTO t VALUES (map('123456', 'a'))"))
assert(e1.getCause.getMessage.contains(
s"input string '123456' exceeds $typeName type length limitation: 5"))
s"input string of length 6 exceeds $typeName type length limitation: 5"))
val e2 = intercept[SparkException](sql("INSERT INTO t VALUES (map('a', '123456'))"))
assert(e2.getCause.getMessage.contains(
s"input string '123456' exceeds $typeName type length limitation: 5"))
s"input string of length 6 exceeds $typeName type length limitation: 5"))
}
}

Expand All @@ -269,7 +269,7 @@ trait CharVarcharTestSuite extends QueryTest with SQLTestUtils {
checkAnswer(spark.table("t"), Row(Row(Seq(null))))
val e = intercept[SparkException](sql("INSERT INTO t SELECT struct(array('123456'))"))
assert(e.getCause.getMessage.contains(
s"input string '123456' exceeds $typeName type length limitation: 5"))
s"input string of length 6 exceeds $typeName type length limitation: 5"))
}
}

Expand All @@ -280,7 +280,7 @@ trait CharVarcharTestSuite extends QueryTest with SQLTestUtils {
checkAnswer(spark.table("t"), Row(Seq(Row(null))))
val e = intercept[SparkException](sql("INSERT INTO t VALUES (array(struct('123456')))"))
assert(e.getCause.getMessage.contains(
s"input string '123456' exceeds $typeName type length limitation: 5"))
s"input string of length 6 exceeds $typeName type length limitation: 5"))
}
}

Expand All @@ -291,7 +291,7 @@ trait CharVarcharTestSuite extends QueryTest with SQLTestUtils {
checkAnswer(spark.table("t"), Row(Seq(Seq(null))))
val e = intercept[SparkException](sql("INSERT INTO t VALUES (array(array('123456')))"))
assert(e.getCause.getMessage.contains(
s"input string '123456' exceeds $typeName type length limitation: 5"))
s"input string of length 6 exceeds $typeName type length limitation: 5"))
}
}

Expand All @@ -313,10 +313,10 @@ trait CharVarcharTestSuite extends QueryTest with SQLTestUtils {
checkAnswer(spark.table("t"), Row("1234 ", "1234"))
val e1 = intercept[SparkException](sql("INSERT INTO t VALUES (123456, 1)"))
assert(e1.getCause.getMessage.contains(
"input string '123456' exceeds char type length limitation: 5"))
"input string of length 6 exceeds char type length limitation: 5"))
val e2 = intercept[SparkException](sql("INSERT INTO t VALUES (1, 123456)"))
assert(e2.getCause.getMessage.contains(
"input string '123456' exceeds varchar type length limitation: 5"))
"input string of length 6 exceeds varchar type length limitation: 5"))
}
}

Expand Down