Return-Path: X-Original-To: apmail-flink-user-archive@minotaur.apache.org Delivered-To: apmail-flink-user-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 56FFE18727 for ; Tue, 16 Jun 2015 08:27:51 +0000 (UTC) Received: (qmail 68559 invoked by uid 500); 16 Jun 2015 08:27:51 -0000 Delivered-To: apmail-flink-user-archive@flink.apache.org Received: (qmail 68495 invoked by uid 500); 16 Jun 2015 08:27:50 -0000 Mailing-List: contact user-help@flink.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@flink.apache.org Delivered-To: mailing list user@flink.apache.org Received: (qmail 68486 invoked by uid 99); 16 Jun 2015 08:27:50 -0000 Received: from mail-relay.apache.org (HELO mail-relay.apache.org) (140.211.11.15) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Jun 2015 08:27:50 +0000 Received: from mail-wi0-f171.google.com (mail-wi0-f171.google.com [209.85.212.171]) by mail-relay.apache.org (ASF Mail Server at mail-relay.apache.org) with ESMTPSA id 22DEC1A04B1 for ; Tue, 16 Jun 2015 08:27:50 +0000 (UTC) Received: by wiwd19 with SMTP id d19so96482901wiw.0 for ; Tue, 16 Jun 2015 01:27:49 -0700 (PDT) X-Received: by 10.180.93.170 with SMTP id cv10mr4202952wib.44.1434443269123; Tue, 16 Jun 2015 01:27:49 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Aljoscha Krettek Date: Tue, 16 Jun 2015 08:27:38 +0000 Message-ID: Subject: Re: Help with Flink experimental Table API To: user@flink.apache.org Content-Type: multipart/alternative; boundary=f46d0438933181b4b105189e59e5 --f46d0438933181b4b105189e59e5 Content-Type: text/plain; charset=UTF-8 Yes, what I meant was to have a single bit mask that is written before all the fields are written. Then, for example, 1011 would mean that field 1, 2, and 4 are non-null while field 3 is null. On Tue, 16 Jun 2015 at 10:24 Shiti Saxena wrote: > Can we use 0(false) and 1(true)? > > On Tue, Jun 16, 2015 at 1:32 PM, Aljoscha Krettek > wrote: > >> One more thing, it would be good if the TupleSerializer didn't write a >> boolean for every field. A single integer could be used where one bit >> specifies if a given field is null or not. (Maybe we should also add this >> to the RowSerializer in the future.) >> >> On Tue, 16 Jun 2015 at 07:30 Aljoscha Krettek >> wrote: >> >>> I think you can work on it. By the way, there are actually two >>> serializers. For Scala, CaseClassSerializer is responsible for tuples as >>> well. In Java, TupleSerializer is responsible for, well, Tuples. >>> >>> On Tue, 16 Jun 2015 at 06:25 Shiti Saxena wrote: >>> >>>> Hi, >>>> >>>> Can I work on the issue with TupleSerializer or is someone working on >>>> it? >>>> >>>> On Mon, Jun 15, 2015 at 11:20 AM, Aljoscha Krettek >>> > wrote: >>>> >>>>> Hi, >>>>> the reason why this doesn't work is that the TupleSerializer cannot >>>>> deal with null values: >>>>> >>>>> @Test >>>>> def testAggregationWithNull(): Unit = { >>>>> >>>>> val env = ExecutionEnvironment.getExecutionEnvironment >>>>> val table = env.fromElements[(Integer, String)]( >>>>> (123, "a"), (234, "b"), (345, "c"), (null, "d")).toTable >>>>> >>>>> val total = table.select('_1.sum).collect().head.productElement(0) >>>>> assertEquals(total, 702) >>>>> } >>>>> >>>>> it would have to modified in a similar way to the PojoSerializer and RowSerializer. You could either leave the tests as they are now in you pull request or also modify the TupleSerializer. Both seem fine to me. >>>>> >>>>> Cheers, >>>>> >>>>> Aljoscha >>>>> >>>>> >>>>> On Sun, 14 Jun 2015 at 20:28 Shiti Saxena wrote: >>>>> >>>>> Hi, >>>>>> >>>>>> Re-writing the test in the following manner works. But I am not sure >>>>>> if this is the correct way. >>>>>> >>>>>> def testAggregationWithNull(): Unit = { >>>>>> >>>>>> val env = ExecutionEnvironment.getExecutionEnvironment >>>>>> val dataSet = env.fromElements[(Integer, String)]((123, "a"), >>>>>> (234, "b"), (345, "c"), (0, "d")) >>>>>> >>>>>> implicit val rowInfo: TypeInformation[Row] = new RowTypeInfo( >>>>>> Seq(BasicTypeInfo.INT_TYPE_INFO, >>>>>> BasicTypeInfo.STRING_TYPE_INFO), Seq("id", "name")) >>>>>> >>>>>> val rowDataSet = dataSet.map { >>>>>> entry => >>>>>> val row = new Row(2) >>>>>> val amount = if(entry._1<100) null else entry._1 >>>>>> row.setField(0, amount) >>>>>> row.setField(1, entry._2) >>>>>> row >>>>>> } >>>>>> >>>>>> val total = >>>>>> rowDataSet.toTable.select('id.sum).collect().head.productElement(0) >>>>>> assertEquals(total, 702) >>>>>> } >>>>>> >>>>>> >>>>>> >>>>>> On Sun, Jun 14, 2015 at 11:42 PM, Shiti Saxena >>>>> > wrote: >>>>>> >>>>>>> Hi, >>>>>>> >>>>>>> For >>>>>>> >>>>>>> val table = env.fromElements[(Integer, String)]((123, "a"), (234, >>>>>>> "b"), (345, "c"), (null, "d")).toTable >>>>>>> >>>>>>> I get the following error, >>>>>>> >>>>>>> Error translating node 'Data Source "at >>>>>>> org.apache.flink.api.scala.ExecutionEnvironment.fromElements(ExecutionEnvironment.scala:505) >>>>>>> (org.apache.flink.api.java.io.CollectionInputFormat)" : NONE [[ >>>>>>> GlobalProperties [partitioning=RANDOM_PARTITIONED] ]] [[ LocalProperties >>>>>>> [ordering=null, grouped=null, unique=null] ]]': null >>>>>>> org.apache.flink.optimizer.CompilerException: Error translating node >>>>>>> 'Data Source "at >>>>>>> org.apache.flink.api.scala.ExecutionEnvironment.fromElements(ExecutionEnvironment.scala:505) >>>>>>> (org.apache.flink.api.java.io.CollectionInputFormat)" : NONE [[ >>>>>>> GlobalProperties [partitioning=RANDOM_PARTITIONED] ]] [[ LocalProperties >>>>>>> [ordering=null, grouped=null, unique=null] ]]': null >>>>>>> at >>>>>>> org.apache.flink.optimizer.plantranslate.JobGraphGenerator.preVisit(JobGraphGenerator.java:360) >>>>>>> at >>>>>>> org.apache.flink.optimizer.plantranslate.JobGraphGenerator.preVisit(JobGraphGenerator.java:103) >>>>>>> at >>>>>>> org.apache.flink.optimizer.plan.SourcePlanNode.accept(SourcePlanNode.java:87) >>>>>>> at >>>>>>> org.apache.flink.optimizer.plan.SingleInputPlanNode.accept(SingleInputPlanNode.java:199) >>>>>>> at >>>>>>> org.apache.flink.optimizer.plan.SingleInputPlanNode.accept(SingleInputPlanNode.java:199) >>>>>>> at >>>>>>> org.apache.flink.optimizer.plan.SingleInputPlanNode.accept(SingleInputPlanNode.java:199) >>>>>>> at >>>>>>> org.apache.flink.optimizer.plan.SingleInputPlanNode.accept(SingleInputPlanNode.java:199) >>>>>>> at >>>>>>> org.apache.flink.optimizer.plan.SingleInputPlanNode.accept(SingleInputPlanNode.java:199) >>>>>>> at >>>>>>> org.apache.flink.optimizer.plan.SingleInputPlanNode.accept(SingleInputPlanNode.java:199) >>>>>>> at >>>>>>> org.apache.flink.optimizer.plan.OptimizedPlan.accept(OptimizedPlan.java:127) >>>>>>> at >>>>>>> org.apache.flink.optimizer.plantranslate.JobGraphGenerator.compileJobGraph(JobGraphGenerator.java:170) >>>>>>> at >>>>>>> org.apache.flink.test.util.TestEnvironment.execute(TestEnvironment.java:52) >>>>>>> at >>>>>>> org.apache.flink.api.java.ExecutionEnvironment.execute(ExecutionEnvironment.java:789) >>>>>>> at >>>>>>> org.apache.flink.api.scala.ExecutionEnvironment.execute(ExecutionEnvironment.scala:576) >>>>>>> at org.apache.flink.api.scala.DataSet.collect(DataSet.scala:544) >>>>>>> at >>>>>>> org.apache.flink.api.scala.table.test.AggregationsITCase.testAggregationWithNull(AggregationsITCase.scala:135) >>>>>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) >>>>>>> at >>>>>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) >>>>>>> at >>>>>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) >>>>>>> at java.lang.reflect.Method.invoke(Method.java:606) >>>>>>> at >>>>>>> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) >>>>>>> at >>>>>>> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) >>>>>>> at >>>>>>> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) >>>>>>> at >>>>>>> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) >>>>>>> at >>>>>>> org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) >>>>>>> at >>>>>>> org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) >>>>>>> at >>>>>>> org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:48) >>>>>>> at org.junit.rules.RunRules.evaluate(RunRules.java:20) >>>>>>> at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) >>>>>>> at >>>>>>> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) >>>>>>> at >>>>>>> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) >>>>>>> at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) >>>>>>> at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) >>>>>>> at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) >>>>>>> at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) >>>>>>> at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) >>>>>>> at org.junit.runners.ParentRunner.run(ParentRunner.java:309) >>>>>>> at org.junit.runners.Suite.runChild(Suite.java:127) >>>>>>> at org.junit.runners.Suite.runChild(Suite.java:26) >>>>>>> at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) >>>>>>> at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) >>>>>>> at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) >>>>>>> at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) >>>>>>> at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) >>>>>>> at >>>>>>> org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) >>>>>>> at >>>>>>> org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) >>>>>>> at org.junit.runners.ParentRunner.run(ParentRunner.java:309) >>>>>>> at org.junit.runner.JUnitCore.run(JUnitCore.java:160) >>>>>>> at >>>>>>> com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:78) >>>>>>> at >>>>>>> com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:212) >>>>>>> at >>>>>>> com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68) >>>>>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) >>>>>>> at >>>>>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) >>>>>>> at >>>>>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) >>>>>>> at java.lang.reflect.Method.invoke(Method.java:606) >>>>>>> at >>>>>>> com.intellij.rt.execution.application.AppMain.main(AppMain.java:140) >>>>>>> Caused by: java.lang.NullPointerException >>>>>>> at >>>>>>> org.apache.flink.api.common.typeutils.base.IntSerializer.serialize(IntSerializer.java:63) >>>>>>> at >>>>>>> org.apache.flink.api.common.typeutils.base.IntSerializer.serialize(IntSerializer.java:27) >>>>>>> at >>>>>>> org.apache.flink.api.scala.typeutils.CaseClassSerializer.serialize(CaseClassSerializer.scala:89) >>>>>>> at >>>>>>> org.apache.flink.api.scala.typeutils.CaseClassSerializer.serialize(CaseClassSerializer.scala:29) >>>>>>> at org.apache.flink.api.java.io >>>>>>> .CollectionInputFormat.writeObject(CollectionInputFormat.java:88) >>>>>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) >>>>>>> at >>>>>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) >>>>>>> at >>>>>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) >>>>>>> at java.lang.reflect.Method.invoke(Method.java:606) >>>>>>> at >>>>>>> java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:988) >>>>>>> at >>>>>>> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1493) >>>>>>> at >>>>>>> java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1429) >>>>>>> at >>>>>>> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1175) >>>>>>> at >>>>>>> java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1541) >>>>>>> at >>>>>>> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1506) >>>>>>> at >>>>>>> java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1429) >>>>>>> at >>>>>>> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1175) >>>>>>> at >>>>>>> java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347) >>>>>>> at >>>>>>> org.apache.flink.util.InstantiationUtil.serializeObject(InstantiationUtil.java:314) >>>>>>> at >>>>>>> org.apache.flink.util.InstantiationUtil.writeObjectToConfig(InstantiationUtil.java:268) >>>>>>> at >>>>>>> org.apache.flink.runtime.operators.util.TaskConfig.setStubWrapper(TaskConfig.java:273) >>>>>>> at >>>>>>> org.apache.flink.optimizer.plantranslate.JobGraphGenerator.createDataSourceVertex(JobGraphGenerator.java:853) >>>>>>> at >>>>>>> org.apache.flink.optimizer.plantranslate.JobGraphGenerator.preVisit(JobGraphGenerator.java:260) >>>>>>> ... 55 more >>>>>>> >>>>>>> >>>>>>> Does this mean that the collect method is being called before doing >>>>>>> the aggregation? Is this because base serializers do not handle null values >>>>>>> like POJOSerializer? And is that why fromCollection does not support >>>>>>> collections with null values? >>>>>>> >>>>>>> Or I could write the test using a file load if thats alright. >>>>>>> >>>>>>> >>>>>>> On Sun, Jun 14, 2015 at 11:11 PM, Aljoscha Krettek < >>>>>>> aljoscha@apache.org> wrote: >>>>>>> >>>>>>>> Hi, >>>>>>>> sorry, my mail client sent before I was done. >>>>>>>> >>>>>>>> I think the problem is that the Scala compiler derives a wrong type >>>>>>>> for this statement: >>>>>>>> val table = env.fromElements((123, "a"), (234, "b"), (345, "c"), >>>>>>>> (null, "d")).toTable >>>>>>>> >>>>>>>> Because of the null value it derives (Any, String) as the type if >>>>>>>> you do it like this, I think it should work: >>>>>>>> val table = env.fromElements[(Integer, String)]((123, "a"), (234, >>>>>>>> "b"), (345, "c"), (null, "d")).toTable >>>>>>>> >>>>>>>> I used Integer instead of Int because Scala will complain that null >>>>>>>> is not a valid value for Int otherwise. >>>>>>>> >>>>>>>> Cheers, >>>>>>>> Aljoscha >>>>>>>> >>>>>>>> >>>>>>>> On Sun, 14 Jun 2015 at 19:34 Aljoscha Krettek >>>>>>>> wrote: >>>>>>>> >>>>>>>>> Hi, >>>>>>>>> I think the problem is that the Scala compiler derives a wrong >>>>>>>>> type for this statement: >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> On Sun, 14 Jun 2015 at 18:28 Shiti Saxena >>>>>>>>> wrote: >>>>>>>>> >>>>>>>>>> Hi Aljoscha, >>>>>>>>>> >>>>>>>>>> I created the issue FLINK-2210 >>>>>>>>>> for aggregate >>>>>>>>>> on null. I made changes to ExpressionAggregateFunction to handle ignore >>>>>>>>>> null values. But I am unable to create a Table with null values in tests. >>>>>>>>>> >>>>>>>>>> The code I used is, >>>>>>>>>> >>>>>>>>>> def testAggregationWithNull(): Unit = { >>>>>>>>>> >>>>>>>>>> val env = ExecutionEnvironment.getExecutionEnvironment >>>>>>>>>> val table = env.fromElements((123, "a"), (234, "b"), (345, >>>>>>>>>> "c"), (null, "d")).toTable >>>>>>>>>> >>>>>>>>>> val total = >>>>>>>>>> table.select('_1.sum).collect().head.productElement(0) >>>>>>>>>> assertEquals(total, 702) >>>>>>>>>> } >>>>>>>>>> >>>>>>>>>> and the error i get is, >>>>>>>>>> >>>>>>>>>> org.apache.flink.api.table.ExpressionException: Invalid >>>>>>>>>> expression "('_1).sum": Unsupported type GenericType for >>>>>>>>>> aggregation ('_1).sum. Only numeric data types supported. >>>>>>>>>> at >>>>>>>>>> org.apache.flink.api.table.expressions.analysis.TypeCheck.apply(TypeCheck.scala:50) >>>>>>>>>> at >>>>>>>>>> org.apache.flink.api.table.expressions.analysis.TypeCheck.apply(TypeCheck.scala:31) >>>>>>>>>> at >>>>>>>>>> org.apache.flink.api.table.trees.Analyzer$$anonfun$analyze$1.apply(Analyzer.scala:34) >>>>>>>>>> at >>>>>>>>>> org.apache.flink.api.table.trees.Analyzer$$anonfun$analyze$1.apply(Analyzer.scala:31) >>>>>>>>>> at scala.collection.immutable.List.foreach(List.scala:318) >>>>>>>>>> at >>>>>>>>>> org.apache.flink.api.table.trees.Analyzer.analyze(Analyzer.scala:31) >>>>>>>>>> at >>>>>>>>>> org.apache.flink.api.table.Table$$anonfun$1.apply(Table.scala:59) >>>>>>>>>> at >>>>>>>>>> org.apache.flink.api.table.Table$$anonfun$1.apply(Table.scala:59) >>>>>>>>>> at >>>>>>>>>> scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244) >>>>>>>>>> at >>>>>>>>>> scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244) >>>>>>>>>> at >>>>>>>>>> scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33) >>>>>>>>>> at >>>>>>>>>> scala.collection.mutable.WrappedArray.foreach(WrappedArray.scala:34) >>>>>>>>>> at >>>>>>>>>> scala.collection.TraversableLike$class.map(TraversableLike.scala:244) >>>>>>>>>> at scala.collection.AbstractTraversable.map(Traversable.scala:105) >>>>>>>>>> at org.apache.flink.api.table.Table.select(Table.scala:59) >>>>>>>>>> at >>>>>>>>>> org.apache.flink.api.scala.table.test.AggregationsITCase.testAggregationWithNull(AggregationsITCase.scala:135) >>>>>>>>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) >>>>>>>>>> at >>>>>>>>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) >>>>>>>>>> at >>>>>>>>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) >>>>>>>>>> at >>>>>>>>>> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) >>>>>>>>>> at >>>>>>>>>> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) >>>>>>>>>> at >>>>>>>>>> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) >>>>>>>>>> at >>>>>>>>>> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) >>>>>>>>>> at >>>>>>>>>> org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) >>>>>>>>>> at >>>>>>>>>> org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) >>>>>>>>>> at >>>>>>>>>> org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:48) >>>>>>>>>> at org.junit.rules.RunRules.evaluate(RunRules.java:20) >>>>>>>>>> at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) >>>>>>>>>> at >>>>>>>>>> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) >>>>>>>>>> at >>>>>>>>>> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) >>>>>>>>>> at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) >>>>>>>>>> at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) >>>>>>>>>> at >>>>>>>>>> org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) >>>>>>>>>> at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) >>>>>>>>>> at >>>>>>>>>> org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) >>>>>>>>>> at org.junit.runners.ParentRunner.run(ParentRunner.java:309) >>>>>>>>>> at org.junit.runners.Suite.runChild(Suite.java:127) >>>>>>>>>> at org.junit.runners.Suite.runChild(Suite.java:26) >>>>>>>>>> at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) >>>>>>>>>> at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) >>>>>>>>>> at >>>>>>>>>> org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) >>>>>>>>>> at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) >>>>>>>>>> at >>>>>>>>>> org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) >>>>>>>>>> at >>>>>>>>>> org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) >>>>>>>>>> at >>>>>>>>>> org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) >>>>>>>>>> at org.junit.runners.ParentRunner.run(ParentRunner.java:309) >>>>>>>>>> at org.junit.runner.JUnitCore.run(JUnitCore.java:160) >>>>>>>>>> at >>>>>>>>>> com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:78) >>>>>>>>>> at >>>>>>>>>> com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:212) >>>>>>>>>> at >>>>>>>>>> com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68) >>>>>>>>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) >>>>>>>>>> at >>>>>>>>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) >>>>>>>>>> at >>>>>>>>>> com.intellij.rt.execution.application.AppMain.main(AppMain.java:140) >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> The ExecutionEnvironment.fromCollection method also throws an >>>>>>>>>> error when the collection contains a null. >>>>>>>>>> >>>>>>>>>> Could you please point out what I am doing wrong? How do we >>>>>>>>>> create a Table with null values? >>>>>>>>>> >>>>>>>>>> In our application, we load a file and transform each line into a >>>>>>>>>> Row resulting in a DataSet[Row]. This DataSet[Row] is then converted into >>>>>>>>>> Table. Should I use the same approach for the test case? >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> Thanks, >>>>>>>>>> Shiti >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> On Sun, Jun 14, 2015 at 4:10 PM, Shiti Saxena < >>>>>>>>>> ssaxena.ece@gmail.com> wrote: >>>>>>>>>> >>>>>>>>>>> I'll do the fix >>>>>>>>>>> >>>>>>>>>>> On Sun, Jun 14, 2015 at 12:42 AM, Aljoscha Krettek < >>>>>>>>>>> aljoscha@apache.org> wrote: >>>>>>>>>>> >>>>>>>>>>>> I merged your PR for the RowSerializer. Teaching the >>>>>>>>>>>> aggregators to deal with null values should be a very simple fix in >>>>>>>>>>>> ExpressionAggregateFunction.scala. There it is simply always aggregating >>>>>>>>>>>> the values without checking whether they are null. If you want you can also >>>>>>>>>>>> fix that or I can quickly fix it. >>>>>>>>>>>> >>>>>>>>>>>> On Thu, 11 Jun 2015 at 10:40 Aljoscha Krettek < >>>>>>>>>>>> aljoscha@apache.org> wrote: >>>>>>>>>>>> >>>>>>>>>>>>> Cool, good to hear. >>>>>>>>>>>>> >>>>>>>>>>>>> The PojoSerializer already handles null fields. The >>>>>>>>>>>>> RowSerializer can be modified in pretty much the same way. So you should >>>>>>>>>>>>> start by looking at the copy()/serialize()/deserialize() methods of >>>>>>>>>>>>> PojoSerializer and then modify RowSerializer in a similar way. >>>>>>>>>>>>> >>>>>>>>>>>>> You can also send me a private mail if you want more in-depth >>>>>>>>>>>>> explanations. >>>>>>>>>>>>> >>>>>>>>>>>>> On Thu, 11 Jun 2015 at 09:33 Till Rohrmann < >>>>>>>>>>>>> trohrmann@apache.org> wrote: >>>>>>>>>>>>> >>>>>>>>>>>>>> Hi Shiti, >>>>>>>>>>>>>> >>>>>>>>>>>>>> here is the issue [1]. >>>>>>>>>>>>>> >>>>>>>>>>>>>> Cheers, >>>>>>>>>>>>>> Till >>>>>>>>>>>>>> >>>>>>>>>>>>>> [1] https://issues.apache.org/jira/browse/FLINK-2203 >>>>>>>>>>>>>> >>>>>>>>>>>>>> On Thu, Jun 11, 2015 at 8:42 AM Shiti Saxena < >>>>>>>>>>>>>> ssaxena.ece@gmail.com> wrote: >>>>>>>>>>>>>> >>>>>>>>>>>>>>> Hi Aljoscha, >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> Could you please point me to the JIRA tickets? If you could >>>>>>>>>>>>>>> provide some guidance on how to resolve these, I will work on them and >>>>>>>>>>>>>>> raise a pull-request. >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>> Shiti >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> On Thu, Jun 11, 2015 at 11:31 AM, Aljoscha Krettek < >>>>>>>>>>>>>>> aljoscha@apache.org> wrote: >>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>>> yes, I think the problem is that the RowSerializer does not >>>>>>>>>>>>>>>> support null-values. I think we can add support for this, I will open a >>>>>>>>>>>>>>>> Jira issue. >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> Another problem I then see is that the aggregations can not >>>>>>>>>>>>>>>> properly deal with null-values. This would need separate support. >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> Regards, >>>>>>>>>>>>>>>> Aljoscha >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>> On Thu, 11 Jun 2015 at 06:41 Shiti Saxena < >>>>>>>>>>>>>>>> ssaxena.ece@gmail.com> wrote: >>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> Hi, >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> In our project, we are using the Flink Table API and are >>>>>>>>>>>>>>>>> facing the following issues, >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> We load data from a CSV file and create a DataSet[Row]. >>>>>>>>>>>>>>>>> The CSV file can also have invalid entries in some of the fields which we >>>>>>>>>>>>>>>>> replace with null when building the DataSet[Row]. >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> This DataSet[Row] is later on transformed to Table >>>>>>>>>>>>>>>>> whenever required and specific operation such as select or aggregate, etc >>>>>>>>>>>>>>>>> are performed. >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> When a null value is encountered, we get a null pointer >>>>>>>>>>>>>>>>> exception and the whole job fails. (We can see this by calling collect on >>>>>>>>>>>>>>>>> the resulting DataSet). >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> The error message is similar to, >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> Job execution failed. >>>>>>>>>>>>>>>>> org.apache.flink.runtime.client.JobExecutionException: Job >>>>>>>>>>>>>>>>> execution failed. >>>>>>>>>>>>>>>>> at >>>>>>>>>>>>>>>>> org.apache.flink.runtime.jobmanager.JobManager$$anonfun$receiveWithLogMessages$1.applyOrElse(JobManager.scala:315) >>>>>>>>>>>>>>>>> at >>>>>>>>>>>>>>>>> scala.runtime.AbstractPartialFunction$mcVL$sp.apply$mcVL$sp(AbstractPartialFunction.scala:33) >>>>>>>>>>>>>>>>> at >>>>>>>>>>>>>>>>> scala.runtime.AbstractPartialFunction$mcVL$sp.apply(AbstractPartialFunction.scala:33) >>>>>>>>>>>>>>>>> at >>>>>>>>>>>>>>>>> scala.runtime.AbstractPartialFunction$mcVL$sp.apply(AbstractPartialFunction.scala:25) >>>>>>>>>>>>>>>>> at >>>>>>>>>>>>>>>>> org.apache.flink.runtime.ActorLogMessages$$anon$1.apply(ActorLogMessages.scala:43) >>>>>>>>>>>>>>>>> at >>>>>>>>>>>>>>>>> org.apache.flink.runtime.ActorLogMessages$$anon$1.apply(ActorLogMessages.scala:29) >>>>>>>>>>>>>>>>> at >>>>>>>>>>>>>>>>> scala.PartialFunction$class.applyOrElse(PartialFunction.scala:118) >>>>>>>>>>>>>>>>> at >>>>>>>>>>>>>>>>> org.apache.flink.runtime.ActorLogMessages$$anon$1.applyOrElse(ActorLogMessages.scala:29) >>>>>>>>>>>>>>>>> at akka.actor.Actor$class.aroundReceive(Actor.scala:465) >>>>>>>>>>>>>>>>> at >>>>>>>>>>>>>>>>> org.apache.flink.runtime.jobmanager.JobManager.aroundReceive(JobManager.scala:94) >>>>>>>>>>>>>>>>> at akka.actor.ActorCell.receiveMessage(ActorCell.scala:516) >>>>>>>>>>>>>>>>> at akka.actor.ActorCell.invoke(ActorCell.scala:487) >>>>>>>>>>>>>>>>> at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:254) >>>>>>>>>>>>>>>>> at akka.dispatch.Mailbox.run(Mailbox.scala:221) >>>>>>>>>>>>>>>>> at akka.dispatch.Mailbox.exec(Mailbox.scala:231) >>>>>>>>>>>>>>>>> at >>>>>>>>>>>>>>>>> scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) >>>>>>>>>>>>>>>>> at >>>>>>>>>>>>>>>>> scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) >>>>>>>>>>>>>>>>> at >>>>>>>>>>>>>>>>> scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) >>>>>>>>>>>>>>>>> at >>>>>>>>>>>>>>>>> scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) >>>>>>>>>>>>>>>>> Caused by: java.lang.NullPointerException >>>>>>>>>>>>>>>>> at >>>>>>>>>>>>>>>>> org.apache.flink.api.common.typeutils.base.IntSerializer.serialize(IntSerializer.java:63) >>>>>>>>>>>>>>>>> at >>>>>>>>>>>>>>>>> org.apache.flink.api.common.typeutils.base.IntSerializer.serialize(IntSerializer.java:27) >>>>>>>>>>>>>>>>> at >>>>>>>>>>>>>>>>> org.apache.flink.api.table.typeinfo.RowSerializer.serialize(RowSerializer.scala:80) >>>>>>>>>>>>>>>>> at >>>>>>>>>>>>>>>>> org.apache.flink.api.table.typeinfo.RowSerializer.serialize(RowSerializer.scala:28) >>>>>>>>>>>>>>>>> at >>>>>>>>>>>>>>>>> org.apache.flink.runtime.plugable.SerializationDelegate.write(SerializationDelegate.java:51) >>>>>>>>>>>>>>>>> at org.apache.flink.runtime.io >>>>>>>>>>>>>>>>> .network.api.serialization.SpanningRecordSerializer.addRecord(SpanningRecordSerializer.java:76) >>>>>>>>>>>>>>>>> at org.apache.flink.runtime.io >>>>>>>>>>>>>>>>> .network.api.writer.RecordWriter.emit(RecordWriter.java:83) >>>>>>>>>>>>>>>>> at >>>>>>>>>>>>>>>>> org.apache.flink.runtime.operators.shipping.OutputCollector.collect(OutputCollector.java:65) >>>>>>>>>>>>>>>>> at >>>>>>>>>>>>>>>>> org.apache.flink.runtime.operators.chaining.ChainedMapDriver.collect(ChainedMapDriver.java:78) >>>>>>>>>>>>>>>>> at >>>>>>>>>>>>>>>>> org.apache.flink.runtime.operators.chaining.ChainedMapDriver.collect(ChainedMapDriver.java:78) >>>>>>>>>>>>>>>>> at >>>>>>>>>>>>>>>>> org.apache.flink.runtime.operators.DataSourceTask.invoke(DataSourceTask.java:177) >>>>>>>>>>>>>>>>> at >>>>>>>>>>>>>>>>> org.apache.flink.runtime.taskmanager.Task.run(Task.java:559) >>>>>>>>>>>>>>>>> at java.lang.Thread.run(Thread.java:724) >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> Could this be because the RowSerializer does not support >>>>>>>>>>>>>>>>> null values? (Similar to Flink-629 >>>>>>>>>>>>>>>>> ) >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> Currently, to overcome this issue, we are ignoring all the >>>>>>>>>>>>>>>>> rows which may have null values. For example, we have a method cleanData >>>>>>>>>>>>>>>>> defined as, >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> def cleanData(table:Table, >>>>>>>>>>>>>>>>> relevantColumns:Seq[String]):Table = { >>>>>>>>>>>>>>>>> val whereClause: String = relevantColumns.map{ >>>>>>>>>>>>>>>>> cName=> >>>>>>>>>>>>>>>>> s"$cName.isNotNull" >>>>>>>>>>>>>>>>> }.mkString(" && ") >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> val result :Table = >>>>>>>>>>>>>>>>> table.select(relevantColumns.mkString(",")).where(whereClause) >>>>>>>>>>>>>>>>> result >>>>>>>>>>>>>>>>> } >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> Before operating on any Table, we use this method and then >>>>>>>>>>>>>>>>> continue with task. >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> Is this the right way to handle this? If not please let me >>>>>>>>>>>>>>>>> know how to go about it. >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> Thanks, >>>>>>>>>>>>>>>>> Shiti >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>> >>>>>>> >>>>>> >>>> > --f46d0438933181b4b105189e59e5 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Yes, what I meant was to have a single bit mask that is wr= itten before all the fields are written. Then, for example, 1011 would mean= that field 1, 2, and 4 are non-null while field 3 is null.

On Tue, 16 Jun 2015 at 10:24 Shit= i Saxena <ssaxena.ece@gmail.com= > wrote:
Ca= n we use 0(false) and 1(true)?

On Tue, Jun 16, 2015 at 1:32 PM, Aljoscha Krettek <al= joscha@apache.org> wrote:
<= div dir=3D"ltr">One more thing, it would be good if the TupleSerializer did= n't write a boolean for every field. A single integer could be used whe= re one bit specifies if a given field is null or not. (Maybe we should also= add this to the RowSerializer in the future.)

On Tue, 16 Jun 2015 at 07:30 Aljosch= a Krettek <aljo= scha@apache.org> wrote:
I think you can work on it. By the way, there are actually two= serializers. For Scala, CaseClassSerializer is responsible for tuples as w= ell. In Java, TupleSerializer is responsible for, well, Tuples.=C2=A0

On Tue, 16 Jun 2015 at = 06:25 Shiti Saxena <ssaxena.ece@gmail.com> wrote:
Hi,

Can I work on the issue wi= th TupleSerializer or is someone working on it?

On Mon, Jun 15, 2015 at 11:20 AM,= Aljoscha Krettek <aljoscha@apache.org> wrote:
Hi,
the reason why this doesn= 9;t work is that the TupleSerializer cannot deal with null values:
@Test
def testAggregationWithNull(): Unit =3D {

val env = =3D ExecutionEnvironment.getExecutionEnvironment
val table =3D e= nv.fromElements[(Integer, String)](
(123, "a"), (234, &= quot;b"), (345, "c"), (null, "d")).toTable

= val total =3D table.select('_1.sum).collect().head.productElement(0) assertEquals(total, 702)
}
it wo=
uld have to=C2=A0modified in a similar way to the PojoSerializer and RowSer=
ializer. You could either leave the tests as they are now in you pull reque=
st or also modify the TupleSerializer. Both seem fine to me.<=
br>
<=
span style=3D"white-space:normal">Cheers,
Aljoscha

On Sun, 14 Jun 2015 at 20:28 Shiti Saxena <ssaxena.ece@gmail.com> wrote:
Hi,

Re-writing the test in the following manner work= s. But I am not sure if this is the correct way.

<= /div>
def testAggregationWithNull(): Unit =3D {

=C2=A0 =C2=A0 val env =3D ExecutionEnvironment.getE= xecutionEnvironment
=C2=A0 =C2= =A0 val dataSet =3D env.fromElements[(Integer, String)]((123, "a"= ), (234, "b"), (345, "c"), (0, "d"))

=C2=A0 =C2=A0 implicit val rowInfo: TypeInformation[Row] = =3D new RowTypeInfo(
=C2=A0 =C2=A0 =C2=A0 Seq(BasicTypeInfo.INT_T= YPE_INFO, BasicTypeInfo.STRING_TYPE_INFO), Seq("id", "name&q= uot;))

=C2=A0 =C2=A0 val rowDataSet =3D dataSet.ma= p {
=C2=A0 =C2=A0 =C2=A0 entry =3D>
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 val row =3D new Row(2)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 = val amount =3D if(entry._1<100) null else entry._1
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 row.setField(0, amount)
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 row.setField(1, entry._2)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 row<= /div>
=C2=A0 =C2=A0 }
=C2=A0 =C2=A0=C2=A0
=C2=A0 = =C2=A0 val total =3D rowDataSet.toTable.select('id.sum).collect().head.= productElement(0)
=C2=A0 =C2=A0 assertEquals(total, 702)
=C2=A0 }



On Sun, Jun 14, 2015 at 11:42 PM, = Shiti Saxena <ssaxena.ece@gmail.com> wrote:
Hi,

For=C2=A0

val table =3D env.f= romElements[(Integer, String)]((123, "a"), (234, "b"), = (345, "c"), (null, "d")).toTable

I get the following error,

Error translating node '= Data Source "at org.apache.flink.api.scala.ExecutionEnvironment.fromEl= ements(ExecutionEnvironment.scala:505) (org.apache.flink.api.java.io.CollectionI= nputFormat)" : NONE [[ GlobalProperties [partitioning=3DRANDOM_PARTITI= ONED] ]] [[ LocalProperties [ordering=3Dnull, grouped=3Dnull, unique=3Dnull= ] ]]': null
org.apach= e.flink.optimizer.CompilerException: Error translating node 'Data Sourc= e "at org.apache.flink.api.scala.ExecutionEnvironment.fromElements(Exe= cutionEnvironment.scala:505) (org.apache.flink.api.java.io.CollectionInputFormat= )" : NONE [[ GlobalProperties [partitioning=3DRANDOM_PARTITIONED] ]] [= [ LocalProperties [ordering=3Dnull, grouped=3Dnull, unique=3Dnull] ]]':= null
at org.apache.flink.optimizer.plantranslate.JobGr= aphGenerator.preVisit(JobGraphGenerator.java:360)
at or= g.apache.flink.optimizer.plantranslate.JobGraphGenerator.preVisit(JobGraphG= enerator.java:103)
at org.apache.flink.optimizer.plan.S= ourcePlanNode.accept(SourcePlanNode.java:87)
at org.a= pache.flink.optimizer.plan.SingleInputPlanNode.accept(SingleInputPlanNode.j= ava:199)
at org.apache.flink.optimizer.plan.SingleInput= PlanNode.accept(SingleInputPlanNode.java:199)
at org.a= pache.flink.optimizer.plan.SingleInputPlanNode.accept(SingleInputPlanNode.j= ava:199)
at org.apache.flink.optimizer.plan.SingleInput= PlanNode.accept(SingleInputPlanNode.java:199)
at org.a= pache.flink.optimizer.plan.SingleInputPlanNode.accept(SingleInputPlanNode.j= ava:199)
at org.apache.flink.optimizer.plan.SingleInput= PlanNode.accept(SingleInputPlanNode.java:199)
at org.a= pache.flink.optimizer.plan.OptimizedPlan.accept(OptimizedPlan.java:127)
at org.apache.flink.optimizer.plantranslate.JobGraphGenera= tor.compileJobGraph(JobGraphGenerator.java:170)
at org.= apache.flink.test.util.TestEnvironment.execute(TestEnvironment.java:52)
at org.apache.flink.api.java.ExecutionEnvironment.execute(= ExecutionEnvironment.java:789)
at org.apache.flink.api.= scala.ExecutionEnvironment.execute(ExecutionEnvironment.scala:576)
at org.apache.flink.api.scala.DataSet.collect(DataSet.scala:544= )
at org.apache.flink.api.scala.table.test.Aggreg= ationsITCase.testAggregationWithNull(AggregationsITCase.scala:135)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<= /span>
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMe= thodAccessorImpl.java:57)
at sun.reflect.DelegatingMeth= odAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.runners.model.FrameworkMethod$1.runReflecti= veCall(FrameworkMethod.java:47)
at org.junit.internal.r= unners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(Frame= workMethod.java:44)
at org.junit.internal.runners.state= ments.InvokeMethod.evaluate(InvokeMethod.java:17)
at or= g.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)=
at org.junit.internal.runners.statements.RunAfters.eva= luate(RunAfters.java:27)
= at org.junit.rules.ExternalRes= ource$1.evaluate(ExternalResource.java:48)
at org.junit= .rules.RunRules.evaluate(RunRules.java:20)
at org.junit= .runners.ParentRunner.runLeaf(ParentRunner.java:271)
at= org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.j= ava:70)
at org.junit.runners.BlockJUnit4ClassRunner.run= Child(BlockJUnit4ClassRunner.java:50)
at org.junit.runn= ers.ParentRunner$3.run(ParentRunner.java:238)
at org.j= unit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner= .java:53)
at org.junit.runners.ParentRunner$2.evaluate(= ParentRunner.java:229)
at org.junit.runners.ParentRunne= r.run(ParentRunner.java:309)
at org.junit.runners.Suite= .runChild(Suite.java:127)
at org.junit.runners.Suite.ru= nChild(Suite.java:26)
at org.junit.runners.ParentRunner= $3.run(ParentRunner.java:238)
at org.junit.runners.Pare= ntRunner$1.schedule(ParentRunner.java:63)
at org.junit.= runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)<= /div>
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java= :229)
at org.junit.internal.runners.statements.RunBefor= es.evaluate(RunBefores.java:26)
at org.junit.internal.r= unners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
<= div> = at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
<= /span>at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit= 4IdeaTestRunner.java:78)
= at com.intellij.rt.execution.j= unit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:212)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.= java:68)
at sun.reflect.NativeMethodAccessorImpl.invoke= 0(Native Method)
at sun.reflect.NativeMethodAccessorImp= l.invoke(NativeMethodAccessorImpl.java:57)
= at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor= Impl.java:43)
at java.lang.reflect.Method.invoke(Method= .java:606)
at com.intellij.rt.execution.application.App= Main.main(AppMain.java:140)
Caused by: java.lang.NullPointerException
at o= rg.apache.flink.api.common.typeutils.base.IntSerializer.serialize(IntSerial= izer.java:63)
at org.apache.flink.api.common.typeutils.= base.IntSerializer.serialize(IntSerializer.java:27)
at org.apache.flink.api.scala.typeutils.CaseClassSerializer.serialize(C= aseClassSerializer.scala:89)
at org.apache.flink.api.sc= ala.typeutils.CaseClassSerializer.serialize(CaseClassSerializer.scala:29)
at org.apache.flink.api.java.io.CollectionInputFormat.writeOb= ject(CollectionInputFormat.java:88)
at sun.reflec= t.NativeMethodAccessorImpl.invoke0(Native Method)
at su= n.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)=
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Del= egatingMethodAccessorImpl.java:43)
at java.lang.= reflect.Method.invoke(Method.java:606)
at java.io.Objec= tStreamClass.invokeWriteObject(ObjectStreamClass.java:988)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1= 493)
at java.io.ObjectOutputStream.writeOrdinaryObject(= ObjectOutputStream.java:1429)
at java.io.ObjectOutputSt= ream.writeObject0(ObjectOutputStream.java:1175)
at java= .io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1541)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutput= Stream.java:1506)
at java.io.ObjectOutputStream.writeOr= dinaryObject(ObjectOutputStream.java:1429)
at java.io.O= bjectOutputStream.writeObject0(ObjectOutputStream.java:1175)
<= /span>at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347= )
at org.apache.flink.util.InstantiationUtil.serializeO= bject(InstantiationUtil.java:314)
at org.apache.flink.u= til.InstantiationUtil.writeObjectToConfig(InstantiationUtil.java:268)
at org.apache.flink.runtime.operators.util.TaskConfig.setStu= bWrapper(TaskConfig.java:273)
at org.apache.flink.optim= izer.plantranslate.JobGraphGenerator.createDataSourceVertex(JobGraphGenerat= or.java:853)
at org.apache.flink.optimizer.plantransla= te.JobGraphGenerator.preVisit(JobGraphGenerator.java:260)
= ... 55 more
<= br>

