Skip to content

Commit 38531de

Browse files
authored
Column.ToString override for returning the column name (#624)
1 parent 61cfeb5 commit 38531de

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/csharp/Microsoft.Spark.E2ETest/IpcTests/Sql/ColumnTests.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,10 @@ public void TestSignaturesV2_3_X()
137137
Assert.IsType<Column>(col1.BitwiseXOR(col2));
138138

139139
Assert.IsType<Column>(col1.Over(PartitionBy(col1)));
140-
Assert.IsType<Column>(col1.Over());
140+
Assert.IsType<Column>(col1.Over());
141+
142+
Assert.Equal("col1", col1.ToString());
143+
Assert.Equal("col2", col2.ToString());
141144
}
142145

143146
}

src/csharp/Microsoft.Spark/Sql/Column.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -886,6 +886,12 @@ public override bool Equals(object obj)
886886
/// <returns>Hash code for this object</returns>
887887
public override int GetHashCode() => _jvmObject.GetHashCode();
888888

889+
/// <summary>
890+
/// Invoke the toString method of the column instance
891+
/// </summary>
892+
/// <returns>Column name of this column</returns>
893+
public override string ToString() => (string)_jvmObject.Invoke("toString");
894+
889895
/// <summary>
890896
/// Invokes a method under "org.apache.spark.sql.functions" with the given column.
891897
/// </summary>

0 commit comments

Comments
 (0)