Skip to content

Commit 23c452f

Browse files
committed
Remove isNull, isNotNull, isNan, isNotNan, error expressions
1 parent 7d1794d commit 23c452f

File tree

4 files changed

+8
-407
lines changed

4 files changed

+8
-407
lines changed

dev/src/pipelines/expression.ts

Lines changed: 0 additions & 200 deletions
Original file line numberDiff line numberDiff line change
@@ -651,36 +651,6 @@ export abstract class Expression
651651
return new BooleanExpression('not_equal_any', [this, exprOthers]);
652652
}
653653

654-
/**
655-
* @beta
656-
* Creates an expression that checks if this expression evaluates to 'NaN' (Not a Number).
657-
*
658-
* ```typescript
659-
* // Check if the result of a calculation is NaN
660-
* field("value").divide(0).isNan();
661-
* ```
662-
*
663-
* @return A new `Expression` representing the 'isNan' check.
664-
*/
665-
isNan(): BooleanExpression {
666-
return new BooleanExpression('is_nan', [this]);
667-
}
668-
669-
/**
670-
* @beta
671-
* Creates an expression that checks if this expression evaluates to 'Null'.
672-
*
673-
* ```typescript
674-
* // Check if the result of a calculation is NaN
675-
* field("value").isNull();
676-
* ```
677-
*
678-
* @return A new `Expression` representing the 'isNull' check.
679-
*/
680-
isNull(): BooleanExpression {
681-
return new BooleanExpression('is_null', [this]);
682-
}
683-
684654
/**
685655
* @beta
686656
* Creates an expression that checks if a field exists in the document.
@@ -1728,36 +1698,6 @@ export abstract class Expression
17281698
return new BooleanExpression('is_absent', [this]);
17291699
}
17301700

1731-
/**
1732-
* @beta
1733-
* Creates an expression that checks if tbe result of an expression is not null.
1734-
*
1735-
* ```typescript
1736-
* // Check if the value of the 'name' field is not null
1737-
* field("name").isNotNull();
1738-
* ```
1739-
*
1740-
* @return A new {@code BooleanExpression} representing the 'isNotNull' check.
1741-
*/
1742-
isNotNull(): BooleanExpression {
1743-
return new BooleanExpression('is_not_null', [this]);
1744-
}
1745-
1746-
/**
1747-
* @beta
1748-
* Creates an expression that checks if the results of this expression is NOT 'NaN' (Not a Number).
1749-
*
1750-
* ```typescript
1751-
* // Check if the result of a calculation is NOT NaN
1752-
* field("value").divide(0).isNotNan();
1753-
* ```
1754-
*
1755-
* @return A new {@code Expression} representing the 'isNan' check.
1756-
*/
1757-
isNotNan(): BooleanExpression {
1758-
return new BooleanExpression('is_not_nan', [this]);
1759-
}
1760-
17611701
/**
17621702
* @beta
17631703
* Creates an expression that removes a key from the map produced by evaluating this expression.
@@ -3068,99 +3008,6 @@ export function isAbsent(value: Expression | string): BooleanExpression {
30683008
return fieldOrExpression(value).isAbsent();
30693009
}
30703010

3071-
/**
3072-
* @beta
3073-
* Creates an expression that checks if an expression evaluates to 'NaN' (Not a Number).
3074-
*
3075-
* ```typescript
3076-
* // Check if the result of a calculation is NaN
3077-
* isNull(field("value").divide(0));
3078-
* ```
3079-
*
3080-
* @param value The expression to check.
3081-
* @return A new {@code Expression} representing the 'isNull' check.
3082-
*/
3083-
export function isNull(value: Expression): BooleanExpression;
3084-
3085-
/**
3086-
* @beta
3087-
* Creates an expression that checks if a field's value evaluates to 'NaN' (Not a Number).
3088-
*
3089-
* ```typescript
3090-
* // Check if the result of a calculation is NaN
3091-
* isNull("value");
3092-
* ```
3093-
*
3094-
* @param value The name of the field to check.
3095-
* @return A new {@code Expression} representing the 'isNull' check.
3096-
*/
3097-
export function isNull(value: string): BooleanExpression;
3098-
export function isNull(value: Expression | string): BooleanExpression {
3099-
return fieldOrExpression(value).isNull();
3100-
}
3101-
3102-
/**
3103-
* @beta
3104-
* Creates an expression that checks if tbe result of an expression is not null.
3105-
*
3106-
* ```typescript
3107-
* // Check if the value of the 'name' field is not null
3108-
* isNotNull(field("name"));
3109-
* ```
3110-
*
3111-
* @param value The expression to check.
3112-
* @return A new {@code Expression} representing the 'isNotNull' check.
3113-
*/
3114-
export function isNotNull(value: Expression): BooleanExpression;
3115-
3116-
/**
3117-
* @beta
3118-
* Creates an expression that checks if tbe value of a field is not null.
3119-
*
3120-
* ```typescript
3121-
* // Check if the value of the 'name' field is not null
3122-
* isNotNull("name");
3123-
* ```
3124-
*
3125-
* @param value The name of the field to check.
3126-
* @return A new {@code Expression} representing the 'isNotNull' check.
3127-
*/
3128-
export function isNotNull(value: string): BooleanExpression;
3129-
export function isNotNull(value: Expression | string): BooleanExpression {
3130-
return fieldOrExpression(value).isNotNull();
3131-
}
3132-
3133-
/**
3134-
* @beta
3135-
* Creates an expression that checks if the results of this expression is NOT 'NaN' (Not a Number).
3136-
*
3137-
* ```typescript
3138-
* // Check if the result of a calculation is NOT NaN
3139-
* isNotNaN(field("value").divide(0));
3140-
* ```
3141-
*
3142-
* @param value The expression to check.
3143-
* @return A new {@code Expression} representing the 'isNotNaN' check.
3144-
*/
3145-
export function isNotNan(value: Expression): BooleanExpression;
3146-
3147-
/**
3148-
* @beta
3149-
* Creates an expression that checks if the results of this expression is NOT 'NaN' (Not a Number).
3150-
*
3151-
* ```typescript
3152-
* // Check if the value of a field is NOT NaN
3153-
* isNotNaN("value");
3154-
* ```
3155-
*
3156-
* @param value The name of the field to check.
3157-
* @return A new {@code Expression} representing the 'isNotNaN' check.
3158-
*/
3159-
export function isNotNan(value: string): BooleanExpression;
3160-
export function isNotNan(value: Expression | string): BooleanExpression {
3161-
return fieldOrExpression(value).isNotNan();
3162-
}
3163-
31643011
/**
31653012
* @beta
31663013
* Creates an expression that removes a key from the map at the specified field name.
@@ -4960,37 +4807,6 @@ export function exists(valueOrField: Expression | string): BooleanExpression {
49604807
return fieldOrExpression(valueOrField).exists();
49614808
}
49624809

4963-
/**
4964-
* @beta
4965-
* Creates an expression that checks if an expression evaluates to 'NaN' (Not a Number).
4966-
*
4967-
* ```typescript
4968-
* // Check if the result of a calculation is NaN
4969-
* isNan(field("value").divide(0));
4970-
* ```
4971-
*
4972-
* @param value The expression to check.
4973-
* @return A new {@code Expression} representing the 'isNan' check.
4974-
*/
4975-
export function isNan(value: Expression): BooleanExpression;
4976-
4977-
/**
4978-
* @beta
4979-
* Creates an expression that checks if a field's value evaluates to 'NaN' (Not a Number).
4980-
*
4981-
* ```typescript
4982-
* // Check if the result of a calculation is NaN
4983-
* isNan("value");
4984-
* ```
4985-
*
4986-
* @param fieldName The name of the field to check.
4987-
* @return A new {@code Expression} representing the 'isNan' check.
4988-
*/
4989-
export function isNan(fieldName: string): BooleanExpression;
4990-
export function isNan(value: Expression | string): BooleanExpression {
4991-
return fieldOrExpression(value).isNan();
4992-
}
4993-
49944810
/**
49954811
* @beta
49964812
* Creates an expression that reverses a string.
@@ -6699,22 +6515,6 @@ export function currentTimestamp(): FunctionExpression {
66996515
return new FunctionExpression('current_timestamp', []);
67006516
}
67016517

6702-
/**
6703-
* @beta
6704-
* Creates an expression that raises an error with the given message. This could be useful for
6705-
* debugging purposes.
6706-
*
6707-
* ```typescript
6708-
* // Raise an error with the message "simulating an evaluation error".
6709-
* error("simulating an evaluation error")
6710-
* ```
6711-
*
6712-
* @return A new Expression representing the error() operation.
6713-
*/
6714-
export function error(message: string): Expression {
6715-
return new FunctionExpression('error', [constant(message)]);
6716-
}
6717-
67186518
/**
67196519
* @beta
67206520
* Creates an expression that performs a logical 'AND' operation on multiple filter conditions.

dev/src/pipelines/index.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,12 @@ export {
7171
toUpper,
7272
toLower,
7373
vectorLength,
74-
isNotNan,
7574
exists,
76-
isNotNull,
7775
isAbsent,
7876
ifError,
7977
isError,
80-
isNan,
8178
substring,
8279
documentId,
83-
isNull,
8480
arrayContainsAll,
8581
constant,
8682
Field,
@@ -124,7 +120,6 @@ export {
124120
concat,
125121
join,
126122
currentTimestamp,
127-
error,
128123
arrayConcat,
129124
// TODO(new-expression): Add new expression exports above this line
130125
} from './expression';

dev/system-test/pipeline.ts

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,12 @@ import {
5454
toUpper,
5555
toLower,
5656
vectorLength,
57-
isNotNan,
5857
exists,
59-
isNotNull,
6058
isAbsent,
6159
ifError,
6260
isError,
63-
isNan,
6461
substring,
6562
documentId,
66-
isNull,
6763
arrayContainsAll,
6864
mapRemove,
6965
mapMerge,
@@ -119,7 +115,6 @@ import {
119115
join,
120116
arraySum,
121117
currentTimestamp,
122-
error,
123118
arrayConcat,
124119
// TODO(new-expression): add new expression imports above this line
125120
} from '../src/pipelines';
@@ -2701,8 +2696,8 @@ describe.only('Pipeline class', () => {
27012696
.sort(field('rating').descending())
27022697
.limit(1)
27032698
.select(
2704-
isNull('rating').as('ratingIsNull'),
2705-
isNan('rating').as('ratingIsNaN'),
2699+
equal('rating', null).as('ratingIsNull'),
2700+
equal('rating', NaN).as('ratingIsNaN'),
27062701
isError(divide(constant(1), constant(0))).as('isError'),
27072702
ifError(divide(constant(1), constant(0)), constant('was error')).as(
27082703
'ifError'
@@ -2714,8 +2709,8 @@ describe.only('Pipeline class', () => {
27142709
.not()
27152710
.as('ifErrorBooleanExpression'),
27162711
isAbsent('foo').as('isAbsent'),
2717-
isNotNull('title').as('titleIsNotNull'),
2718-
isNotNan('cost').as('costIsNotNan'),
2712+
notEqual('title', null).as('titleIsNotNull'),
2713+
notEqual('cost', NaN).as('costIsNotNan'),
27192714
exists('fooBarBaz').as('fooBarBazExists'),
27202715
field('title').exists().as('titleExists')
27212716
)
@@ -2739,8 +2734,8 @@ describe.only('Pipeline class', () => {
27392734
.sort(field('rating').descending())
27402735
.limit(1)
27412736
.select(
2742-
field('rating').isNull().as('ratingIsNull'),
2743-
field('rating').isNan().as('ratingIsNaN'),
2737+
field('rating').equal(null).as('ratingIsNull'),
2738+
field('rating').equal(NaN).as('ratingIsNaN'),
27442739
divide(constant(1), constant(0)).isError().as('isError'),
27452740
divide(constant(1), constant(0))
27462741
.ifError(constant('was error'))
@@ -2751,8 +2746,8 @@ describe.only('Pipeline class', () => {
27512746
.not()
27522747
.as('ifErrorBooleanExpression'),
27532748
field('foo').isAbsent().as('isAbsent'),
2754-
field('title').isNotNull().as('titleIsNotNull'),
2755-
field('cost').isNotNan().as('costIsNotNan')
2749+
field('title').notEqual(null).as('titleIsNotNull'),
2750+
field('cost').notEqual(NaN).as('costIsNotNan')
27562751
)
27572752
.execute();
27582753
expectResults(snapshot, {
@@ -3929,21 +3924,6 @@ describe.only('Pipeline class', () => {
39293924
).lessThan(5000);
39303925
});
39313926

3932-
// Not implemented in backend
3933-
// eslint-disable-next-line no-restricted-properties
3934-
it.skip('supports error', async () => {
3935-
const snapshot = await firestore
3936-
.pipeline()
3937-
.collection(randomCol.path)
3938-
.limit(1)
3939-
.select(isError(error('test error')).as('error'))
3940-
.execute();
3941-
3942-
expectResults(snapshot, {
3943-
error: true,
3944-
});
3945-
});
3946-
39473927
it('supports ifAbsent', async () => {
39483928
const snapshot = await firestore
39493929
.pipeline()

0 commit comments

Comments
 (0)