cloud-fan commented on a change in pull request #27013: [SPARK-30356][SQL] Codegen support for the function str_to_map URL: https://github.com/apache/spark/pull/27013#discussion_r361588857
########## File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/complexTypeCreator.scala ########## @@ -451,5 +452,24 @@ case class StringToMap(text: Expression, pairDelim: Expression, keyValueDelim: E mapBuilder.build() } + override protected def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = { + val builderTerm = ctx.addReferenceObj("mapBuilder", mapBuilder) + val keyValues = ctx.freshName("kvs") + val idx = ctx.freshName("i") + + nullSafeCodeGen(ctx, ev, (text, pd, kvd) => + s""" + |int $idx = 0; + |UTF8String[] $keyValues = $text.split($pd, -1); + |while ($idx < $keyValues.length) { Review comment: shall we use for loop? then we don't need to declare `int idx` outside of the loop. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org