@@ -54,6 +54,7 @@ def ingest(
5454 config : Optional [Mapping [str , Any ]] = None ,
5555 namespace : Optional [str ] = None ,
5656 size : int = - 1 ,
57+ dimensions : int = - 1 ,
5758 partitions : int = - 1 ,
5859 num_subspaces : int = - 1 ,
5960 l_build : int = - 1 ,
@@ -122,6 +123,10 @@ def ingest(
122123 size: int
123124 Number of input vectors, if not provided use the full size of the input dataset.
124125 If provided, we filter the first vectors from the input source.
126+ dimensions: int
127+ Number of vector dimensions, if not provided use the dimensions detected from the input dataset.
128+ If provided, this overrides the dimensions detected by read_source_metadata. This is only used when
129+ the input_vectors is not provided. Otherwise, it is ignored.
125130 partitions: int
126131 For IVF_FLAT and IVF_PQ indexes, the number of partitions to generate from the data during k-means clustering.
127132 If not provided, is auto-configured based on the dataset size.
@@ -3052,15 +3057,23 @@ def consolidate_and_vacuum(
30523057
30533058 if input_vectors is not None :
30543059 in_size = input_vectors .shape [0 ]
3055- dimensions = input_vectors .shape [1 ]
3060+ # When input_vectors is provided, use detected dimensions (ignore dimensions parameter)
3061+ dimensions = int (input_vectors .shape [1 ])
30563062 vector_type = input_vectors .dtype
30573063 source_type = "TILEDB_ARRAY"
3064+ logger .debug ("Using dimensions from input_vectors: %d" , dimensions )
30583065 else :
30593066 if source_type is None :
30603067 source_type = autodetect_source_type (source_uri = source_uri )
3061- in_size , dimensions , vector_type = read_source_metadata (
3068+ in_size , detected_dimensions , vector_type = read_source_metadata (
30623069 source_uri = source_uri , source_type = source_type
30633070 )
3071+ # Use provided dimensions if specified, otherwise use detected dimensions
3072+ if dimensions == - 1 :
3073+ dimensions = int (detected_dimensions )
3074+ logger .debug (
3075+ "Using dimensions: %d (detected: %d)" , dimensions , detected_dimensions
3076+ )
30643077 logger .debug ("Ingesting Vectors into %r" , index_group_uri )
30653078 arrays_created = False
30663079 if is_type_erased_index (index_type ):
0 commit comments