@@ -25,6 +25,11 @@ def __init__(self, property_id: int, op: _QueryConditionOp, args: Dict[str, Any]
2525 self ._property_id = property_id
2626 self ._op = op
2727 self ._args = args
28+ self ._alias = None
29+
30+ def alias (self , value : str ):
31+ self ._alias = value
32+ return self
2833
2934 def _get_op_map (self ):
3035 return {
@@ -52,6 +57,9 @@ def _apply_eq(self, qb: 'QueryBuilder'):
5257 else :
5358 raise Exception (f"Unsupported type for 'EQ': { type (value )} " )
5459
60+ if self ._alias is not None :
61+ qb .alias (self ._alias )
62+
5563 def _apply_not_eq (self , qb : 'QueryBuilder' ):
5664 value = self ._args ['value' ]
5765 case_sensitive = self ._args ['case_sensitive' ]
@@ -62,6 +70,9 @@ def _apply_not_eq(self, qb: 'QueryBuilder'):
6270 else :
6371 raise Exception (f"Unsupported type for 'NOT_EQ': { type (value )} " )
6472
73+ if self ._alias is not None :
74+ qb .alias (self ._alias )
75+
6576 def _apply_contains (self , qb : 'QueryBuilder' ):
6677 value = self ._args ['value' ]
6778 case_sensitive = self ._args ['case_sensitive' ]
@@ -70,6 +81,9 @@ def _apply_contains(self, qb: 'QueryBuilder'):
7081 else :
7182 raise Exception (f"Unsupported type for 'CONTAINS': { type (value )} " )
7283
84+ if self ._alias is not None :
85+ qb .alias (self ._alias )
86+
7387 def _apply_starts_with (self , qb : 'QueryBuilder' ):
7488 value = self ._args ['value' ]
7589 case_sensitive = self ._args ['case_sensitive' ]
@@ -78,6 +92,9 @@ def _apply_starts_with(self, qb: 'QueryBuilder'):
7892 else :
7993 raise Exception (f"Unsupported type for 'STARTS_WITH': { type (value )} " )
8094
95+ if self ._alias is not None :
96+ qb .alias (self ._alias )
97+
8198 def _apply_ends_with (self , qb : 'QueryBuilder' ):
8299 value = self ._args ['value' ]
83100 case_sensitive = self ._args ['case_sensitive' ]
@@ -86,6 +103,9 @@ def _apply_ends_with(self, qb: 'QueryBuilder'):
86103 else :
87104 raise Exception (f"Unsupported type for 'ENDS_WITH': { type (value )} " )
88105
106+ if self ._alias is not None :
107+ qb .alias (self ._alias )
108+
89109 def _apply_gt (self , qb : 'QueryBuilder' ):
90110 value = self ._args ['value' ]
91111 case_sensitive = self ._args ['case_sensitive' ]
@@ -96,6 +116,9 @@ def _apply_gt(self, qb: 'QueryBuilder'):
96116 else :
97117 raise Exception (f"Unsupported type for 'GT': { type (value )} " )
98118
119+ if self ._alias is not None :
120+ qb .alias (self ._alias )
121+
99122 def _apply_gte (self , qb : 'QueryBuilder' ):
100123 value = self ._args ['value' ]
101124 case_sensitive = self ._args ['case_sensitive' ]
@@ -106,6 +129,9 @@ def _apply_gte(self, qb: 'QueryBuilder'):
106129 else :
107130 raise Exception (f"Unsupported type for 'GTE': { type (value )} " )
108131
132+ if self ._alias is not None :
133+ qb .alias (self ._alias )
134+
109135 def _apply_lt (self , qb : 'QueryCondition' ):
110136 value = self ._args ['value' ]
111137 case_sensitive = self ._args ['case_sensitive' ]
@@ -116,6 +142,9 @@ def _apply_lt(self, qb: 'QueryCondition'):
116142 else :
117143 raise Exception ("Unsupported type for 'LT': " + str (type (value )))
118144
145+ if self ._alias is not None :
146+ qb .alias (self ._alias )
147+
119148 def _apply_lte (self , qb : 'QueryBuilder' ):
120149 value = self ._args ['value' ]
121150 case_sensitive = self ._args ['case_sensitive' ]
@@ -126,6 +155,9 @@ def _apply_lte(self, qb: 'QueryBuilder'):
126155 else :
127156 raise Exception (f"Unsupported type for 'LTE': { type (value )} " )
128157
158+ if self ._alias is not None :
159+ qb .alias (self ._alias )
160+
129161 def _apply_between (self , qb : 'QueryBuilder' ):
130162 a = self ._args ['a' ]
131163 b = self ._args ['b' ]
@@ -134,6 +166,9 @@ def _apply_between(self, qb: 'QueryBuilder'):
134166 else :
135167 raise Exception (f"Unsupported type for 'BETWEEN': { type (a )} " )
136168
169+ if self ._alias is not None :
170+ qb .alias (self ._alias )
171+
137172 def _apply_nearest_neighbor (self , qb : 'QueryBuilder' ):
138173 query_vector = self ._args ['query_vector' ]
139174 element_count = self ._args ['element_count' ]
@@ -149,5 +184,8 @@ def _apply_nearest_neighbor(self, qb: 'QueryBuilder'):
149184 else :
150185 raise Exception (f"Unsupported type for 'NEAREST_NEIGHBOR': { type (query_vector )} " )
151186
187+ if self ._alias is not None :
188+ qb .alias (self ._alias )
189+
152190 def apply (self , qb : 'QueryBuilder' ):
153191 self ._get_op_map ()[self ._op ](qb )
0 commit comments