Does this mean that the collect method is being called = before doing the aggregation? Is this because base serializers do not handl= e null values like POJOSerializer? And is that why fromCollection does not = support collections with null values?
Or I could write the test using a f= ile load if thats alright.


On Sun, Jun 14, 2015 a= t 11:11 PM, Aljoscha Krettek <aljoscha@apache.org> wrote:<= br>
Hi,
sorry, my mail c= lient sent before I was done.

I think the problem is that the Scala com= piler derives a wrong type for this statement:
=
val table =3D env.from= Elements((123, "a"), (234, "b"), (345, "c"), = (null, "d")).toTable

Because of t= he null value it derives (Any, String) as the type if you do it like this, = I think it should work:
val table =3D env.fromElements[(Integer, String)]((123, "a"= ), (234, "b"), (345, "c"), (null, "d")).toTab= le

I used Integer instead of Int be= cause Scala will complain that null is not a valid value for Int otherwise.=

Cheers,
Aljoscha


On Sun, 14 Jun 2015 at 19:34 Aljoscha Kre= ttek <aljoscha@= apache.org> wrote:
Hi,
I think the problem is that the Scala compiler derives a wr= ong type for this statement:



On Sun, 14 Jun 2015 at 18:28 Shiti Sax= ena <ssaxena.= ece@gmail.com> wrote:
Hi Aljoscha,

