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 057BC200CED for ; Fri, 14 Jul 2017 06:35:09 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 02C8716D440; Fri, 14 Jul 2017 04:35:09 +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 27F4C16D43F for ; Fri, 14 Jul 2017 06:35:07 +0200 (CEST) Received: (qmail 24394 invoked by uid 500); 14 Jul 2017 04:35:07 -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 24382 invoked by uid 99); 14 Jul 2017 04:35:06 -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; Fri, 14 Jul 2017 04:35:06 +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 5FBABC002B for ; Fri, 14 Jul 2017 04:35:06 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -99.202 X-Spam-Level: X-Spam-Status: No, score=-99.202 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id JlV5GZDslYeA for ; Fri, 14 Jul 2017 04:35:04 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 769FC5F4A7 for ; Fri, 14 Jul 2017 04:35:04 +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 760EFE0732 for ; Fri, 14 Jul 2017 04:35:03 +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 3231B24742 for ; Fri, 14 Jul 2017 04:35:02 +0000 (UTC) Date: Fri, 14 Jul 2017 04:35:02 +0000 (UTC) From: "Hyukjin Kwon (JIRA)" To: issues@spark.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (SPARK-21413) Multiple projections with CASE WHEN fails to run generated codes MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Fri, 14 Jul 2017 04:35:09 -0000 [ https://issues.apache.org/jira/browse/SPARK-21413?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Hyukjin Kwon updated SPARK-21413: --------------------------------- Description: Scala codes to reproduce are as below: {code} import org.apache.spark.sql.functions._ import org.apache.spark.sql.types._ import org.apache.spark.sql.Row val schema = StructType(StructField("fieldA", IntegerType) :: Nil) var df = spark.createDataFrame(spark.sparkContext.parallelize(Seq(Row(1))), schema) df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) df.show() {code} Calling {{explain()}} on the dataframe in the former case shows a huge case-when projection and {{show()}} fails with the exception as below: {code} ... Caused by: org.codehaus.janino.JaninoRuntimeException: Code of method "apply_0$(Lorg/apache/spark/sql/catalyst/expressions/GeneratedClass$SpecificUnsafeProjection;Lorg/apache/spark/sql/catalyst/InternalRow;)V" of class "org.apache.spark.sql.catalyst.expressions.GeneratedClass$SpecificUnsafeProjection" grows beyond 64 KB at org.codehaus.janino.CodeContext.makeSpace(CodeContext.java:949) at org.codehaus.janino.CodeContext.write(CodeContext.java:839) at org.codehaus.janino.UnitCompiler.writeOpcode(UnitCompiler.java:11081) at org.codehaus.janino.UnitCompiler.pushConstant(UnitCompiler.java:9674) at org.codehaus.janino.UnitCompiler.compileGet2(UnitCompiler.java:4911) at org.codehaus.janino.UnitCompiler.access$7700(UnitCompiler.java:206) at org.codehaus.janino.UnitCompiler$12.visitIntegerLiteral(UnitCompiler.java:3776) ... {code} Note that, I could not reproduce this with local relation (this one appears by {{ConvertToLocalRelation}}). {code} import org.apache.spark.sql.functions._ var df = Seq(1).toDF("fieldA") df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) df.show() {code} was: Scala codes to reproduce are as below: {code} import org.apache.spark.sql.functions._ import org.apache.spark.sql.types._ import org.apache.spark.sql.Row val schema = StructType(StructField("fieldA", IntegerType) :: Nil) var df = spark.createDataFrame(spark.sparkContext.parallelize(Seq(Row(1))), schema) df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) df.show() {code} Calling {{explain()}} on the dataframe in the former case shows a huge case-when projection and {{show()}} fails with the exception as below: {code} ... Caused by: org.codehaus.janino.JaninoRuntimeException: Code of method "apply_0$(Lorg/apache/spark/sql/catalyst/expressions/GeneratedClass$SpecificUnsafeProjection;Lorg/apache/spark/sql/catalyst/InternalRow;)V" of class "org.apache.spark.sql.catalyst.expressions.GeneratedClass$SpecificUnsafeProjection" grows beyond 64 KB at org.codehaus.janino.CodeContext.makeSpace(CodeContext.java:949) at org.codehaus.janino.CodeContext.write(CodeContext.java:839) at org.codehaus.janino.UnitCompiler.writeOpcode(UnitCompiler.java:11081) at org.codehaus.janino.UnitCompiler.pushConstant(UnitCompiler.java:9674) at org.codehaus.janino.UnitCompiler.compileGet2(UnitCompiler.java:4911) at org.codehaus.janino.UnitCompiler.access$7700(UnitCompiler.java:206) at org.codehaus.janino.UnitCompiler$12.visitIntegerLiteral(UnitCompiler.java:3776) ... {code} Note that, I could not reproduce this with local relation. {code} import org.apache.spark.sql.functions._ var df = Seq(1).toDF("fieldA") df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) df.show() {code} > Multiple projections with CASE WHEN fails to run generated codes > ---------------------------------------------------------------- > > Key: SPARK-21413 > URL: https://issues.apache.org/jira/browse/SPARK-21413 > Project: Spark > Issue Type: Bug > Components: SQL > Affects Versions: 2.3.0 > Reporter: Hyukjin Kwon > > Scala codes to reproduce are as below: > {code} > import org.apache.spark.sql.functions._ > import org.apache.spark.sql.types._ > import org.apache.spark.sql.Row > val schema = StructType(StructField("fieldA", IntegerType) :: Nil) > var df = spark.createDataFrame(spark.sparkContext.parallelize(Seq(Row(1))), schema) > df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) > df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) > df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) > df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) > df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) > df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) > df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) > df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) > df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) > df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) > df.show() > {code} > Calling {{explain()}} on the dataframe in the former case shows a huge case-when projection and {{show()}} fails with the exception as below: > {code} > ... > Caused by: org.codehaus.janino.JaninoRuntimeException: Code of method "apply_0$(Lorg/apache/spark/sql/catalyst/expressions/GeneratedClass$SpecificUnsafeProjection;Lorg/apache/spark/sql/catalyst/InternalRow;)V" of class "org.apache.spark.sql.catalyst.expressions.GeneratedClass$SpecificUnsafeProjection" grows beyond 64 KB > at org.codehaus.janino.CodeContext.makeSpace(CodeContext.java:949) > at org.codehaus.janino.CodeContext.write(CodeContext.java:839) > at org.codehaus.janino.UnitCompiler.writeOpcode(UnitCompiler.java:11081) > at org.codehaus.janino.UnitCompiler.pushConstant(UnitCompiler.java:9674) > at org.codehaus.janino.UnitCompiler.compileGet2(UnitCompiler.java:4911) > at org.codehaus.janino.UnitCompiler.access$7700(UnitCompiler.java:206) > at org.codehaus.janino.UnitCompiler$12.visitIntegerLiteral(UnitCompiler.java:3776) > ... > {code} > Note that, I could not reproduce this with local relation (this one appears by {{ConvertToLocalRelation}}). > {code} > import org.apache.spark.sql.functions._ > var df = Seq(1).toDF("fieldA") > df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) > df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) > df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) > df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) > df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) > df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) > df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) > df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) > df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) > df = df.withColumn("fieldA", when($"fieldA" === 0, null).otherwise($"fieldA")) > df.show() > {code} -- 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