Hello all, I have some questions about work with FlinkSQL.
1) I'm want calculate average for column values: val env = ExecutionEnvironment.getExecutionEnvironment val tEnv = TableEnvironment.getTableEnvironment(env, config) val ds = env.fromElements( (1.0f, 1), (2.0f, 2)).toTable(tEnv) tEnv.registerTable("MyTable", ds) val sqlQuery="select avg(_1), avg(_2) from MyTable" tEnv.sql(sqlQuery).toDataSet[Row].collect().foreach(x=>print(s"$x ")) As result I'm getting: "1.5,1 ". But I expected: "1.5,1.5 " Why is for columns like integer types avg function is return result as integer? Where is described this behavior? 2) I wanted calculate stddev_pop function like as sequences sql aggregate functions, how it is describe in calcite javadocs: https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/rel/rules/AggregateReduceFunctionsRule.java#L64 val ds = env.fromElements( (1.0f, 1), (1.0f, 2)).toTable(tEnv) tEnv.registerTable("MyTable", ds) val sqlQuery = "SELECT " + "SQRT((SUM(a*a) - SUM(a)*SUM(a)/COUNT(a))/COUNT(a)) "+ "from (select _1 as a from MyTable)" tEnv.sql(sqlQuery).toDataSet[Row].collect().foreach(print) I got exception: org.apache.flink.runtime.client.JobExecutionException: Job execution failed. ....... Caused by: java.lang.Exception: The user defined 'open(Configuration)' method in class org.apache.flink.api.table.runtime.FlatMapRunner caused an exception: Table program cannot be compiled. This is a bug. Please file an issue. at org.apache.flink.runtime.operators.BatchTask.openUserCode(BatchTask.java:1337) at org.apache.flink.runtime.operators.chaining.ChainedFlatMapDriver.openTask(ChainedFlatMapDriver.java:47) ..... Caused by: org.codehaus.commons.compiler.CompileException: Line 59, Column 57: No applicable constructor/method found for actual parameters "float, java.math.BigDecimal"; candidates are: "public static double org.apache.calcite.runtime.SqlFunctions.power(long, java.math.BigDecimal)", "public static double org.apache.calcite.runtime.SqlFunctions.power(long, long)", "public static double org.apache.calcite.runtime.SqlFunctions.power(double, double)" at org.codehaus.janino.UnitCompiler.compileError(UnitCompiler.java:10062) at org.codehaus.janino.UnitCompiler.findMostSpecificIInvocable(UnitCompiler.java:7476) In this time if I am execute for int column ('_2') i getting result is equals '0.0' What am I doing wrong? Best regards, Anton Mushin