I created the issue=C2=A0FLI= NK-2210=C2=A0for aggregate on null. I made changes to ExpressionAggrega= teFunction to handle ignore null values. But I am unable to create a Table = with null values in tests.
=C2=A0
The code I used is,

def testAggregationWithNull(): Unit =3D {

=C2=A0 =C2=A0 val env =3D ExecutionEnvironment.getExec= utionEnvironment
=C2=A0 =C2=A0 val table =3D env.fromElements((12= 3, "a"), (234, "b"), (345, "c"), (null, "= ;d")).toTable

=C2=A0 =C2=A0 val total =3D tab= le.select('_1.sum).collect().head.productElement(0)
=C2=A0 = =C2=A0 assertEquals(total, 702)
=C2=A0 }

and the error i get is,

org.apach= e.flink.api.table.ExpressionException: Invalid expression "('_1).s= um": Unsupported type GenericType<java.lang.Object> for aggregat= ion ('_1).sum. Only numeric data types supported.
at org.apache.flink.api.table.expressions= .analysis.TypeCheck.apply(TypeCheck.scala:50)
at org.apache.flink.api.table.expressions.analysi= s.TypeCheck.apply(TypeCheck.scala:31)
at org.apache.flink.api.table.trees.Analyzer$$anonfun$ana= lyze$1.apply(Analyzer.scala:34)
at org.apache.flink.api.table.trees.Analyzer$$anonfun$analyze$1= .apply(Analyzer.scala:31)
<= /span>at scala.collection.immutable.List.foreach(List.scala:318)
= at org.apache.flink.api.table.= trees.Analyzer.analyze(Analyzer.scala:31)
at org.apache.flink.api.table.Table$$anonfun$1.apply(= Table.scala:59)
at o= rg.apache.flink.api.table.Table$$anonfun$1.apply(Table.scala:59)
= at scala.collection.Traversabl= eLike$$anonfun$map$1.apply(TraversableLike.scala:244)
at scala.collection.TraversableLike$$anon= fun$map$1.apply(TraversableLike.scala:244)
at scala.collection.IndexedSeqOptimized$class.foreac= h(IndexedSeqOptimized.scala:33)
at scala.collection.mutable.WrappedArray.foreach(WrappedArray.s= cala:34)
at scala.co= llection.TraversableLike$class.map(TraversableLike.scala:244)
at scala.collection.AbstractTrave= rsable.map(Traversable.scala:105)
at org.apache.flink.api.table.Table.select(Table.scala:59)
at org.apache.flink.ap= i.scala.table.test.AggregationsITCase.testAggregationWithNull(AggregationsI= TCase.scala:135)
at = sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessor= Impl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invok= e(DelegatingMethodAccessorImpl.java:43)
at org.junit.runners.model.FrameworkMethod$1.runReflect= iveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(Ref= lectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(Framework= Method.java:44)
at o= rg.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.jav= a:17)
at org.junit.i= nternal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runner= s.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.rules.ExternalResource$1.evalua= te(ExternalResource.java:48)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
<= span style=3D"white-space:pre-wrap"> at org.junit.runners.ParentRunn= er.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUn= it4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRu= nner.java:50)
at org= .junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.sc= hedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:23= 6)
at org.junit.runn= ers.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(= ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
<= span style=3D"white-space:pre-wrap"> at org.junit.runners.Suite.runC= hild(Suite.java:127)
at org.junit.runners.Suite.runChild(Suite.java:26)
at org.junit.runners.ParentRunner$3.run(P= arentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
<= div> at org.junit.runners.Paren= tRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentR= unner.java:53)
at or= g.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.internal.runners.st= atements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAf= ters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.junit.runner.J= UnitCore.run(JUnitCore.java:160)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArg= s(JUnit4IdeaTestRunner.java:78)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsA= ndStart(JUnitStarter.java:212)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarte= r.java:68)
at sun.re= flect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.i= nvoke(NativeMethodAccessorImpl.java:57)
at com.intellij.rt.execution.application.AppMain.main(A= ppMain.java:140)


