Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id C67CF200CD7 for ; Tue, 18 Jul 2017 07:28:10 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id C310C16652B; Tue, 18 Jul 2017 05:28:10 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 171FE166529 for ; Tue, 18 Jul 2017 07:28:09 +0200 (CEST) Received: (qmail 87160 invoked by uid 500); 18 Jul 2017 05:28:08 -0000 Mailing-List: contact issues-help@spark.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list issues@spark.apache.org Received: (qmail 87150 invoked by uid 99); 18 Jul 2017 05:28:08 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 18 Jul 2017 05:28:08 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 3D0E4C039F for ; Tue, 18 Jul 2017 05:28:08 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -100.002 X-Spam-Level: X-Spam-Status: No, score=-100.002 tagged_above=-999 required=6.31 tests=[RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id RFqCAzYsELWj for ; Tue, 18 Jul 2017 05:28:07 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id C92805F613 for ; Tue, 18 Jul 2017 05:28:06 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id A0006E05BF for ; Tue, 18 Jul 2017 05:28:05 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 30FC82475C for ; Tue, 18 Jul 2017 05:28:03 +0000 (UTC) Date: Tue, 18 Jul 2017 05:28:03 +0000 (UTC) From: "Felix Cheung (JIRA)" To: issues@spark.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (SPARK-21450) List of NA is flattened inside a SparkR struct type MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Tue, 18 Jul 2017 05:28:11 -0000 [ https://issues.apache.org/jira/browse/SPARK-21450?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16091132#comment-16091132 ] Felix Cheung commented on SPARK-21450: -------------------------------------- [~hyukjin.kwon] If you follow the code in test_sparkSQL.R, {code} df <- as.DataFrame(list(list("col" = "{\"date\":\"21/10/2014\"}"))) schema2 <- structType(structField("date", "date")) s <- collect(select(df, from_json(df$col, schema2))) expect_equal(s[[1]][[1]], NA) s <- collect(select(df, from_json(df$col, schema2, dateFormat = "dd/MM/yyyy"))) {code} Both lines should be using schema2 - not schema. schema is actually defined as {code} schema <- structType(structField("age", "integer"), structField("height", "double")) {code} which doesn't match the json blob. Is this a copy/paste error in this JIRA? could you check? In any case, I wonder - didn't get to test it in Scala - if the different result is cause by unparseable json blob because schema/format passed in. The logi NA would be a null in Scala > List of NA is flattened inside a SparkR struct type > --------------------------------------------------- > > Key: SPARK-21450 > URL: https://issues.apache.org/jira/browse/SPARK-21450 > Project: Spark > Issue Type: Bug > Components: SparkR > Affects Versions: 2.2.0 > Reporter: Hossein Falaki > > Consider the following two cases copied from {{test_sparkSQL.R}}: > {code} > df <- as.DataFrame(list(list("col" = "{\"date\":\"21/10/2014\"}"))) > schema <- structType(structField("date", "date")) > s1 <- collect(select(df, from_json(df$col, schema))) > s2 <- collect(select(df, from_json(df$col, schema2, dateFormat = "dd/MM/yyyy"))) > {code} > If you inspect s1 using {{str(s1)}} you will find: > {code} > 'data.frame': 2 obs. of 1 variable: > $ jsontostructs(col):List of 2 > ..$ : logi NA > {code} > But for s2, running {{str(s2)}} results in: > {code} > 'data.frame': 2 obs. of 1 variable: > $ jsontostructs(col):List of 2 > ..$ :List of 1 > .. ..$ date: Date, format: "2014-10-21" > .. ..- attr(*, "class")= chr "struct" > {code} > I assume this is not intentional and is just a subtle bug. Do you think otherwise? [~shivaram] and [~felixcheung] -- This message was sent by Atlassian JIRA (v6.4.14#64029) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org For additional commands, e-mail: issues-help@spark.apache.org