@@ -21,16 +21,14 @@ namespace Microsoft.Spark.Extensions.Delta.Tables
2121 [ DeltaLakeSince ( DeltaLakeVersions . V0_3_0 ) ]
2222 public class DeltaTable : IJvmObjectReferenceProvider
2323 {
24- private readonly JvmObjectReference _jvmObject ;
25-
2624 private static readonly string s_deltaTableClassName = "io.delta.tables.DeltaTable" ;
2725
2826 internal DeltaTable ( JvmObjectReference jvmObject )
2927 {
30- _jvmObject = jvmObject ;
28+ Reference = jvmObject ;
3129 }
3230
33- JvmObjectReference IJvmObjectReferenceProvider . Reference => _jvmObject ;
31+ public JvmObjectReference Reference { get ; private set ; }
3432
3533 /// <summary>
3634 /// Create a DeltaTable from the given parquet table and partition schema.
@@ -243,7 +241,7 @@ public static bool IsDeltaTable(string identifier) =>
243241 /// <returns>Aliased DeltaTable.</returns>
244242 [ DeltaLakeSince ( DeltaLakeVersions . V0_3_0 ) ]
245243 public DeltaTable As ( string alias ) =>
246- new DeltaTable ( ( JvmObjectReference ) _jvmObject . Invoke ( "as" , alias ) ) ;
244+ new DeltaTable ( ( JvmObjectReference ) Reference . Invoke ( "as" , alias ) ) ;
247245
248246 /// <summary>
249247 /// Apply an alias to the DeltaTable. This is similar to <c>Dataset.as(alias)</c>
@@ -253,14 +251,14 @@ public DeltaTable As(string alias) =>
253251 /// <returns>Aliased DeltaTable.</returns>
254252 [ DeltaLakeSince ( DeltaLakeVersions . V0_3_0 ) ]
255253 public DeltaTable Alias ( string alias ) =>
256- new DeltaTable ( ( JvmObjectReference ) _jvmObject . Invoke ( "alias" , alias ) ) ;
254+ new DeltaTable ( ( JvmObjectReference ) Reference . Invoke ( "alias" , alias ) ) ;
257255
258256 /// <summary>
259257 /// Get a DataFrame (that is, Dataset[Row]) representation of this Delta table.
260258 /// </summary>
261259 /// <returns>DataFrame representation of Delta table.</returns>
262260 [ DeltaLakeSince ( DeltaLakeVersions . V0_3_0 ) ]
263- public DataFrame ToDF ( ) => new DataFrame ( ( JvmObjectReference ) _jvmObject . Invoke ( "toDF" ) ) ;
261+ public DataFrame ToDF ( ) => new DataFrame ( ( JvmObjectReference ) Reference . Invoke ( "toDF" ) ) ;
264262
265263 /// <summary>
266264 /// Recursively delete files and directories in the table that are not needed by the table
@@ -273,7 +271,7 @@ public DeltaTable Alias(string alias) =>
273271 /// <returns>Vacuumed DataFrame.</returns>
274272 [ DeltaLakeSince ( DeltaLakeVersions . V0_3_0 ) ]
275273 public DataFrame Vacuum ( double retentionHours ) =>
276- new DataFrame ( ( JvmObjectReference ) _jvmObject . Invoke ( "vacuum" , retentionHours ) ) ;
274+ new DataFrame ( ( JvmObjectReference ) Reference . Invoke ( "vacuum" , retentionHours ) ) ;
277275
278276 /// <summary>
279277 /// Recursively delete files and directories in the table that are not needed by the table
@@ -285,7 +283,7 @@ public DataFrame Vacuum(double retentionHours) =>
285283 /// <returns>Vacuumed DataFrame.</returns>
286284 [ DeltaLakeSince ( DeltaLakeVersions . V0_3_0 ) ]
287285 public DataFrame Vacuum ( ) =>
288- new DataFrame ( ( JvmObjectReference ) _jvmObject . Invoke ( "vacuum" ) ) ;
286+ new DataFrame ( ( JvmObjectReference ) Reference . Invoke ( "vacuum" ) ) ;
289287
290288 /// <summary>
291289 /// Get the information of the latest <c>limit</c> commits on this table as a Spark
@@ -295,7 +293,7 @@ public DataFrame Vacuum() =>
295293 /// <returns>History DataFrame.</returns>
296294 [ DeltaLakeSince ( DeltaLakeVersions . V0_3_0 ) ]
297295 public DataFrame History ( int limit ) =>
298- new DataFrame ( ( JvmObjectReference ) _jvmObject . Invoke ( "history" , limit ) ) ;
296+ new DataFrame ( ( JvmObjectReference ) Reference . Invoke ( "history" , limit ) ) ;
299297
300298 /// <summary>
301299 /// Get the information available commits on this table as a Spark DataFrame. The
@@ -304,7 +302,7 @@ public DataFrame History(int limit) =>
304302 /// <returns>History DataFrame</returns>
305303 [ DeltaLakeSince ( DeltaLakeVersions . V0_3_0 ) ]
306304 public DataFrame History ( ) =>
307- new DataFrame ( ( JvmObjectReference ) _jvmObject . Invoke ( "history" ) ) ;
305+ new DataFrame ( ( JvmObjectReference ) Reference . Invoke ( "history" ) ) ;
308306
309307 /// <summary>
310308 /// Generate a manifest for the given Delta Table.
@@ -315,27 +313,27 @@ public DataFrame History() =>
315313 /// for Presto and Athena read support.
316314 /// See the online documentation for more information.</param>
317315 [ DeltaLakeSince ( DeltaLakeVersions . V0_5_0 ) ]
318- public void Generate ( string mode ) => _jvmObject . Invoke ( "generate" , mode ) ;
316+ public void Generate ( string mode ) => Reference . Invoke ( "generate" , mode ) ;
319317
320318 /// <summary>
321319 /// Delete data from the table that match the given <c>condition</c>.
322320 /// </summary>
323321 /// <param name="condition">Boolean SQL expression.</param>
324322 [ DeltaLakeSince ( DeltaLakeVersions . V0_3_0 ) ]
325- public void Delete ( string condition ) => _jvmObject . Invoke ( "delete" , condition ) ;
323+ public void Delete ( string condition ) => Reference . Invoke ( "delete" , condition ) ;
326324
327325 /// <summary>
328326 /// Delete data from the table that match the given <c>condition</c>.
329327 /// </summary>
330328 /// <param name="condition">Boolean SQL expression.</param>
331329 [ DeltaLakeSince ( DeltaLakeVersions . V0_3_0 ) ]
332- public void Delete ( Column condition ) => _jvmObject . Invoke ( "delete" , condition ) ;
330+ public void Delete ( Column condition ) => Reference . Invoke ( "delete" , condition ) ;
333331
334332 /// <summary>
335333 /// Delete data from the table.
336334 /// </summary>
337335 [ DeltaLakeSince ( DeltaLakeVersions . V0_3_0 ) ]
338- public void Delete ( ) => _jvmObject . Invoke ( "delete" ) ;
336+ public void Delete ( ) => Reference . Invoke ( "delete" ) ;
339337
340338 /// <summary>
341339 /// Update rows in the table based on the rules defined by <c>set</c>.
@@ -351,7 +349,7 @@ public DataFrame History() =>
351349 /// <param name="set">Pules to update a row as a Scala map between target column names
352350 /// and corresponding update expressions as Column objects.</param>
353351 [ DeltaLakeSince ( DeltaLakeVersions . V0_3_0 ) ]
354- public void Update ( Dictionary < string , Column > set ) => _jvmObject . Invoke ( "update" , set ) ;
352+ public void Update ( Dictionary < string , Column > set ) => Reference . Invoke ( "update" , set ) ;
355353
356354 /// <summary>
357355 /// Update data from the table on the rows that match the given <c>condition</c> based on
@@ -373,7 +371,7 @@ public DataFrame History() =>
373371 /// corresponding update expressions as Column objects.</param>
374372 [ DeltaLakeSince ( DeltaLakeVersions . V0_3_0 ) ]
375373 public void Update ( Column condition , Dictionary < string , Column > set ) =>
376- _jvmObject . Invoke ( "update" , condition , set ) ;
374+ Reference . Invoke ( "update" , condition , set ) ;
377375
378376 /// <summary>
379377 /// Update rows in the table based on the rules defined by <c>set</c>.
@@ -391,7 +389,7 @@ public void Update(Column condition, Dictionary<string, Column> set) =>
391389 /// corresponding update expressions as SQL formatted strings.</param>
392390 [ DeltaLakeSince ( DeltaLakeVersions . V0_3_0 ) ]
393391 public void UpdateExpr ( Dictionary < string , string > set ) =>
394- _jvmObject . Invoke ( "updateExpr" , set ) ;
392+ Reference . Invoke ( "updateExpr" , set ) ;
395393
396394 /// <summary>
397395 /// Update data from the table on the rows that match the given <c>condition</c>, which
@@ -413,7 +411,7 @@ public void UpdateExpr(Dictionary<string, string> set) =>
413411 /// corresponding update expressions as SQL formatted strings.</param>
414412 [ DeltaLakeSince ( DeltaLakeVersions . V0_3_0 ) ]
415413 public void UpdateExpr ( string condition , Dictionary < string , string > set ) =>
416- _jvmObject . Invoke ( "updateExpr" , condition , set ) ;
414+ Reference . Invoke ( "updateExpr" , condition , set ) ;
417415
418416 /// <summary>
419417 /// Merge data from the <c>source</c> DataFrame based on the given merge <c>condition</c>.
@@ -455,7 +453,7 @@ public void UpdateExpr(string condition, Dictionary<string, string> set) =>
455453 [ DeltaLakeSince ( DeltaLakeVersions . V0_3_0 ) ]
456454 public DeltaMergeBuilder Merge ( DataFrame source , string condition ) =>
457455 new DeltaMergeBuilder (
458- ( JvmObjectReference ) _jvmObject . Invoke (
456+ ( JvmObjectReference ) Reference . Invoke (
459457 "merge" ,
460458 source ,
461459 condition ) ) ;
@@ -497,7 +495,7 @@ public DeltaMergeBuilder Merge(DataFrame source, string condition) =>
497495 [ DeltaLakeSince ( DeltaLakeVersions . V0_3_0 ) ]
498496 public DeltaMergeBuilder Merge ( DataFrame source , Column condition ) =>
499497 new DeltaMergeBuilder (
500- ( JvmObjectReference ) _jvmObject . Invoke (
498+ ( JvmObjectReference ) Reference . Invoke (
501499 "merge" ,
502500 source ,
503501 condition ) ) ;
@@ -516,6 +514,6 @@ public DeltaMergeBuilder Merge(DataFrame source, Column condition) =>
516514 /// <param name="writerVersion">Version of the Delta write protocol.</param>
517515 [ DeltaLakeSince ( DeltaLakeVersions . V0_8_0 ) ]
518516 public void UpgradeTableProtocol ( int readerVersion , int writerVersion ) =>
519- _jvmObject . Invoke ( "upgradeTableProtocol" , readerVersion , writerVersion ) ;
517+ Reference . Invoke ( "upgradeTableProtocol" , readerVersion , writerVersion ) ;
520518 }
521519}
0 commit comments