The Executio= nEnvironment.fromCollection method also throws an error when the collection= contains a null.

Could you please point out w= hat I am doing wrong? How do we create a Table with null values?
<= div>
In our application, we load a file and transform each li= ne into a Row resulting in a DataSet[Row]. This DataSet[Row] is then conver= ted into Table. Should I use the same approach for the test case?


Thanks,
Shiti

=





=



On Sun, Jun 14, 2015 at 4:10 PM, Shiti Saxena <ssaxena.ece@gmail.com> wrote:
I'll do the fix

On Sun, Jun 14, 2015 at 12:42 AM, A= ljoscha Krettek <aljoscha@apache.org> wrote:
I merged your PR for the RowSerialize= r. Teaching the aggregators to deal with null values should be a very simpl= e fix in ExpressionAggregateFunction.scala. There it is simply always aggre= gating the values without checking whether they are null. If you want you c= an also fix that or I can quickly fix it.

On Thu, 11 Jun 2015 at 10:40 Aljoscha Kre= ttek <aljoscha@= apache.org> wrote:
Cool, good to hear.

The PojoSerializer already handles= null fields. The RowSerializer can be modified in pretty much the same way= . So you should start by looking at the copy()/serialize()/deserialize() me= thods of PojoSerializer and then modify RowSerializer in a similar way.

