spark-connect 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +173 -1
  3. data/README.md +37 -13
  4. data/lib/spark_connect/arrow.rb +5 -1
  5. data/lib/spark_connect/catalog.rb +157 -12
  6. data/lib/spark_connect/channel_builder.rb +119 -12
  7. data/lib/spark_connect/client.rb +237 -17
  8. data/lib/spark_connect/column.rb +143 -10
  9. data/lib/spark_connect/conf.rb +17 -1
  10. data/lib/spark_connect/data_frame.rb +447 -25
  11. data/lib/spark_connect/functions.rb +1948 -494
  12. data/lib/spark_connect/grouped_data.rb +33 -7
  13. data/lib/spark_connect/merge.rb +146 -0
  14. data/lib/spark_connect/na_functions.rb +43 -9
  15. data/lib/spark_connect/observation.rb +26 -5
  16. data/lib/spark_connect/pipelines.rb +101 -0
  17. data/lib/spark_connect/plan.rb +52 -0
  18. data/lib/spark_connect/proto/spark/connect/base_pb.rb +6 -1
  19. data/lib/spark_connect/proto/spark/connect/base_services_pb.rb +2 -0
  20. data/lib/spark_connect/proto/spark/connect/catalog_pb.rb +11 -1
  21. data/lib/spark_connect/proto/spark/connect/commands_pb.rb +1 -1
  22. data/lib/spark_connect/proto/spark/connect/expressions_pb.rb +3 -1
  23. data/lib/spark_connect/proto/spark/connect/pipelines_pb.rb +5 -1
  24. data/lib/spark_connect/proto/spark/connect/relations_pb.rb +4 -1
  25. data/lib/spark_connect/proto/spark/connect/types_pb.rb +3 -1
  26. data/lib/spark_connect/reader.rb +98 -17
  27. data/lib/spark_connect/session.rb +232 -30
  28. data/lib/spark_connect/stat_functions.rb +19 -9
  29. data/lib/spark_connect/storage_level.rb +79 -0
  30. data/lib/spark_connect/streaming.rb +335 -20
  31. data/lib/spark_connect/table_arg.rb +73 -0
  32. data/lib/spark_connect/tvf.rb +78 -0
  33. data/lib/spark_connect/types.rb +149 -0
  34. data/lib/spark_connect/version.rb +2 -2
  35. data/lib/spark_connect/writer.rb +80 -10
  36. data/lib/spark_connect.rb +4 -0
  37. data/proto/spark/connect/base.proto +93 -1
  38. data/proto/spark/connect/catalog.proto +81 -0
  39. data/proto/spark/connect/commands.proto +7 -0
  40. data/proto/spark/connect/expressions.proto +28 -0
  41. data/proto/spark/connect/pipelines.proto +92 -5
  42. data/proto/spark/connect/relations.proto +71 -1
  43. data/proto/spark/connect/types.proto +19 -0
  44. metadata +10 -3
@@ -205,6 +205,11 @@ message Expression {
205
205
 
206
206
  SpecializedArray specialized_array = 25;
207
207
  Time time = 26;
208
+
209
+ // Nanosecond-capable timestamp literals (precision 7..9). NTZ and LTZ are distinct
210
+ // arms so the literal kind is self-describing.
211
+ TimestampNTZNanos timestamp_ntz_nanos = 29;
212
+ TimestampLTZNanos timestamp_ltz_nanos = 30;
208
213
  }
209
214
 
210
215
  // Reserved for Geometry and Geography.
@@ -289,6 +294,29 @@ message Expression {
289
294
  // The precision of this time, if omitted, uses the default value of MICROS_PRECISION.
290
295
  optional int32 precision = 2;
291
296
  }
