Skip to content
Open
Show file tree
Hide file tree
Changes from 68 commits
Commits
Show all changes
69 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
585c525
add trim()
cherylEnkidu Oct 27, 2025
b6ab3a0
remove Equivalent
cherylEnkidu Oct 27, 2025
94cc75f
address feedbacks
cherylEnkidu Oct 30, 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
435 changes: 270 additions & 165 deletions Firestore/Swift/Source/ExpressionImplementation.swift

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Firestore/Swift/Source/Helper/PipelineHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ enum Helper {
result.append(Constant(key))
result.append(sendableToExpr(value))
}
return FunctionExpression("map", result)
return FunctionExpression(functionName: "map", args: result)
}

static func array(_ elements: [Sendable?]) -> FunctionExpression {
let transformedElements = elements.map { element in
sendableToExpr(element)
}
return FunctionExpression("array", transformedElements)
return FunctionExpression(functionName: "array", args: transformedElements)
}

// This function is used to convert Swift type into Objective-C type.
Expand Down
31 changes: 31 additions & 0 deletions Firestore/Swift/Source/SwiftAPI/Firestore+Pipeline.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,44 @@
import Foundation

@objc public extension Firestore {
/// Creates a `PipelineSource` that can be used to build and execute a pipeline of operations on
/// the Firestore database.
///
/// A pipeline is a sequence of stages that are executed in order. Each stage can perform an
/// operation on the data, such as filtering, sorting, or transforming it.
///
/// Example usage:
/// ```swift
/// let db = Firestore.firestore()
/// let pipeline = db.pipeline()
/// .collection("books")
/// .where(Field("rating").isGreaterThan(4.5))
/// .sort([Field("rating").descending()])
/// .limit(2)
///
/// do {
/// let snapshot = try await pipeline.execute()
/// for doc in snapshot.results {
/// print(doc.data())
/// }
/// } catch {
/// print("Error executing pipeline: \(error)")
/// }
/// ```
///
/// - Returns: A `PipelineSource` that can be used to build and execute a pipeline.
Copy link
Contributor

Choose a reason for hiding this comment

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

FWIW, I have updated Android's comment to this:

/**

  • Creates a new {@link PipelineSource} to build and execute a data pipeline.
  • A pipeline is composed of a sequence of stages. Each stage processes the

  • output from the previous one, and the final stage's output is the result of the
  • pipeline's execution.
  • Example usage:

  • {@code
    
  • Pipeline pipeline = firestore.pipeline()
  • .collection("books")
  • .where(Field("rating").isGreaterThan(4.5))
  • .sort(Field("rating").descending())
  • .limit(2);
  • }
  • Note on Execution: The stages are conceptual. The Firestore backend may

  • optimize execution (e.g., reordering or merging stages) as long as the
  • final result remains the same.
  • Important Limitations:

    • Pipelines operate on a request/response basis only.
    • They do not utilize or update the local SDK cache.
    • They do not support realtime snapshot listeners.
  • @return A {@code PipelineSource} to begin defining the pipeline's stages.
    */

@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@nonobjc func pipeline() -> PipelineSource {
return PipelineSource(db: self) { stages, db in
Pipeline(stages: stages, db: db)
}
}

/// Creates a `RealtimePipelineSource` for building and executing a realtime pipeline.
///
/// This is an internal method and should not be used directly.
///
/// - Returns: A `RealtimePipelineSource` for building a realtime pipeline.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@nonobjc internal func realtimePipeline() -> RealtimePipelineSource {
return RealtimePipelineSource(db: self) { stages, db in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,23 @@ extension AggregateFunction {
}
}

/// Represents an aggregate function in a pipeline.
///
/// An `AggregateFunction` is a function that computes a single value from a set of input values.
///
/// `AggregateFunction`s are typically used in the `aggregate` stage of a pipeline.
public class AggregateFunction: AggregateBridgeWrapper, @unchecked Sendable {
let bridge: AggregateFunctionBridge

let functionName: String
let args: [Expression]

public init(_ functionName: String, _ args: [Expression]) {
/// Creates a new `AggregateFunction`.
///
/// - Parameters:
/// - functionName: The name of the aggregate function.
/// - args: The arguments to the aggregate function.
public init(functionName: String, args: [Expression]) {
self.functionName = functionName
self.args = args
bridge = AggregateFunctionBridge(
Expand All @@ -34,6 +44,10 @@ public class AggregateFunction: AggregateBridgeWrapper, @unchecked Sendable {
)
}

/// Creates an `AliasedAggregate` from this aggregate function.
///
/// - Parameter name: The alias for the aggregate function.
/// - Returns: An `AliasedAggregate` with the given alias.
public func `as`(_ name: String) -> AliasedAggregate {
return AliasedAggregate(aggregate: self, alias: name)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

/// An `AggregateFunction` that has been given an alias.
public struct AliasedAggregate {
public let aggregate: AggregateFunction
public let alias: String
let aggregate: AggregateFunction

let alias: String
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@
public class CountAll: AggregateFunction, @unchecked Sendable {
/// Initializes a new `CountAll` aggregation.
public init() {
super.init("count", [])
super.init(functionName: "count", args: [])
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import Foundation

/// Represents the distance measure to be used in a vector similarity search.
public struct DistanceMeasure: Sendable, Equatable, Hashable {
let kind: Kind

Expand All @@ -29,10 +30,13 @@ public struct DistanceMeasure: Sendable, Equatable, Hashable {
case dotProduct = "dot_product"
}

/// The Euclidean distance measure.
public static let euclidean: DistanceMeasure = .init(kind: .euclidean)

/// The Cosine distance measure.
public static let cosine: DistanceMeasure = .init(kind: .cosine)

/// The Dot Product distance measure.
public static let dotProduct: DistanceMeasure = .init(kind: .dotProduct)

init(kind: Kind) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

/// An `Expression` that has been given an alias.
public struct AliasedExpression: Selectable, SelectableWrapper, Sendable {
let alias: String

Expand Down
Loading
Loading