You can also send me a private mail if you want more = in-depth explanations.=C2=A0

On Thu, 11 Jun 2015 at 09:33 Till Rohrmann <trohrmann@apache.org> wro= te:
Hi Shiti,
=
here is the issue [1].


On Thu, Jun 11, 2015 at 8:42 AM Shiti Sax= ena <ssaxena.= ece@gmail.com> wrote:
Hi=C2=A0Aljoscha,

Could you please point me to the JIRA tickets? If = you could provide some guidance on how to resolve these, I will work on the= m and raise a pull-request.

Thanks,
Shit= i

On T= hu, Jun 11, 2015 at 11:31 AM, Aljoscha Krettek <aljoscha@apache.org&= gt; wrote:
Hi,yes, I think the problem is that the RowSerializer does not support null-v= alues. I think we can add support for this, I will open a Jira issue.
<= br>
Another problem I then see is that the aggregations can not p= roperly deal with null-values. This would need separate support.
=
Regards,
Aljoscha

On Thu, 11 Jun 2015 at 06:41 Shiti Sax= ena <ssaxena.= ece@gmail.com> wrote:
Hi,

In our project, we are using the Flink Ta= ble API and are facing the following issues,

We lo= ad data from a CSV file and create a DataSet[Row]. The CSV file can also ha= ve invalid entries in some of the fields which we replace with null when bu= ilding the DataSet[Row].

