HeartSaVioR commented on a change in pull request #23854: [SPARK-22000][SQL]
Use String.valueOf to assign value to String type of field in Java Bean
URL: https://github.com/apache/spark/pull/23854#discussion_r259113471
##########
File path:
sql/core/src/test/java/test/org/apache/spark/sql/JavaBeanDeserializationSuite.java
##########
@@ -252,4 +325,116 @@ public String toString() {
return String.format("[%d,%d]", startTime, endTime);
}
}
+
+ public static class RecordSpark22000 {
+ private String shortField;
+ private String intField;
+ private String longField;
+ private String floatField;
+ private String doubleField;
+ private String stringField;
+ private String booleanField;
+ private String timestampField;
+
+ public RecordSpark22000() { }
+
+ public String getShortField() {
+ return shortField;
+ }
+
+ public void setShortField(String shortField) {
+ this.shortField = shortField;
+ }
+
+ public String getIntField() {
+ return intField;
+ }
+
+ public void setIntField(String intField) {
+ this.intField = intField;
+ }
+
+ public String getLongField() {
+ return longField;
+ }
+
+ public void setLongField(String longField) {
+ this.longField = longField;
+ }
+
+ public String getFloatField() {
+ return floatField;
+ }
+
+ public void setFloatField(String floatField) {
+ this.floatField = floatField;
+ }
+
+ public String getDoubleField() {
+ return doubleField;
+ }
+
+ public void setDoubleField(String doubleField) {
+ this.doubleField = doubleField;
+ }
+
+ public String getStringField() {
+ return stringField;
+ }
+
+ public void setStringField(String stringField) {
+ this.stringField = stringField;
+ }
+
+ public String getBooleanField() {
+ return booleanField;
+ }
+
+ public void setBooleanField(String booleanField) {
+ this.booleanField = booleanField;
+ }
+
+ public String getTimestampField() {
+ return timestampField;
+ }
+
+ public void setTimestampField(String timestampField) {
+ this.timestampField = timestampField;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ RecordSpark22000 that = (RecordSpark22000) o;
+ return Objects.equals(shortField, that.shortField) &&
+ Objects.equals(intField, that.intField) &&
+ Objects.equals(longField, that.longField) &&
+ Objects.equals(floatField, that.floatField) &&
+ Objects.equals(doubleField, that.doubleField) &&
+ Objects.equals(stringField, that.stringField) &&
+ Objects.equals(booleanField, that.booleanField) &&
+ Objects.equals(timestampField, that.timestampField);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(shortField, intField, longField, floatField,
doubleField, stringField,
+ booleanField, timestampField);
+ }
+
+ @Override
+ public String toString() {
Review comment:
It will help to compare expected and actual when test fails. Otherwise they
would've seen as `Object.toString()` does and it doesn't provide any
information why they are not equal.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]