Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
com.cloudera.impala.util.AvroSchemaParser Class Reference
Collaboration diagram for com.cloudera.impala.util.AvroSchemaParser:

Static Public Member Functions

static List< Columnparse (String schemaStr) throws SchemaParseException
 

Static Package Functions

 [static initializer]
 

Static Private Member Functions

static Type getTypeInfo (Schema schema, String colName)
 
static boolean isNullableType (Schema schema)
 
static Schema getColumnType (Schema schema)
 
static Type getDecimalType (Schema schema)
 
static Integer getDecimalProp (Schema schema, String propName) throws SchemaParseException
 

Static Private Attributes

static final Map< Schema.Type,
Type
avroToImpalaPrimitiveTypeMap_
 

Detailed Description

Utility class used to parse Avro schema. Checks that the schema is valid and performs mapping of Avro types to Impala types. Note: This code is loosely based off the parsing code in the Hive AvroSerDe.

Definition at line 44 of file AvroSchemaParser.java.

Member Function Documentation

com.cloudera.impala.util.AvroSchemaParser.[static initializer] ( )
inlinestaticpackage
static Schema com.cloudera.impala.util.AvroSchemaParser.getColumnType ( Schema  schema)
inlinestaticprivate

If a nullable type, get the schema for the non-nullable type which will provide Impala column type information.

Definition at line 129 of file AvroSchemaParser.java.

Referenced by com.cloudera.impala.util.AvroSchemaParser.getTypeInfo().

static Integer com.cloudera.impala.util.AvroSchemaParser.getDecimalProp ( Schema  schema,
String  propName 
) throws SchemaParseException
inlinestaticprivate

Parses a decimal property and returns the value as an integer, or null if the property isn't set. Used to parse decimal scale/precision. Throws a SchemaParseException if the property doesn't parse to a natural number.

Definition at line 169 of file AvroSchemaParser.java.

Referenced by com.cloudera.impala.util.AvroSchemaParser.getDecimalType().

static Type com.cloudera.impala.util.AvroSchemaParser.getDecimalType ( Schema  schema)
inlinestaticprivate

Attempts to parse decimal type information from the Avro schema, returning a decimal ColumnType if successful or null if this schema does not map to a decimal type. Decimal is defined in Avro as a BYTE type with the logicalType property set to "decimal" and a specified scale/precision. Throws a SchemaParseException if the logicType=decimal, but scale/precision is not specified or in the incorrect format.

Definition at line 143 of file AvroSchemaParser.java.

References com.cloudera.impala.util.AvroSchemaParser.getDecimalProp().

Referenced by com.cloudera.impala.util.AvroSchemaParser.getTypeInfo().

static Type com.cloudera.impala.util.AvroSchemaParser.getTypeInfo ( Schema  schema,
String  colName 
)
inlinestaticprivate
static boolean com.cloudera.impala.util.AvroSchemaParser.isNullableType ( Schema  schema)
inlinestaticprivate

Returns true if this is a nullable type (a Union[T, Null]), false otherwise.

Definition at line 118 of file AvroSchemaParser.java.

Referenced by com.cloudera.impala.util.AvroSchemaParser.getTypeInfo().

static List<Column> com.cloudera.impala.util.AvroSchemaParser.parse ( String  schemaStr) throws SchemaParseException
inlinestatic

Parses the Avro schema string literal, mapping the Avro types to Impala types. Returns a list of Column objects with their name and type info set. Throws an UnsupportedOperationException if the Avro type maps to a type Impala does not yet support. Throws a SchemaParseException if the Avro schema was invalid.

Definition at line 65 of file AvroSchemaParser.java.

References com.cloudera.impala.util.AvroSchemaParser.getTypeInfo().

Member Data Documentation

final Map<Schema.Type, Type> com.cloudera.impala.util.AvroSchemaParser.avroToImpalaPrimitiveTypeMap_
staticprivate

The documentation for this class was generated from the following file: