@@ -392,7 +392,18 @@ def _read_items(
392392 items = _read_batch_items (table_name , dynamodb_client , chunked , ** kwargs )
393393
394394 else :
395- if limit :
395+ if limit is not None :
396+ if limit < 0 :
397+ raise exceptions .InvalidArgumentValue ("`max_items_evaluated` must be greater than or equal to 0." )
398+ if limit == 0 :
399+ empty_items : _ItemsListType = []
400+ if chunked :
401+ return _convert_items_chunked (
402+ items_iterator = iter ([empty_items ]),
403+ as_dataframe = as_dataframe ,
404+ arrow_kwargs = arrow_kwargs ,
405+ )
406+ return _convert_items (items = empty_items , as_dataframe = as_dataframe , arrow_kwargs = arrow_kwargs )
396407 kwargs ["Limit" ] = limit
397408 _logger .debug ("`max_items_evaluated` argument detected, setting use_threads to False" )
398409 use_threads = False
@@ -744,12 +755,20 @@ def read_items( # noqa: PLR0912, PLR0915
744755 ** kwargs .get ("ExpressionAttributeValues" , {}),
745756 ** _serialize_item (expression_attribute_values , serializer ),
746757 }
747- if max_items_evaluated :
758+ if max_items_evaluated is not None :
748759 kwargs ["Limit" ] = max_items_evaluated
749760
750761 _logger .debug ("DynamoDB scan/query kwargs: %s" , kwargs )
751762 # If kwargs are sufficiently informative, proceed with actual read op
752- if any ((partition_values , key_condition_expression , filter_expression , allow_full_scan , max_items_evaluated )):
763+ if any (
764+ (
765+ partition_values ,
766+ key_condition_expression ,
767+ filter_expression ,
768+ allow_full_scan ,
769+ max_items_evaluated is not None ,
770+ )
771+ ):
753772 return _read_items (
754773 table_name = table_name ,
755774 as_dataframe = as_dataframe ,
0 commit comments