def handle_single_value( value: Optional[FilterValue]) -> Optional[FilterValue]: if (isinstance(value, (float, int)) and target_generic_type == utils.GenericDataType.TEMPORAL and target_native_type is not None and db_engine_spec is not None): value = db_engine_spec.convert_dttm( target_type=target_native_type, dttm=datetime.utcfromtimestamp(value / 1000), db_extra=db_extra, ) value = literal_column(value) if isinstance(value, str): value = value.strip("\t\n") if target_generic_type == utils.GenericDataType.NUMERIC: # For backwards compatibility and edge cases # where a column data type might have changed return utils.cast_to_num(value) if value == NULL_STRING: return None if value == EMPTY_STRING: return "" if target_generic_type == utils.GenericDataType.BOOLEAN: return utils.cast_to_boolean(value) return value
def handle_single_value( value: Optional[FilterValue]) -> Optional[FilterValue]: # backward compatibility with previous <select> components if (isinstance(value, (float, int)) and target_column_type == utils.GenericDataType.TEMPORAL): return datetime.utcfromtimestamp(value / 1000) if isinstance(value, str): value = value.strip("\t\n") if target_column_type == utils.GenericDataType.NUMERIC: # For backwards compatibility and edge cases # where a column data type might have changed return utils.cast_to_num(value) if value == NULL_STRING: return None if value == EMPTY_STRING: return "" if target_column_type == utils.GenericDataType.BOOLEAN: return utils.cast_to_boolean(value) return value