Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
Renames analysisRequire to checkConversionRequirement
  • Loading branch information
liancheng committed Aug 2, 2015
commit 6bda94ba32ebb61d089c5392f1afdbf5613b8549
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private[parquet] class ParquetSchemaConverter(
val precision = field.getDecimalMetadata.getPrecision
val scale = field.getDecimalMetadata.getScale

ParquetSchemaConverter.analysisRequire(
ParquetSchemaConverter.checkConversionRequirement(
maxPrecision == -1 || 1 <= precision && precision <= maxPrecision,
s"Invalid decimal precision: $typeName cannot store $precision digits (max $maxPrecision)")

Expand Down Expand Up @@ -168,7 +168,7 @@ private[parquet] class ParquetSchemaConverter(
}

case INT96 =>
ParquetSchemaConverter.analysisRequire(
ParquetSchemaConverter.checkConversionRequirement(
assumeInt96IsTimestamp,
"INT96 is not supported unless it's interpreted as timestamp. " +
s"Please try to set ${SQLConf.PARQUET_INT96_AS_TIMESTAMP.key} to true.")
Expand Down Expand Up @@ -210,11 +210,11 @@ private[parquet] class ParquetSchemaConverter(
//
// See: https://github.com/apache/parquet-format/blob/master/LogicalTypes.md#lists
case LIST =>
ParquetSchemaConverter.analysisRequire(
ParquetSchemaConverter.checkConversionRequirement(
field.getFieldCount == 1, s"Invalid list type $field")

val repeatedType = field.getType(0)
ParquetSchemaConverter.analysisRequire(
ParquetSchemaConverter.checkConversionRequirement(
repeatedType.isRepetition(REPEATED), s"Invalid list type $field")

if (isElementType(repeatedType, field.getName)) {
Expand All @@ -230,17 +230,17 @@ private[parquet] class ParquetSchemaConverter(
// See: https://github.com/apache/parquet-format/blob/master/LogicalTypes.md#backward-compatibility-rules-1
// scalastyle:on
case MAP | MAP_KEY_VALUE =>
ParquetSchemaConverter.analysisRequire(
ParquetSchemaConverter.checkConversionRequirement(
field.getFieldCount == 1 && !field.getType(0).isPrimitive,
s"Invalid map type: $field")

val keyValueType = field.getType(0).asGroupType()
ParquetSchemaConverter.analysisRequire(
ParquetSchemaConverter.checkConversionRequirement(
keyValueType.isRepetition(REPEATED) && keyValueType.getFieldCount == 2,
s"Invalid map type: $field")

val keyType = keyValueType.getType(0)
ParquetSchemaConverter.analysisRequire(
ParquetSchemaConverter.checkConversionRequirement(
keyType.isPrimitive,
s"Map key type is expected to be a primitive type, but found: $keyType")

Expand Down Expand Up @@ -546,7 +546,7 @@ private[parquet] object ParquetSchemaConverter {

def checkFieldName(name: String): Unit = {
// ,;{}()\n\t= and space are special characters in Parquet schema
analysisRequire(
checkConversionRequirement(
!name.matches(".*[ ,;{}()\n\t=].*"),
s"""Attribute name "$name" contains invalid character(s) among " ,;{}()\\n\\t=".
|Please use alias to rename it.
Expand All @@ -558,7 +558,7 @@ private[parquet] object ParquetSchemaConverter {
schema
}

def analysisRequire(f: => Boolean, message: String): Unit = {
def checkConversionRequirement(f: => Boolean, message: String): Unit = {
if (!f) {
throw new AnalysisException(message)
}
Expand Down