[ https://issues.apache.org/jira/browse/SPARK-19214?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15834263#comment-15834263 ]
Alexander Alexandrov commented on SPARK-19214: ---------------------------------------------- [~sowen] I understand that a PR against the current mainline is not ideal due to backwards compatibility. Nevertheless, accessing the grouping key under different names depending on the key type and under the name `value` is confusing (to say the least), especially given the (*key*, *value*) nomenclature used throughout all other dataflow APIs (even in Spark). I hope that some committers will agree with me and support me for merging this in the next API breaking release. > Inconsistencies between DataFrame and Dataset APIs > -------------------------------------------------- > > Key: SPARK-19214 > URL: https://issues.apache.org/jira/browse/SPARK-19214 > Project: Spark > Issue Type: Improvement > Affects Versions: 2.0.0, 2.0.1, 2.0.2, 2.1.0 > Reporter: Alexander Alexandrov > Priority: Trivial > > I am not sure whether this has been reported already, but there are some > confusing & annoying inconsistencies when programming the same expression in > the Dataset and the DataFrame APIs. > Consider the following minimal example executed in a Spark Shell: > {code} > case class Point(x: Int, y: Int, z: Int) > val ps = spark.createDataset(for { > x <- 1 to 10; > y <- 1 to 10; > z <- 1 to 10 > } yield Point(x, y, z)) > // Problem 1: > // count produces different fields in the Dataset / DataFrame variants > // count() on grouped DataFrame: field name is `count` > ps.groupBy($"x").count().printSchema > // root > // |-- x: integer (nullable = false) > // |-- count: long (nullable = false) > // count() on grouped Dataset: field name is `count(1)` > ps.groupByKey(_.x).count().printSchema > // root > // |-- value: integer (nullable = true) > // |-- count(1): long (nullable = false) > // Problem 2: > // groupByKey produces different `key` field name depending > // on the result type > // this is especially confusing in the first case below (simple key types) > // where the key field is actually named `value` > // simple key types > ps.groupByKey(p => p.x).count().printSchema > // root > // |-- value: integer (nullable = true) > // |-- count(1): long (nullable = false) > // complex key types > ps.groupByKey(p => (p.x, p.y)).count().printSchema > // root > // |-- key: struct (nullable = false) > // | |-- _1: integer (nullable = true) > // | |-- _2: integer (nullable = true) > // |-- count(1): long (nullable = false) > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org