@@ -39,7 +39,9 @@ __all__ = [
39
39
"DimensionsMismatchError" ,
40
40
"DtypeMismatch" ,
41
41
"EmbeddingSizeMismatch" ,
42
+ "EmptyColumnNameError" ,
42
43
"Executor" ,
44
+ "ExplainQueryResult" ,
43
45
"ExpiredTokenError" ,
44
46
"FormatNotSupportedError" ,
45
47
"Future" ,
@@ -130,6 +132,7 @@ __all__ = [
130
132
"delete" ,
131
133
"disconnect" ,
132
134
"exists" ,
135
+ "explain_query" ,
133
136
"from_coco" ,
134
137
"from_parquet" ,
135
138
"like" ,
@@ -560,6 +563,12 @@ class Metadata(ReadOnlyMetadata):
560
563
"""
561
564
...
562
565
566
+ class ExplainQueryResult :
567
+ def __str__ (self ) -> str :
568
+ ...
569
+ def to_dict (self ) -> typing .Any :
570
+ ...
571
+
563
572
def prepare_query (query : str , token : str | None = None , creds : dict [str , str ] | None = None ) -> Executor :
564
573
"""
565
574
Prepares a TQL query for execution with optional authentication.
@@ -786,6 +795,37 @@ def query_async(query: str, token: str | None = None, creds: dict[str, str] | No
786
795
"""
787
796
...
788
797
798
+ def explain_query (query : str , token : str | None = None , creds : dict [str , str ] | None = None ) -> ExplainQueryResult :
799
+ """
800
+ Explains TQL query with optional authentication.
801
+
802
+ Args:
803
+ query: TQL query string to explain
804
+ token: Optional Activeloop authentication token
805
+ creds (dict, optional): Dictionary containing credentials used to access the dataset at the path.
806
+
807
+ Returns:
808
+ ExplainQueryResult: An explain result object to analyze the query.
809
+
810
+ <!-- test-context
811
+ ```python
812
+ import deeplake
813
+ ds = deeplake.create("mem://explain_query")
814
+ ds.add_column("category", "text")
815
+ ds.append({"category": ["active", "inactive", "not sure"]})
816
+ ds.commit()
817
+ ```
818
+ -->
819
+
820
+ Examples:
821
+ Explaining a query:
822
+ ```python
823
+ explain_result = deeplake.explain_query('SELECT * FROM "mem://explain_query" WHERE category == \' active\' ')
824
+ print(explain_result)
825
+ ```
826
+ """
827
+ ...
828
+
789
829
class Client :
790
830
"""
791
831
Client for connecting to Activeloop services.
@@ -972,6 +1012,19 @@ class Tag:
972
1012
"""
973
1013
The name of the tag
974
1014
"""
1015
+
1016
+ @property
1017
+ def message (self ) -> str :
1018
+ """
1019
+ The message of the tag
1020
+ """
1021
+
1022
+ @property
1023
+ def timestamp (self ) -> datetime .datetime :
1024
+ """
1025
+ The tag creation timestamp
1026
+ """
1027
+ ...
975
1028
976
1029
@property
977
1030
def version (self ) -> str :
@@ -1025,12 +1078,25 @@ class TagView:
1025
1078
The name of the tag
1026
1079
"""
1027
1080
1081
+ @property
1082
+ def message (self ) -> str :
1083
+ """
1084
+ The message of the tag
1085
+ """
1086
+
1028
1087
@property
1029
1088
def version (self ) -> str :
1030
1089
"""
1031
1090
The version that has been tagged
1032
1091
"""
1033
1092
1093
+ @property
1094
+ def timestamp (self ) -> datetime .datetime :
1095
+ """
1096
+ The tag creation timestamp
1097
+ """
1098
+ ...
1099
+
1034
1100
def open (self ) -> DatasetView :
1035
1101
"""
1036
1102
Fetches the dataset corresponding to the tag
@@ -1095,7 +1161,7 @@ class TagsView:
1095
1161
"""
1096
1162
Return a list of tag names
1097
1163
"""
1098
- ...
1164
+ ...
1099
1165
1100
1166
class ColumnDefinition :
1101
1167
def __str__ (self ) -> str : ...
@@ -1282,6 +1348,12 @@ class ColumnView:
1282
1348
"""
1283
1349
...
1284
1350
1351
+ def get_bytes (self , index : int | slice | list | tuple ) -> bytes | list :
1352
+ ...
1353
+
1354
+ def get_bytes_async (self , index : int | slice | list | tuple ) -> Future :
1355
+ ...
1356
+
1285
1357
def __len__ (self ) -> int :
1286
1358
"""
1287
1359
Get the number of items in the column.
@@ -1679,6 +1751,12 @@ class Row:
1679
1751
or await the FutureVoid object in an asynchronous context.
1680
1752
"""
1681
1753
1754
+ def get_bytes (self , column : str ) -> bytes | list :
1755
+ ...
1756
+
1757
+ def get_bytes_async (self , column : str ) -> Future :
1758
+ ...
1759
+
1682
1760
def to_dict (self ) -> dict :
1683
1761
"""
1684
1762
Converts the row to a dictionary.
@@ -1783,6 +1861,12 @@ class RowRange:
1783
1861
or await the FutureVoid object in an asynchronous context.
1784
1862
"""
1785
1863
1864
+ def get_bytes (self , column : str ) -> bytes | list :
1865
+ ...
1866
+
1867
+ def get_bytes_async (self , column : str ) -> Future :
1868
+ ...
1869
+
1786
1870
def summary (self ) -> None :
1787
1871
"""
1788
1872
Prints a summary of the RowRange.
@@ -1846,6 +1930,12 @@ class RowRangeView:
1846
1930
or use the Future in an `await` expression.
1847
1931
"""
1848
1932
1933
+ def get_bytes (self , column : str ) -> bytes | list :
1934
+ ...
1935
+
1936
+ def get_bytes_async (self , column : str ) -> Future :
1937
+ ...
1938
+
1849
1939
class RowView :
1850
1940
"""
1851
1941
Provides access to a particular row in a dataset.
@@ -1889,6 +1979,12 @@ class RowView:
1889
1979
or use the Future in an `await` expression.
1890
1980
"""
1891
1981
1982
+ def get_bytes (self , column : str ) -> bytes | list :
1983
+ ...
1984
+
1985
+ def get_bytes_async (self , column : str ) -> Future :
1986
+ ...
1987
+
1892
1988
def to_dict (self ) -> dict :
1893
1989
"""
1894
1990
Converts the row to a dictionary.
@@ -1993,6 +2089,33 @@ class DatasetView:
1993
2089
"""
1994
2090
...
1995
2091
2092
+ def explain_query (self , query : str ) -> ExplainQueryResult :
2093
+ """
2094
+ Explains a query.
2095
+
2096
+ Parameters:
2097
+ query: The query to explain
2098
+
2099
+ Returns:
2100
+ ExplainQueryResult: The result of the explanation
2101
+
2102
+ <!-- test-context
2103
+ ```python
2104
+ import deeplake
2105
+ ds = deeplake.create("tmp://")
2106
+ ds.add_column("category", "text")
2107
+ ds.append({"category": ["active", "inactive", "not sure"]})
2108
+ ```
2109
+ -->
2110
+
2111
+ Examples:
2112
+ ```python
2113
+ explain_result = ds.explain_query("select * where category == 'inactive'")
2114
+ print(explain_result)
2115
+ ```
2116
+ """
2117
+ ...
2118
+
1996
2119
def summary (self ) -> None :
1997
2120
"""
1998
2121
Prints a summary of the dataset.
@@ -2083,7 +2206,7 @@ class DatasetView:
2083
2206
"""
2084
2207
...
2085
2208
2086
- def tag (self , name : str | None = None ) -> Tag :
2209
+ def tag (self , name : str | None = None , message : str | None = None ) -> Tag :
2087
2210
"""
2088
2211
Saves the current view as a tag to its source dataset and returns the tag.
2089
2212
"""
@@ -2285,7 +2408,7 @@ class Dataset(DatasetView):
2285
2408
"""
2286
2409
...
2287
2410
2288
- def tag (self , name : str , version : str | None = None ) -> Tag :
2411
+ def tag (self , name : str , message : str | None = None , version : str | None = None ) -> Tag :
2289
2412
"""
2290
2413
Tags a version of the dataset. If no version is given, the current version is tagged.
2291
2414
@@ -2382,6 +2505,10 @@ class Dataset(DatasetView):
2382
2505
"""
2383
2506
...
2384
2507
2508
+ @property
2509
+ def _datafiles (self ) -> list [tuple [str , int ]]:
2510
+ ...
2511
+
2385
2512
@property
2386
2513
def id (self ) -> str :
2387
2514
"""
@@ -2880,6 +3007,10 @@ class ReadOnlyDataset(DatasetView):
2880
3007
"""
2881
3008
...
2882
3009
3010
+ @property
3011
+ def _datafiles (self ) -> list [tuple [str , int ]]:
3012
+ ...
3013
+
2883
3014
@property
2884
3015
def id (self ) -> str :
2885
3016
"""
@@ -3015,6 +3146,9 @@ class IndexAlreadyExistsError(Exception):
3015
3146
class EmbeddingSizeMismatch (Exception ):
3016
3147
pass
3017
3148
3149
+ class EmptyColumnNameError (Exception ):
3150
+ pass
3151
+
3018
3152
class InvalidCredsKeyAssignmentError (Exception ):
3019
3153
pass
3020
3154
0 commit comments