what data type should be used in Google big query for a column that only accept few values?

Viewed 452

I want to have a column in a table in google big query that only accept 3 values. the values are 'r', 'g', 'b'. what is the best data type in this case? I can use "string" but I thought it is mostly used for variable length data types.

1 Answers

Google cloud documentation recommends STRING as the compatible data type for ENUM fields that you might be generating/importing from other systems. Refer to this BQ documentation.

For restricting the column to a set of values, I would recommend doing it upstream. For example, when you write to your relational data sources(MYSQL etc) you can add that validation, if that isn't an option your import pipeline should explicitly handle this prior to loading onto BQ

Related