You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Hyukjin Kwon (JIRA)" <ji...@apache.org> on 2019/07/15 06:07:00 UTC

[jira] [Commented] (SPARK-28368) Row.getAs() return different values in scala and java

    [ https://issues.apache.org/jira/browse/SPARK-28368?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16884874#comment-16884874 ] 

Hyukjin Kwon commented on SPARK-28368:
--------------------------------------

Scala types like {{Int}} are actually primitive types whereas you're using boxed {{Integer}} where {{null}} is legitimate. Looks not an issue to me.

> Row.getAs() return different values in scala and java
> -----------------------------------------------------
>
>                 Key: SPARK-28368
>                 URL: https://issues.apache.org/jira/browse/SPARK-28368
>             Project: Spark
>          Issue Type: Bug
>          Components: Java API
>    Affects Versions: 2.4.3
>            Reporter: Kideok Kim
>            Priority: Major
>
> *description*
>  * About [org.apache.spark.sql.Row.getAs()|https://spark.apache.org/docs/2.4.3/api/java/org/apache/spark/sql/Row.html#getAs-java.lang.String-], It doesn't return zero value in java even if I used primitive type null value. (scala return zero value.) Here is an example with spark ver 2.4.3.
> {code:java}
> @Test
> public void testIntegerTypeNull() {
>     StructType schema = createStructType(Arrays.asList(createStructField("test", IntegerType, true)));
>     Object[] values = new Object[1];
>     values[0] = null;
>     Row row = new GenericRowWithSchema(values, schema);
>     Integer result = row.getAs("test");
>     System.out.println(result); // result = null
> }{code}
>  * This problem is shown by not only Integer type, but also all primitive types of java like double, long and so on. I really appreciate if you confirm whether it is a normal or not.



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org