Skip to content

Commit

Permalink
[SPARK-34402][SQL] Group exception about data format schema
Browse files Browse the repository at this point in the history
### What changes were proposed in this pull request?
Group exception about data format schema of different format, orc/parquet

### Why are the changes needed?
group exception

### Does this PR introduce _any_ user-facing change?
No

### How was this patch tested?
Not need

Closes #33296 from AngersZhuuuu/SPARK-34402.

Authored-by: Angerszhuuuu <angers.zhu@gmail.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
  • Loading branch information
AngersZhuuuu authored and cloud-fan committed Jul 26, 2021
1 parent e5616e3 commit a63802f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
Expand Up @@ -586,11 +586,9 @@ private[sql] object ParquetSchemaConverter {

def checkFieldName(name: String): Unit = {
// ,;{}()\n\t= and space are special characters in Parquet schema
checkConversionRequirement(
!name.matches(".*[ ,;{}()\n\t=].*"),
s"""Attribute name "$name" contains invalid character(s) among " ,;{}()\\n\\t=".
|Please use alias to rename it.
""".stripMargin.split("\n").mkString(" ").trim)
if (name.matches(".*[ ,;{}()\n\t=].*")) {
throw QueryCompilationErrors.columnNameContainsInvalidCharactersError(name)
}
}

def checkFieldNames(schema: StructType): Unit = {
Expand Down
Expand Up @@ -3002,8 +3002,8 @@ class HiveDDLSuite
spark.sql(s"INSERT OVERWRITE LOCAL DIRECTORY '${path.getCanonicalPath}' " +
s"STORED AS PARQUET SELECT ID, if(1=1, 1, 0), abs(id), '^-' FROM v")
}.getMessage
assert(e.contains("Attribute name \"(IF((1 = 1), 1, 0))\" contains" +
" invalid character(s) among \" ,;{}()\\n\\t=\". Please use alias to rename it."))
assert(e.contains("Column name \"(IF((1 = 1), 1, 0))\" contains invalid character(s). " +
"Please use alias to rename it."))
}
}
}
Expand All @@ -3022,8 +3022,8 @@ class HiveDDLSuite
|FROM v
""".stripMargin)
}.getMessage
assert(e.contains("Attribute name \"IF(ID=1,ID,0)\" contains" +
" invalid character(s) among \" ,;{}()\\n\\t=\". Please use alias to rename it."))
assert(e.contains("Column name \"IF(ID=1,ID,0)\" contains" +
" invalid character(s). Please use alias to rename it."))
}
}
}
Expand Down

0 comments on commit a63802f

Please sign in to comment.