Skip to content

Commit fe03c74

Browse files
authored
Support for Delta Lake 0.8.0 (#823)
1 parent f50ea5f commit fe03c74

File tree

4 files changed

+24
-4
lines changed

4 files changed

+24
-4
lines changed

src/csharp/Extensions/Microsoft.Spark.Extensions.Delta.E2ETest/DeltaFixture.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,16 @@ public DeltaFixture()
1919
string deltaVersion = sparkVersion.Major switch
2020
{
2121
2 => "delta-core_2.11:0.6.1",
22-
3 => "delta-core_2.12:0.7.0",
22+
3 => "delta-core_2.12:0.8.0",
2323
_ => throw new NotSupportedException($"Spark {sparkVersion} not supported.")
2424
};
2525

2626
(string, string)[] conf = new[]
2727
{
2828
("spark.databricks.delta.snapshotPartitions", "2"),
29-
("spark.sql.sources.parallelPartitionDiscovery.parallelism", "5")
29+
("spark.sql.sources.parallelPartitionDiscovery.parallelism", "5"),
30+
// Set the writer protocol version for testing UpgradeTableProtocol().
31+
("spark.databricks.delta.minWriterVersion", "2")
3032
};
3133

3234
(string, string)[] extraConf = sparkVersion.Major switch

src/csharp/Extensions/Microsoft.Spark.Extensions.Delta.E2ETest/DeltaTableTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using System.Collections.Generic;
77
using System.IO;
88
using System.Linq;
9-
using Microsoft.Spark.E2ETest;
109
using Microsoft.Spark.E2ETest.Utils;
1110
using Microsoft.Spark.Extensions.Delta.Tables;
1211
using Microsoft.Spark.Sql;
@@ -337,7 +336,9 @@ public void TestSignaturesV3_0_X()
337336
_spark.Range(15).Write().Format("delta").SaveAsTable(tableName);
338337

339338
Assert.IsType<DeltaTable>(DeltaTable.ForName(tableName));
340-
Assert.IsType<DeltaTable>(DeltaTable.ForName(_spark, tableName));
339+
DeltaTable table = DeltaTable.ForName(_spark, tableName);
340+
341+
table.UpgradeTableProtocol(1, 3);
341342
}
342343

343344
/// <summary>

src/csharp/Extensions/Microsoft.Spark.Extensions.Delta/DeltaLakeVersions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ internal static class DeltaLakeVersions
1414
internal const string V0_6_0 = "0.6.0";
1515
internal const string V0_6_1 = "0.6.1";
1616
internal const string V0_7_0 = "0.7.0";
17+
internal const string V0_8_0 = "0.8.0";
1718
}
1819
}

src/csharp/Extensions/Microsoft.Spark.Extensions.Delta/Tables/DeltaTable.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,5 +501,21 @@ public DeltaMergeBuilder Merge(DataFrame source, Column condition) =>
501501
"merge",
502502
source,
503503
condition));
504+
505+
/// <summary>
506+
/// Updates the protocol version of the table to leverage new features. Upgrading the reader version
507+
/// will prevent all clients that have an older version of Delta Lake from accessing this table.
508+
/// Upgrading the writer version will prevent older versions of Delta Lake to write to this table.
509+
/// The reader or writer version cannot be downgraded.
510+
///
511+
/// See online documentation and Delta's protocol specification at
512+
/// <see href="https://github.com/delta-io/delta/blob/master/PROTOCOL.md">PROTOCOL.md</see> for more
513+
/// details.
514+
/// </summary>
515+
/// <param name="readerVersion">Version of the Delta read protocol.</param>
516+
/// <param name="writerVersion">Version of the Delta write protocol.</param>
517+
[DeltaLakeSince(DeltaLakeVersions.V0_8_0)]
518+
public void UpgradeTableProtocol(int readerVersion, int writerVersion) =>
519+
_jvmObject.Invoke("upgradeTableProtocol", readerVersion, writerVersion);
504520
}
505521
}

0 commit comments

Comments
 (0)