<s> from decimal import Decimal <EOL> from agate . aggregations . base import Aggregation <EOL> from agate . data_types import Number , Text <EOL> from agate . exceptions import DataTypeError <EOL> class MaxLength ( Aggregation ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , column_name ) : <EOL> self . _column_name = column_name <EOL> def get_aggregate_data_type ( self , table ) : <EOL> return Number ( ) <EOL> def validate ( self , table ) : <EOL> column = table . columns [ self . _column_name ] <EOL> if not isinstance ( column . data_type , Text ) : <EOL> raise DataTypeError ( '<STR_LIT>' ) <EOL> def run ( self , table ) : <EOL> """<STR_LIT>""" <EOL> column = table . columns [ self . _column_name ] <EOL> return Decimal ( max ( [ len ( d ) for d in column . values_without_nulls ( ) ] ) ) </s>
