Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
f1b5b5d
[realppl 3] Arithmetic and comparison expressions
wu-hui Apr 14, 2025
6294868
[realppl 4] Array, debug, field and logical expressions
wu-hui Apr 16, 2025
6c0a698
[realppl 5] map,string,timestamp and mirroring semantics
wu-hui Apr 17, 2025
8efed9e
[realppl 6] offline ppl evaluation and tests
wu-hui Apr 24, 2025
0a8821c
[realppl 7] realppl integration with remote/local and unit tests
wu-hui Apr 30, 2025
f79f655
Remove Fuzzer
wu-hui May 27, 2025
8b8d4a2
[realppl 8] realppl spec tests
wu-hui May 13, 2025
0d65b86
[realppl 9] realppl public api and integration tests
wu-hui Apr 30, 2025
a1ad8f9
[realppl 10] Add server timestamp support
wu-hui Jun 16, 2025
3a10495
[realppl 11] Add query to pipeline support
wu-hui Jul 9, 2025
5a50bd6
Hide realtime pipelines
wu-hui Sep 12, 2025
a54bd45
address API feedbacks
cherylEnkidu Sep 21, 2025
e76d2a2
add documentation
cherylEnkidu Sep 21, 2025
fac2f83
rename Firestore/Swift/Source/ExprImpl.swift
cherylEnkidu Sep 21, 2025
2951a6c
expand expr to expression
cherylEnkidu Sep 25, 2025
afa920e
move files
cherylEnkidu Sep 25, 2025
d77d6d5
move files
cherylEnkidu Sep 25, 2025
18fbbae
move file
cherylEnkidu Sep 25, 2025
7c7eb75
Separate PipelineSource and RealtimePipelineSource
cherylEnkidu Sep 25, 2025
caf8158
add abs()
cherylEnkidu Sep 25, 2025
fb482c7
add arrayReverse
cherylEnkidu Sep 25, 2025
62434c1
add ceil()
cherylEnkidu Sep 25, 2025
d5d5c9d
add collectionId()
cherylEnkidu Sep 26, 2025
11bf771
add countDistinct()
cherylEnkidu Sep 26, 2025
0e39951
[realppl 8] realppl spec tests
wu-hui May 13, 2025
016dac0
[realppl 9] realppl public api and integration tests
wu-hui Apr 30, 2025
00c6256
add exp()
cherylEnkidu Sep 29, 2025
854b6bb
[realppl 10] Add query to pipeline support
wu-hui Jul 9, 2025
814074f
make all bit operations internal
cherylEnkidu Sep 29, 2025
54461f1
add floor()
cherylEnkidu Sep 29, 2025
8e8557f
add length()
cherylEnkidu Sep 29, 2025
ead6684
hide manhattanDistance()
cherylEnkidu Sep 29, 2025
c720527
add ln()
cherylEnkidu Sep 30, 2025
b51b545
Hide realtime pipelines
wu-hui Sep 12, 2025
69ced35
add pow()
cherylEnkidu Sep 30, 2025
3d0a3d3
hide replace expression
cherylEnkidu Sep 30, 2025
617feb4
rename substring
cherylEnkidu Sep 30, 2025
5bc46e3
add more expressions
cherylEnkidu Sep 30, 2025
452875f
make internal impl of Order public
cherylEnkidu Sep 30, 2025
3a258b2
rename timestampSubtract
cherylEnkidu Sep 30, 2025
1c00eea
refactor snapshot
cherylEnkidu Sep 30, 2025
aaa7855
move file
cherylEnkidu Sep 30, 2025
d02c044
remove backpointer to parent
cherylEnkidu Sep 30, 2025
fd8ed65
equivalent()
cherylEnkidu Sep 30, 2025
418e3a6
merge in base branch
cherylEnkidu Sep 30, 2025
e42cce2
merge in base 2
cherylEnkidu Sep 30, 2025
2fb7a14
add concat()
cherylEnkidu Oct 1, 2025
8422b15
add currentTimestamp()
cherylEnkidu Oct 1, 2025
45797e1
hide equivalent
cherylEnkidu Oct 1, 2025
b377edb
add ifAbsent and error
cherylEnkidu Oct 1, 2025
903425b
add join()
cherylEnkidu Oct 1, 2025
50b673e
rename logical
cherylEnkidu Oct 1, 2025
41fcae2
add name tag for FunctionExpression
cherylEnkidu Oct 7, 2025
a4d33e4
add missing tags
cherylEnkidu Oct 9, 2025
91b0dec
add documentations
cherylEnkidu Oct 9, 2025
d8c5c81
add documentations 2
cherylEnkidu Oct 9, 2025
88586a1
rebase to feature branch
cherylEnkidu Oct 22, 2025
43fb9ef
fix rebase error 1
cherylEnkidu Oct 22, 2025
77e4556
resolve rebase error
cherylEnkidu Oct 22, 2025
dfce952
fix broken tests
cherylEnkidu Oct 23, 2025
8005a23
format code
cherylEnkidu Oct 23, 2025
7a357c2
add map_set
cherylEnkidu Oct 24, 2025
bc1a2b7
add equivalent
cherylEnkidu Oct 24, 2025
72b89fd
add TimestampTrunc
cherylEnkidu Oct 24, 2025
2e18c4a
Revert "add equivalent"
cherylEnkidu Oct 24, 2025
3475b66
solve rebase error
cherylEnkidu Oct 24, 2025
7aed083
remove null / nan related operations
cherylEnkidu Oct 24, 2025
78c00d8
change logic to remove null handling
cherylEnkidu Oct 27, 2025
1c9df2a
address feedbacks
cherylEnkidu Oct 30, 2025
af33109
merge in main branch
cherylEnkidu Oct 31, 2025
219add6
solve merge error
cherylEnkidu Oct 31, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions Firestore/Swift/Source/ExpressionImplementation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -604,14 +604,6 @@ public extension Expression {

// --- Added Type Check Operations ---

func isNan() -> BooleanExpression {
return BooleanExpression(functionName: "is_nan", args: [self])
}

func isNil() -> BooleanExpression {
return BooleanExpression(functionName: "is_null", args: [self])
}

func exists() -> BooleanExpression {
return BooleanExpression(functionName: "exists", args: [self])
}
Expand All @@ -624,14 +616,6 @@ public extension Expression {
return BooleanExpression(functionName: "is_absent", args: [self])
}

func isNotNil() -> BooleanExpression {
return BooleanExpression(functionName: "is_not_null", args: [self])
}

func isNotNan() -> BooleanExpression {
return BooleanExpression(functionName: "is_not_nan", args: [self])
}

// --- Added String Operations ---

func join(delimiter: String) -> FunctionExpression {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -635,26 +635,6 @@ public protocol Expression: Sendable {
/// boolean expressions.
func notEqualAny(_ arrayExpression: Expression) -> BooleanExpression

/// Creates an expression that checks if this expression evaluates to "NaN" (Not a Number).
///
/// ```swift
/// // Check if the result of a calculation is NaN
/// Field("value").divide(0).isNan()
/// ```
///
/// - Returns: A new `BooleanExpression` representing the "isNaN" check.
func isNan() -> BooleanExpression

/// Creates an expression that checks if this expression evaluates to "Nil".
///
/// ```swift
/// // Check if the "optionalField" is null
/// Field("optionalField").isNil()
/// ```
///
/// - Returns: A new `BooleanExpression` representing the "isNil" check.
func isNil() -> BooleanExpression

/// Creates an expression that checks if a field exists in the document.
///
/// ```swift
Expand Down Expand Up @@ -686,27 +666,6 @@ public protocol Expression: Sendable {
/// - Returns: A new `BooleanExpression` representing the "isAbsent" check.
func isAbsent() -> BooleanExpression

/// Creates an expression that checks if the result of this expression is not null.
///
/// ```swift
/// // Check if the value of the "name" field is not null
/// Field("name").isNotNil()
/// ```
///
/// - Returns: A new `BooleanExpression` representing the "isNotNil" check.
func isNotNil() -> BooleanExpression

/// Creates an expression that checks if the results of this expression is NOT "NaN" (Not a
/// Number).
///
/// ```swift
/// // Check if the result of a calculation is NOT NaN
/// Field("value").divide(Field("count")).isNotNan() // Assuming count might be 0
/// ```
///
/// - Returns: A new `BooleanExpr` representing the "isNotNaN" check.
func isNotNan() -> BooleanExpression

// MARK: String Operations

/// Creates an expression that joins the elements of an array of strings with a given separator.
Expand Down
8 changes: 4 additions & 4 deletions Firestore/Swift/Tests/Integration/PipelineTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2488,11 +2488,11 @@ class PipelineIntegrationTests: FSTIntegrationTestCase {
.limit(1)
.select(
[
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of deleting them, you can add Field(rating) == nil instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will add back this test. But the iOS SDK only implemented operator overload for ^, !, and ||. So it is still Field(rating).equals(nil)

Field("rating").isNil().as("ratingIsNull"),
Field("rating").isNan().as("ratingIsNaN"),
Field("rating").equal(Constant.nil).as("ratingIsNull"),
Field("rating").equal(Constant(Double.nan)).as("ratingIsNaN"),
Field("foo").isAbsent().as("isAbsent"),
Field("title").isNotNil().as("titleIsNotNull"),
Field("cost").isNotNan().as("costIsNotNan"),
Field("title").notEqual(Constant.nil).as("titleIsNotNull"),
Field("cost").notEqual(Constant(Double.nan)).as("costIsNotNan"),
Field("fooBarBaz").exists().as("fooBarBazExists"),
Field("title").exists().as("titleExists"),
]
Expand Down
129 changes: 50 additions & 79 deletions Firestore/core/src/core/pipeline_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -554,87 +554,58 @@ std::shared_ptr<api::Expr> ToPipelineBooleanExpr(const Filter& filter) {
const google_firestore_v1_Value& value = field_filter.value();
FieldFilter::Operator op = field_filter.op();

if (model::IsNaNValue(value)) {
auto is_nan_expr = std::make_shared<api::FunctionExpr>(
"is_nan", std::vector<std::shared_ptr<api::Expr>>{api_field});
if (op == FieldFilter::Operator::Equal) {
return std::make_shared<api::FunctionExpr>(
"and",
std::vector<std::shared_ptr<api::Expr>>{exists_expr, is_nan_expr});
} else { // Assuming NotEqual for IsNotNan
auto is_not_nan_expr = std::make_shared<api::FunctionExpr>(
"not", std::vector<std::shared_ptr<api::Expr>>{is_nan_expr});
return std::make_shared<api::FunctionExpr>(
"and", std::vector<std::shared_ptr<api::Expr>>{exists_expr,
is_not_nan_expr});
auto api_constant =
std::make_shared<api::Constant>(model::DeepClone(value));
std::shared_ptr<api::Expr> comparison_expr;
std::string func_name;

switch (op) {
case FieldFilter::Operator::LessThan:
func_name = "lt";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these functions be renamed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, this part would be address when fixing realtime ppl implementation. So it is not included in this PR.

break;
case FieldFilter::Operator::LessThanOrEqual:
func_name = "lte";
break;
case FieldFilter::Operator::GreaterThan:
func_name = "gt";
break;
case FieldFilter::Operator::GreaterThanOrEqual:
func_name = "gte";
break;
case FieldFilter::Operator::Equal:
func_name = "eq";
break;
case FieldFilter::Operator::NotEqual:
func_name = "neq";
break;
case FieldFilter::Operator::ArrayContains:
func_name = "array_contains";
break;
case FieldFilter::Operator::In:
case FieldFilter::Operator::NotIn:
case FieldFilter::Operator::ArrayContainsAny: {
HARD_ASSERT(
model::IsArray(value),
"Value for IN, NOT_IN, ARRAY_CONTAINS_ANY must be an array.");

if (op == FieldFilter::Operator::In)
func_name = "eq_any";
else if (op == FieldFilter::Operator::NotIn)
func_name = "not_eq_any";
else if (op == FieldFilter::Operator::ArrayContainsAny)
func_name = "array_contains_any";
break;
}
} else if (model::IsNullValue(value)) {
auto is_null_expr = std::make_shared<api::FunctionExpr>(
"is_null", std::vector<std::shared_ptr<api::Expr>>{api_field});
if (op == FieldFilter::Operator::Equal) {
return std::make_shared<api::FunctionExpr>(
"and",
std::vector<std::shared_ptr<api::Expr>>{exists_expr, is_null_expr});
} else { // Assuming NotEqual for IsNotNull
auto is_not_null_expr = std::make_shared<api::FunctionExpr>(
"not", std::vector<std::shared_ptr<api::Expr>>{is_null_expr});
return std::make_shared<api::FunctionExpr>(
"and", std::vector<std::shared_ptr<api::Expr>>{exists_expr,
is_not_null_expr});
}
} else {
auto api_constant =
std::make_shared<api::Constant>(model::DeepClone(value));
std::shared_ptr<api::Expr> comparison_expr;
std::string func_name;

switch (op) {
case FieldFilter::Operator::LessThan:
func_name = "lt";
break;
case FieldFilter::Operator::LessThanOrEqual:
func_name = "lte";
break;
case FieldFilter::Operator::GreaterThan:
func_name = "gt";
break;
case FieldFilter::Operator::GreaterThanOrEqual:
func_name = "gte";
break;
case FieldFilter::Operator::Equal:
func_name = "eq";
break;
case FieldFilter::Operator::NotEqual:
func_name = "neq";
break;
case FieldFilter::Operator::ArrayContains:
func_name = "array_contains";
break;
case FieldFilter::Operator::In:
case FieldFilter::Operator::NotIn:
case FieldFilter::Operator::ArrayContainsAny: {
HARD_ASSERT(
model::IsArray(value),
"Value for IN, NOT_IN, ARRAY_CONTAINS_ANY must be an array.");

if (op == FieldFilter::Operator::In)
func_name = "eq_any";
else if (op == FieldFilter::Operator::NotIn)
func_name = "not_eq_any";
else if (op == FieldFilter::Operator::ArrayContainsAny)
func_name = "array_contains_any";
break;
}
default:
HARD_FAIL("Unexpected FieldFilter operator.");
}
comparison_expr = std::make_shared<api::FunctionExpr>(
func_name,
std::vector<std::shared_ptr<api::Expr>>{api_field, api_constant});
return std::make_shared<api::FunctionExpr>(
"and", std::vector<std::shared_ptr<api::Expr>>{exists_expr,
comparison_expr});
default:
HARD_FAIL("Unexpected FieldFilter operator.");
}
comparison_expr = std::make_shared<api::FunctionExpr>(
func_name,
std::vector<std::shared_ptr<api::Expr>>{api_field, api_constant});
return std::make_shared<api::FunctionExpr>(
"and",
std::vector<std::shared_ptr<api::Expr>>{exists_expr, comparison_expr});

} else if (filter.type() == FieldFilter::Type::kCompositeFilter) {
const auto& composite_filter = static_cast<const CompositeFilter&>(filter);
std::vector<std::shared_ptr<api::Expr>> sub_exprs;
Expand Down
Loading