297
+
298
+ // A TIMESTAMP_NTZ literal with nanosecond-capable precision. The physical value is carried
299
+ // as microseconds since the UNIX epoch plus the extra nanoseconds within that microsecond,
300
+ // because a single int64 of nanoseconds cannot span the supported year range.
301
+ message TimestampNTZNanos {
302
+ // Microseconds since the UNIX epoch (without timezone information).
303
+ int64 epoch_micros = 1;
304
+ // Additional nanoseconds within epoch_micros, in [0, 999].
305
+ int32 nanos_within_micro = 2;
306
+ // Number of fractional-second digits (7, 8, or 9). If omitted, defaults to 9 (nanoseconds).
307
+ optional int32 precision = 3;
308
+ }
309
+
310
+ // A TIMESTAMP_LTZ literal with nanosecond-capable precision. See TimestampNTZNanos for the
311
+ // rationale behind the two-component physical value.
312
+ message TimestampLTZNanos {
313
+ // Microseconds since the UNIX epoch.
314
+ int64 epoch_micros = 1;
315
+ // Additional nanoseconds within epoch_micros, in [0, 999].
316
+ int32 nanos_within_micro = 2;
317
+ // Number of fractional-second digits (7, 8, or 9). If omitted, defaults to 9 (nanoseconds).
318
+ optional int32 precision = 3;
319
+ }
292
320
  }
293
321
 
294
322
  // An unresolved attribute that is not explicitly bound to a specific column, but the column
@@ -22,6 +22,7 @@ package spark.connect;
22
22
  import "google/protobuf/any.proto";
23
23
  import "google/protobuf/timestamp.proto";
24
24
  import "spark/connect/common.proto";
25
+ import "spark/connect/expressions.proto";
25
26
  import "spark/connect/relations.proto";
26
27
  import "spark/connect/types.proto";
27
28
 
