[ https://issues.apache.org/jira/browse/SPARK-19416?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15852876#comment-15852876 ]
koert kuipers commented on SPARK-19416: --------------------------------------- would it be simpler to ban columns with a period in the name? > Dataset.schema is inconsistent with Dataset in handling columns with periods > ---------------------------------------------------------------------------- > > Key: SPARK-19416 > URL: https://issues.apache.org/jira/browse/SPARK-19416 > Project: Spark > Issue Type: Bug > Components: SQL > Affects Versions: 1.6.3, 2.0.2, 2.1.0, 2.2.0 > Reporter: Joseph K. Bradley > Priority: Minor > > When you have a DataFrame with a column with a period in its name, the API is > inconsistent about how to quote the column name. > Here's a reproduction: > {code} > import org.apache.spark.sql.functions.col > val rows = Seq( > ("foo", 1), > ("bar", 2) > ) > val df = spark.createDataFrame(rows).toDF("a.b", "id") > {code} > These methods are all consistent: > {code} > df.select("a.b") // fails > df.select("`a.b`") // succeeds > df.select(col("a.b")) // fails > df.select(col("`a.b`")) // succeeds > df("a.b") // fails > df("`a.b`") // succeeds > {code} > But {{schema}} is inconsistent: > {code} > df.schema("a.b") // succeeds > df.schema("`a.b`") // fails > {code} > "fails" produces error messages like: > {code} > org.apache.spark.sql.AnalysisException: cannot resolve '`a.b`' given input > columns: [a.b, id];; > 'Project ['a.b] > +- Project [_1#1511 AS a.b#1516, _2#1512 AS id#1517] > +- LocalRelation [_1#1511, _2#1512] > at > org.apache.spark.sql.catalyst.analysis.package$AnalysisErrorAt.failAnalysis(package.scala:42) > at > org.apache.spark.sql.catalyst.analysis.CheckAnalysis$$anonfun$checkAnalysis$1$$anonfun$apply$2.applyOrElse(CheckAnalysis.scala:77) > at > org.apache.spark.sql.catalyst.analysis.CheckAnalysis$$anonfun$checkAnalysis$1$$anonfun$apply$2.applyOrElse(CheckAnalysis.scala:74) > at > org.apache.spark.sql.catalyst.trees.TreeNode$$anonfun$transformUp$1.apply(TreeNode.scala:310) > at > org.apache.spark.sql.catalyst.trees.TreeNode$$anonfun$transformUp$1.apply(TreeNode.scala:310) > at > org.apache.spark.sql.catalyst.trees.CurrentOrigin$.withOrigin(TreeNode.scala:70) > at > org.apache.spark.sql.catalyst.trees.TreeNode.transformUp(TreeNode.scala:309) > at > org.apache.spark.sql.catalyst.plans.QueryPlan.transformExpressionUp$1(QueryPlan.scala:282) > at > org.apache.spark.sql.catalyst.plans.QueryPlan.org$apache$spark$sql$catalyst$plans$QueryPlan$$recursiveTransform$2(QueryPlan.scala:292) > at > org.apache.spark.sql.catalyst.plans.QueryPlan$$anonfun$org$apache$spark$sql$catalyst$plans$QueryPlan$$recursiveTransform$2$1.apply(QueryPlan.scala:296) > at > scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234) > at > scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234) > at > scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59) > at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:48) > at scala.collection.TraversableLike$class.map(TraversableLike.scala:234) > at scala.collection.AbstractTraversable.map(Traversable.scala:104) > at > org.apache.spark.sql.catalyst.plans.QueryPlan.org$apache$spark$sql$catalyst$plans$QueryPlan$$recursiveTransform$2(QueryPlan.scala:296) > at > org.apache.spark.sql.catalyst.plans.QueryPlan$$anonfun$7.apply(QueryPlan.scala:301) > at > org.apache.spark.sql.catalyst.trees.TreeNode.mapProductIterator(TreeNode.scala:188) > at > org.apache.spark.sql.catalyst.plans.QueryPlan.transformExpressionsUp(QueryPlan.scala:301) > at > org.apache.spark.sql.catalyst.analysis.CheckAnalysis$$anonfun$checkAnalysis$1.apply(CheckAnalysis.scala:74) > at > org.apache.spark.sql.catalyst.analysis.CheckAnalysis$$anonfun$checkAnalysis$1.apply(CheckAnalysis.scala:67) > at > org.apache.spark.sql.catalyst.trees.TreeNode.foreachUp(TreeNode.scala:128) > at > org.apache.spark.sql.catalyst.analysis.CheckAnalysis$class.checkAnalysis(CheckAnalysis.scala:67) > at > org.apache.spark.sql.catalyst.analysis.Analyzer.checkAnalysis(Analyzer.scala:57) > at > org.apache.spark.sql.execution.QueryExecution.assertAnalyzed(QueryExecution.scala:48) > at org.apache.spark.sql.Dataset$.ofRows(Dataset.scala:63) > at > org.apache.spark.sql.Dataset.org$apache$spark$sql$Dataset$$withPlan(Dataset.scala:2822) > at org.apache.spark.sql.Dataset.select(Dataset.scala:1121) > at org.apache.spark.sql.Dataset.select(Dataset.scala:1139) > at > line9667c6d14e79417280e5882aa52e0de727.$read$$iw$$iw$$iw$$iw.<init>(<console>:34) > at > line9667c6d14e79417280e5882aa52e0de727.$read$$iw$$iw$$iw.<init>(<console>:41) > at > line9667c6d14e79417280e5882aa52e0de727.$read$$iw$$iw.<init>(<console>:43) > at line9667c6d14e79417280e5882aa52e0de727.$read$$iw.<init>(<console>:45) > at > line9667c6d14e79417280e5882aa52e0de727.$eval$.$print$lzycompute(<console>:7) > at line9667c6d14e79417280e5882aa52e0de727.$eval$.$print(<console>:6) > {code} > "succeeds" produces: > {code} > org.apache.spark.sql.DataFrame = [a.b: string] > {code} -- This message was sent by Atlassian JIRA (v6.3.15#6346) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org