15 package com.cloudera.impala.analysis;
19 import org.apache.hadoop.hive.metastore.MetaStoreUtils;
29 import com.google.common.base.Preconditions;
30 import com.google.common.collect.Sets;
51 if (type.isScalarType()) {
53 }
else if (type.isStructType()) {
55 }
else if (type.isArrayType()) {
59 Preconditions.checkState(type.isMapType());
79 Preconditions.checkState(
false);
82 int len = scalarType.getLength();
86 if (scalarType.getLength() > maxLen) {
88 name +
" size must be <= " + maxLen +
": " + len);
93 int precision = scalarType.decimalPrecision();
94 int scale = scalarType.decimalScale();
102 if (scale > precision) {
104 "precision (" + precision +
")");
114 Set<String> fieldNames = Sets.newHashSet();
116 analyze(f.getType(), analyzer);
117 if (!fieldNames.add(f.getName().toLowerCase())) {
119 String.format(
"Duplicate field name '%s' in struct '%s'",
120 f.getName(),
toSql()));
123 if (!MetaStoreUtils.validateName(f.getName().toLowerCase())) {
131 analyze(mapType.getKeyType(), analyzer);
132 if (mapType.getKeyType().isComplexType()) {
134 "Map type cannot have a complex-typed key: " + mapType.toSql());
136 analyze(mapType.getValueType(), analyzer);
142 public String
toString() {
return parsedType_.toSql(); }
145 public String
toSql() {
return parsedType_.toSql(); }
static final int MAX_PRECISION
void analyzeStructType(StructType structType, Analyzer analyzer)
void analyze(Type type, Analyzer analyzer)
static final int MAX_VARCHAR_LENGTH
void analyzeScalarType(ScalarType scalarType, Analyzer analyzer)
static final int MAX_CHAR_LENGTH
void analyze(Analyzer analyzer)
void analyzeMapType(MapType mapType, Analyzer analyzer)