PHILO-HE commented on code in PR #5600: URL: https://github.com/apache/incubator-gluten/pull/5600#discussion_r1595188896
########## gluten-core/src/main/scala/org/apache/spark/sql/catalyst/expressions/JsonTupleExplode.scala: ########## @@ -0,0 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.spark.sql.catalyst.expressions + +/** Used when transformed by JsonTuple. The behavior are the same with Explode. */ Review Comment: Suggestion: Used for transforming JsonTuple. The behavior is ... ########## backends-velox/src/main/scala/org/apache/gluten/execution/GenerateExecTransformer.scala: ########## @@ -146,20 +147,48 @@ object PullOutGenerateProjectHelper extends PullOutProjectHelper { // generator.child is other expression, e.g Literal/CreateArray/CreateMap expressionMap.values.head } - Seq(newGeneratorChild) + val newGeneratorChildren = Seq(newGeneratorChild) + + // Avoid using elimainateProjectList to create the project list + // because newGeneratorChild can be a duplicated Attribute in generate.child.output. + // The native side identifies the last field of projection as generator's input. + generate.copy( + generator = + generate.generator.withNewChildren(newGeneratorChildren).asInstanceOf[Generator], + child = ProjectExec(generate.child.output ++ newGeneratorChildren, generate.child) + ) + case JsonTuple(Seq(jsonObj, jsonPaths @ _*)) => + val getJsons: IndexedSeq[Expression] = { + jsonPaths.map { + case jsonPath if jsonPath.foldable => + Option(jsonPath.eval()) match { + case Some(path) => + GetJsonObject(jsonObj, Literal.create(JSON_PATH_PREFIX + path)) + case _ => + Literal.create(null) + } + case jsonPath => + GetJsonObject(jsonObj, Concat(Seq(Literal.create(JSON_PATH_PREFIX), jsonPath))) Review Comment: The prefix is just for adapting to GetJsonObject. Maybe, we can remove this handling in the future by making path without "$." recognized. It would be good to leave a "TODO" comment here. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