This DataSet[Row] is late= r on transformed to Table whenever required and specific operation such as = select or aggregate, etc are performed.

When a nul= l value is encountered, we get a null pointer exception and the whole job f= ails. (We can see this by calling collect on the resulting DataSet).
<= div>
The error message is similar to,

Job execution failed.
org.apache.flink.runtime.client.J= obExecutionException: Job execution failed.
at org.apach= e.flink.runtime.jobmanager.JobManager$$anonfun$receiveWithLogMessages$1.app= lyOrElse(JobManager.scala:315)
at scala.runtime.Abstract= PartialFunction$mcVL$sp.apply$mcVL$sp(AbstractPartialFunction.scala:33)
at scala.runtime.AbstractPartialFunction$mcVL$sp.apply(Abst= ractPartialFunction.scala:33)
at scala.runtime.AbstractP= artialFunction$mcVL$sp.apply(AbstractPartialFunction.scala:25)
= at org.apache.flink.runtime.ActorLogMessages$$anon$1.apply(ActorLogM= essages.scala:43)
at org.apache.flink.runtime.ActorLogMe= ssages$$anon$1.apply(ActorLogMessages.scala:29)
at scala= .PartialFunction$class.applyOrElse(PartialFunction.scala:118)
<= /span>at org.apache.flink.runtime.ActorLogMessages$$anon$1.applyOrElse(Acto= rLogMessages.scala:29)
at akka.actor.Actor$class.aroundR= eceive(Actor.scala:465)
at org.apache.flink.runtime.jobm= anager.JobManager.aroundReceive(JobManager.scala:94)
at = akka.actor.ActorCell.receiveMessage(ActorCell.scala:516)
at akka.actor.ActorCell.invoke(ActorCell.scala:487)
at = akka.dispatch.Mailbox.processMailbox(Mailbox.scala:254)
= at akka.dispatch.Mailbox.run(Mailbox.scala:221)
at akka.= dispatch.Mailbox.exec(Mailbox.scala:231)
at scala.concur= rent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.j= ava:1339)
at scala.concurrent.forkjoin.ForkJoinPool.runW= orker(ForkJoinPool.java:1979)
at scala.concurrent.forkjo= in.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
Caused by: java.lang.NullPointerException=
at org.apache.flink.api.common.typeutils.base.IntSerial= izer.serialize(IntSerializer.java:63)
at org.apache.flin= k.api.common.typeutils.base.IntSerializer.serialize(IntSerializer.java:27)<= /div>
at org.apache.flink.api.table.typeinfo.RowSerializer.ser= ialize(RowSerializer.scala:80)
at org.apache.flink.api.t= able.typeinfo.RowSerializer.serialize(RowSerializer.scala:28)
<= /span>at org.apache.flink.runtime.plugable.SerializationDelegate.write(Seri= alizationDelegate.java:51)
at org.apache.flink.runtime.io.netw= ork.api.serialization.SpanningRecordSerializer.addRecord(SpanningRecordSeri= alizer.java:76)
at org.apache.flink.runtime.io.network.api.wri= ter.RecordWriter.emit(RecordWriter.java:83)
at org.apach= e.flink.runtime.operators.shipping.OutputCollector.collect(OutputCollector.= java:65)
at org.apache.flink.runtime.operators.chaining.= ChainedMapDriver.collect(ChainedMapDriver.java:78)
at or= g.apache.flink.runtime.operators.chaining.ChainedMapDriver.collect(ChainedM= apDriver.java:78)
at org.apache.flink.runtime.operators.= DataSourceTask.invoke(DataSourceTask.java:177)
at org.ap= ache.flink.runtime.taskmanager.Task.run(Task.java:559)
a= t java.lang.Thread.run(Thread.java:724)

<= span style=3D"font-size:12.8000001907349px">Could this be because the RowSe= rializer does not support null values? (Similar to=C2=A0Flink-629=C2=A0)

Currently, to over= come this issue, we are ignoring all the rows which may have null values. F= or example, we have a method cleanData defined as,

def cleanData(table:Table, relevantColumns:Seq[String]):Table =3D {
<= div>=C2=A0 =C2=A0 val whereClause: String =3D relevantColumns.map{
=C2=A0 =C2=A0 =C2=A0 =C2=A0 cName=3D>
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 s"$cName.isNotNull"
=C2=A0 =C2=A0 = }.mkString(" && ")

=C2=A0 =C2=A0= val result :Table =3D table.select(relevantColumns.mkString(",")= ).where(whereClause)
=C2=A0 =C2=A0 result
}
<= br>
Before operating on any Table, we use this method and then co= ntinue with task.

Is this the right way to handle = this? If not please let me know how to go about it.=C2=A0


Thanks,
Shiti









--f46d0438933181b4b105189e59e5--