def test_get_column_type_contains_set(self): field_type = "set_yolo" data_type = get_column_type(self.glue_source, field_type, "a_table", "a_field") self.assertEqual( data_type.to_obj(), SchemaFieldDataType(type=ArrayTypeClass()).to_obj() )
def test_get_column_type_contains_set(): field_type = "set_yolo" data_type = get_column_type(glue_source(), field_type, "a_table", "a_field") assert data_type.to_obj() == SchemaFieldDataType( type=ArrayTypeClass()).to_obj()
def _get_column_type(descriptor: DescriptorBase) -> SchemaFieldDataType: native_type: str = _get_simple_native_type(descriptor) type_class: Any if getattr(descriptor, "label", None) == FieldDescriptor.LABEL_REPEATED: type_class = ArrayTypeClass(nestedType=[native_type]) elif getattr(descriptor, "type", None) == FieldDescriptor.TYPE_ENUM: type_class = EnumTypeClass() # # TODO: Find a better way to detect maps # # elif simple_type == "map": # type_class = MapTypeClass( # keyType=descriptor.key_type, # valueType=descriptor.val_type, # ) else: type_class = _native_type_to_typeclass.get(native_type, RecordTypeClass)() return SchemaFieldDataType(type=type_class)