Hi,

I'm trying to create a table with a NOT NULL column:  CREATE TABLE mytable
(int_required BIGINT NOT NULL, ....)

However, it looks like the schema that AvroSerde generates ignores the "NOT
NULL" part and outputs the following avro field schema:
{"name":"int_required","type":["null","long"],"default":null}

Looking at AvroSerde's codebase, it seems that it infers the avro schema
based on the "column.types" table property:
https://github.com/apache/hive/blob/release-3.1.2-rc0/serde/src/java/org/apache/hadoop/hive/serde2/avro/AvroSerDe.java#L118

However, it looks like the "column.types" table property contains no
indication of whether the column might be "NOT NULL". The property just
contains "bigint" for the column. So the AvroSerde assumes that all columns
must accept null values.

This means that the AvroSerde's inferred schema for that field is a
UNION["null", "long"] instead of just LONG.

Is that the intended behavior, or am I missing something?

Thanks,

Julien

Reply via email to