@@ -40,6 +41,8 @@ message PipelineCommand {
40
41
  DefineSqlGraphElements define_sql_graph_elements = 6;
41
42
  GetQueryFunctionExecutionSignalStream get_query_function_execution_signal_stream = 7;
42
43
  DefineFlowQueryFunctionResult define_flow_query_function_result = 8;
44
+ ExecuteOutputFlows execute_output_flows = 9;
45
+
43
46
  // Reserved field for protocol extensions.
44
47
  // Used to support forward-compatibility by carrying additional command types
45
48
  // that are not yet defined in this version of the proto. During planning, the
@@ -142,6 +145,7 @@ message PipelineCommand {
142
145
 
143
146
  oneof details {
144
147
  WriteRelationFlowDetails relation_flow_details = 7;
148
+ AutoCdcFlowDetails auto_cdc_flow_details = 10;
145
149
  google.protobuf.Any extension = 999;
146
150
  }
147
151
 
@@ -152,6 +156,55 @@ message PipelineCommand {
152
156
  optional spark.connect.Relation relation = 1;
153
157
  }
154
158
 
159
+ // Details for Auto CDC flows.
160
+ message AutoCdcFlowDetails {
161
+ // The name of the CDC source to stream from.
162
+ optional string source = 1;
163
+
164
+ // Column(s) that uniquely identify a row in source and target data.
165
+ repeated Expression keys = 2;
166
+
167
+ // Expression to order the source data.
168
+ optional Expression sequence_by = 3;
169
+
170
+ // Delete condition for the merged operation.
171
+ optional Expression apply_as_deletes = 6;
172
+
173
+ // Truncate condition for the merged operation.
174
+ optional Expression apply_as_truncates = 7;
175
+
176
+ // Columns included in the output table.
177
+ repeated Expression column_list = 8;
178
+
179
+ // Columns excluded from the output table.
180
+ repeated Expression except_column_list = 9;
181
+
182
+ // SCD Type for target table.
183
+ SCDType stored_as_scd_type = 10;
184
+
185
+ // SCD2 only. Columns whose value change opens a new history record. When empty, every
186
+ // eligible selected user column is tracked.
187
+ repeated Expression track_history_column_list = 11;
188
+
189
+ // SCD2 only. Columns excluded from history tracking. Mutually exclusive with
190
+ // track_history_column_list.
191
+ repeated Expression track_history_except_column_list = 12;
192
+
193
+ // Subset of columns to ignore null in updates.
194
+ repeated Expression ignore_null_updates_column_list = 14;
195
+
196
+ // Subset of columns excluded from ignoring null in updates.
197
+ repeated Expression ignore_null_updates_except_column_list = 15;
198
+
199
+ }
200
+
201
+ // SCD Type for Auto CDC target tables.
202
+ enum SCDType {
203
+ SCD_TYPE_UNSPECIFIED = 0;
204
+ SCD_TYPE_1 = 1;
205
+ SCD_TYPE_2 = 2;
206
+ }
207
+
155
208
  // If true, define the flow as a one-time flow, such as for backfill.
156
209
  // Set to true changes the flow in two ways:
157
210
  // - The flow is run one time by default. If the pipeline is ran with a full refresh,
@@ -165,6 +218,25 @@ message PipelineCommand {
165
218
  }
166
219
  }
167
220
 
221
+ // Request to execute all flows for a single output (dataset or sink) remotely.
222
+ message ExecuteOutputFlows {
223
+
224
+ // The output (table or materialized view or sink) definition.
225
+ optional DefineOutput define_output = 1;
226
+
227
+ // The flows to execute for this table.
228
+ repeated DefineFlow define_flows = 2;
229
+
230
+ // Whether to perform a full refresh instead of an incremental update.
231
+ optional bool full_refresh = 3;
232
+
233
+ // Storage location for pipeline checkpoints and metadata.
234
+ optional string storage = 4;
235
+
236
+ // Reserved field for protocol extensions.
237
+ repeated google.protobuf.Any extension = 999;
238
+ }
239
+
168
240
  // Resolves all datasets and flows and start a pipeline update. Should be called after all
169
241
  // graph elements are registered.
170
242
  message StartRun {
@@ -213,8 +285,13 @@ message PipelineCommand {
213
285
  // Request from the client to update the flow function evaluation result
214
286
  // for a previously un-analyzed flow.
215
287
  message DefineFlowQueryFunctionResult {
216
- // The fully qualified name of the flow being updated.
217
- optional string flow_name = 1;
288
+ // (Deprecated) The fully qualified name of the flow being updated.
289
+ //
290
+ // This field is deprecated since Spark 4.2+. Use flow_identifier field instead.
291
+ optional string flow_name = 1 [deprecated = true];
292
+
293
+ // The fully qualified identifier of the flow being updated.
294
+ optional ResolvedIdentifier flow_identifier = 4;
218
295
 
219
296
  // The ID of the graph this flow belongs to.
220
297
  optional string dataflow_graph_id = 2;
@@ -290,7 +367,13 @@ message SourceCodeLocation {
290
367
  // A signal from the server to the client to execute the query function for one or more flows, and
291
368
  // to register their results with the server.
292
369
  message PipelineQueryFunctionExecutionSignal {
293
- repeated string flow_names = 1;
370
+ // (Deprecated) The name of flows that are ready to be re-evaluated.
371
+ //
372
+ // This field is deprecated since Spark 4.2+. Use flow_identifiers field instead.
373
+ repeated string flow_names = 1 [deprecated = true];
374
+
375
+ // The identifier of flows that are ready to be re-evaluated
376
+ repeated ResolvedIdentifier flow_identifiers = 2;
294
377
  }
295
378
 
296
379
  // Metadata providing context about the pipeline during Spark Connect query analysis.
@@ -299,8 +382,12 @@ message PipelineAnalysisContext {
299
382
  optional string dataflow_graph_id = 1;
300
383
  // The path of the top-level pipeline file determined at runtime during pipeline initialization.
301
384
  optional string definition_path = 2;
302
- // The name of the Flow involved in this analysis
303
- optional string flow_name = 3;
385
+ // (Deprecated) The name of the Flow involved in this analysis
386
+ //
387
+ // This field is deprecated since Spark 4.2+. Use flow_identifier field instead.
388
+ optional string flow_name = 3 [deprecated = true];
389
+ // The identifier of the Flow involved in this analysis
390
+ optional ResolvedIdentifier flow_identifier = 4;
304
391
 
305
392
  // Reserved field for protocol extensions.
306
393
  repeated google.protobuf.Any extension = 999;
@@ -81,6 +81,9 @@ message Relation {
81
81
  UnresolvedTableValuedFunction unresolved_table_valued_function = 43;
82
82
  LateralJoin lateral_join = 44;
83
83
  ChunkedCachedLocalRelation chunked_cached_local_relation = 45;
84
+ RelationChanges relation_changes = 46;
85
+ NearestByJoin nearest_by_join = 47;
86
+ Zip zip = 48;
84
87
 
85
88
  // NA functions
86
89
  NAFill fill_na = 90;
@@ -256,9 +259,33 @@ message Read {
256
259
  //
257
260
  // This is only supported by the JDBC data source.
258
261
  repeated string predicates = 5;
262
+
263
+ // (Optional) A user-provided name for the streaming source.
264
+ // This name is used in checkpoint metadata and enables stable checkpoint locations
265
+ // for source evolution.
266
+ optional string source_name = 6;
259
267
  }
260
268
  }
261
269
 
270
+ // Reads Change Data Capture (CDC) changes for a named table.
271
+ //
272
+ // This corresponds to the `DataFrameReader.changes()` or `DataStreamReader.changes()` API.
273
+ // CDC-specific options (startingVersion, endingVersion, startingTimestamp, endingTimestamp,
274
+ // deduplicationMode, computeUpdates, etc.) are passed in the options map.
275
+ message RelationChanges {
276
+ // (Required) Unparsed identifier for the table.
277
+ string unparsed_identifier = 1;
278
+
279
+ // Options for the CDC query. The map key is case insensitive.
280
+ // Supported keys include: startingVersion, endingVersion, startingTimestamp,
281
+ // endingTimestamp, deduplicationMode, computeUpdates, startingBoundInclusive,
282
+ // endingBoundInclusive.
283
+ map<string, string> options = 2;
284
+
285
+ // (Optional) Indicates if this is a streaming CDC read.
286
+ bool is_streaming = 3;
287
+ }
288
+
262
289
  // Projection of a bag of expressions for a given input relation.
263
290
  //
264
291
  // The input relation must be specified.
@@ -1184,12 +1211,13 @@ message Parse {
1184
1211
  // (Optional) DataType representing the schema. If not set, Spark will infer the schema.
1185
1212
  optional DataType schema = 3;
1186
1213
 
1187
- // Options for the csv/json parser. The map key is case insensitive.
1214
+ // Options for the csv/json/xml parser. The map key is case insensitive.
1188
1215
  map<string, string> options = 4;
1189
1216
  enum ParseFormat {
1190
1217
  PARSE_FORMAT_UNSPECIFIED = 0;
1191
1218
  PARSE_FORMAT_CSV = 1;
1192
1219
  PARSE_FORMAT_JSON = 2;
1220
+ PARSE_FORMAT_XML = 3;
1193
1221
  }
1194
1222
  }
1195
1223
 
@@ -1250,3 +1278,45 @@ message LateralJoin {
1250
1278
  // (Required) The join type.
1251
1279
  Join.JoinType join_type = 4;
1252
1280
  }
1281
+
1282
+ // Relation of type [[NearestByJoin]].
1283
+ //
1284
+ // For each row on the left side, returns up to `num_results` rows from the right side ranked
1285
+ // by `ranking_expression`.
1286
+ message NearestByJoin {
1287
+ // (Required) Left (query) input relation.
1288
+ Relation left = 1;
1289
+
1290
+ // (Required) Right (base) input relation.
1291
+ Relation right = 2;
1292
+
1293
+ // (Required) Scalar expression used to rank candidate rows on the right side.
1294
+ Expression ranking_expression = 3;
1295
+
1296
+ // (Required) Maximum number of matches per left row. Must be between 1 and 100000.
1297
+ int32 num_results = 4;
1298
+
1299
+ // The following three fields use `string` (not typed enums) for parity with `AsOfJoin`,
1300
+ // which models analogous fields the same way. Validation happens server-side at planning time.
1301
+
1302
+ // (Required) The join type. Must be one of: "inner", "leftouter".
1303
+ string join_type = 5;
1304
+
1305
+ // (Required) Search algorithm contract. Must be one of: "approx", "exact".
1306
+ string mode = 6;
1307
+
1308
+ // (Required) Ranking direction. Must be one of: "distance", "similarity".
1309
+ string direction = 7;
1310
+ }
1311
+
1312
+ // Relation of type [[Zip]].
1313
+ //
1314
+ // Combines the columns of two DataFrames side-by-side. Both DataFrames must produce the same
1315
+ // canonicalized plan after stripping outer Project chains.
1316
+ message Zip {
1317
+ // (Required) Left input relation.
1318
+ Relation left = 1;
1319
+
1320
+ // (Required) Right input relation.
1321
+ Relation right = 2;
1322
+ }
@@ -76,6 +76,11 @@ message DataType {
76
76
  Unparsed unparsed = 24;
77
77
 
78
78
  Time time = 28;
79
+
80
+ // Nanosecond-capable timestamp types (precision 7..9). NTZ and LTZ are distinct kinds
81
+ // even though their physical value is identical, mirroring timestamp vs timestamp_ntz.
82
+ TimestampNTZNanos timestamp_ntz_nanos = 29;
83
+ TimestampLTZNanos timestamp_ltz_nanos = 30;
79
84
  }
80
85
 
81
86
  message Boolean {
@@ -136,6 +141,20 @@ message DataType {
136
141
  uint32 type_variation_reference = 2;
137
142
  }
138
143
 
144
+ // Timestamp without time zone with nanosecond-capable fractional-second precision.
145
+ message TimestampNTZNanos {
146
+ // Number of fractional-second digits. Valid values are 7, 8, and 9. If omitted, defaults to 9.
147
+ optional int32 precision = 1;
148
+ uint32 type_variation_reference = 2;
149
+ }
150
+
151
+ // Timestamp with local time zone with nanosecond-capable fractional-second precision.
152
+ message TimestampLTZNanos {
153
+ // Number of fractional-second digits. Valid values are 7, 8, and 9. If omitted, defaults to 9.
154
+ optional int32 precision = 1;
155
+ uint32 type_variation_reference = 2;
156
+ }
157
+
139
158
  message CalendarInterval {
140
159
  uint32 type_variation_reference = 1;
141
160
  }
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spark-connect
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hyukjin Kwon
8
+ autorequire:
8
9
  bindir: bin
9
10
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
11
+ date: 2026-11-04 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: google-protobuf
@@ -85,6 +86,7 @@ files:
85
86
  - lib/spark_connect/errors.rb
86
87
  - lib/spark_connect/functions.rb
87
88
  - lib/spark_connect/grouped_data.rb
89
+ - lib/spark_connect/merge.rb
88
90
  - lib/spark_connect/na_functions.rb
89
91
  - lib/spark_connect/observation.rb
90
92
  - lib/spark_connect/pipelines.rb
@@ -105,7 +107,10 @@ files:
105
107
  - lib/spark_connect/row.rb
106
108
  - lib/spark_connect/session.rb
107
109
  - lib/spark_connect/stat_functions.rb
110
+ - lib/spark_connect/storage_level.rb
108
111
  - lib/spark_connect/streaming.rb
112
+ - lib/spark_connect/table_arg.rb
113
+ - lib/spark_connect/tvf.rb
109
114
  - lib/spark_connect/types.rb
110
115
  - lib/spark_connect/version.rb
111
116
  - lib/spark_connect/window.rb
@@ -129,6 +134,7 @@ metadata:
129
134
  documentation_uri: https://hyukjinkwon.github.io/spark-connect-ruby/
130
135
  bug_tracker_uri: https://github.com/HyukjinKwon/spark-connect-ruby/issues
131
136
  changelog_uri: https://github.com/HyukjinKwon/spark-connect-ruby/blob/main/CHANGELOG.md
137
+ post_install_message:
132
138
  rdoc_options: []
133
139
  require_paths:
134
140
  - lib
@@ -143,7 +149,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
149
  - !ruby/object:Gem::Version
144
150
  version: '0'
145
151
  requirements: []
146
- rubygems_version: 4.0.11
152
+ rubygems_version: 3.5.22
153
+ signing_key:
147
154
  specification_version: 4
148
155
  summary: A pure-Ruby client for Apache Spark Connect.
149
156
  test_files: []