|
21 | 21 | import static com.google.cloud.firestore.pipeline.expressions.Expression.arrayContainsAny; |
22 | 22 | import static com.google.cloud.firestore.pipeline.expressions.Expression.field; |
23 | 23 | import static com.google.cloud.firestore.pipeline.expressions.Expression.not; |
| 24 | +import static com.google.cloud.firestore.pipeline.expressions.Expression.nullValue; |
24 | 25 | import static com.google.cloud.firestore.pipeline.expressions.Expression.or; |
25 | 26 | import static com.google.cloud.firestore.pipeline.expressions.FunctionUtils.aggregateFunctionToValue; |
26 | 27 | import static com.google.cloud.firestore.pipeline.expressions.FunctionUtils.exprToValue; |
@@ -109,7 +110,7 @@ static BooleanExpression toPipelineBooleanExpr(FilterInternal f) { |
109 | 110 | case EQUAL: |
110 | 111 | return and(field.exists(), field.equal(value)); |
111 | 112 | case NOT_EQUAL: |
112 | | - return and(field.exists(), not(field.equal(value))); |
| 113 | + return and(field.exists(), field.notEqual(value)); |
113 | 114 | case ARRAY_CONTAINS: |
114 | 115 | return and(field.exists(), field.arrayContains(value)); |
115 | 116 | case IN: |
@@ -155,13 +156,13 @@ static BooleanExpression toPipelineBooleanExpr(FilterInternal f) { |
155 | 156 | Field field = Field.ofServerPath(unaryFilter.fieldReference.getFieldPath()); |
156 | 157 | switch (unaryFilter.getOperator()) { |
157 | 158 | case IS_NAN: |
158 | | - return and(field.exists(), field.isNaN()); |
| 159 | + return and(field.exists(), field.equal(Double.NaN)); |
159 | 160 | case IS_NULL: |
160 | | - return and(field.exists(), field.isNull()); |
| 161 | + return and(field.exists(), field.equal(nullValue())); |
161 | 162 | case IS_NOT_NAN: |
162 | | - return and(field.exists(), field.isNotNaN()); |
| 163 | + return and(field.exists(), field.notEqual(Double.NaN)); |
163 | 164 | case IS_NOT_NULL: |
164 | | - return and(field.exists(), field.isNotNull()); |
| 165 | + return and(field.exists(), field.notEqual(nullValue())); |
165 | 166 | default: |
166 | 167 | // Handle OPERATOR_UNSPECIFIED and UNRECOGNIZED cases as needed |
167 | 168 | throw new IllegalArgumentException("Unsupported operator: " + unaryFilter.getOperator()); |
@@ -219,9 +220,17 @@ public static Map<String, Expression> selectablesToMap(Selectable... selectables |
219 | 220 | for (Selectable proj : selectables) { |
220 | 221 | if (proj instanceof Field) { |
221 | 222 | Field fieldProj = (Field) proj; |
| 223 | + if (projMap.containsKey(fieldProj.getPath().getEncodedPath())) { |
| 224 | + throw new IllegalArgumentException( |
| 225 | + "Duplicate alias or field name: " + fieldProj.getPath().getEncodedPath()); |
| 226 | + } |
222 | 227 | projMap.put(fieldProj.getPath().getEncodedPath(), fieldProj); |
223 | 228 | } else if (proj instanceof AliasedExpression) { |
224 | 229 | AliasedExpression aliasedExpr = (AliasedExpression) proj; |
| 230 | + if (projMap.containsKey(aliasedExpr.getAlias())) { |
| 231 | + throw new IllegalArgumentException( |
| 232 | + "Duplicate alias or field name: " + aliasedExpr.getAlias()); |
| 233 | + } |
225 | 234 | projMap.put(aliasedExpr.getAlias(), aliasedExpr.getExpr()); |
226 | 235 | } |
227 | 236 | } |
|
0 commit comments