Description
When we create an Enum
type in SQL, the DDL starts assigning the enumeration values with numbers starting from 0
which could have unexpected side-effects considering how proto3 attributes special semantics to the enumeration value with number 0
.
Enum Default Value
The default value for the SearchRequest.corpus field is CORPUS_UNSPECIFIED because that is the first value defined in the enum.
In proto3, the first value defined in an enum definition must have the value zero and should have the name ENUM_TYPE_NAME_UNSPECIFIED or ENUM_TYPE_NAME_UNKNOWN. This is because:
There must be a zero value, so that we can use 0 as a numeric default value.
The zero value needs to be the first element, for compatibility with the proto2 semantics where the first enum value is the default unless a different value is explicitly specified.
It is also recommended that this first, default value have no semantic meaning other than “this value was unspecified”.