zoudan commented on code in PR #23984:
URL: https://github.com/apache/flink/pull/23984#discussion_r1439369220
##########
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/codegen/CodeGenUtils.scala:
##########
@@ -124,14 +124,27 @@ object CodeGenUtils {
private val nameCounter = new AtomicLong
- def newName(name: String): String = {
- s"$name$$${nameCounter.getAndIncrement}"
+ def newName(context: CodeGeneratorContext = null, name: String): String = {
Review Comment:
Parameter section with *-parameter is not allowed to have default arguments
##########
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/codegen/CodeGenUtils.scala:
##########
@@ -124,14 +124,27 @@ object CodeGenUtils {
private val nameCounter = new AtomicLong
- def newName(name: String): String = {
- s"$name$$${nameCounter.getAndIncrement}"
+ def newName(context: CodeGeneratorContext = null, name: String): String = {
+ if (context == null || context.getNameCounter == null) {
+ // Add an 'i' in the middle to distinguish from nameCounter in
CodeGeneratorContext
+ // and avoid naming conflicts.
+ s"$name$$i${nameCounter.getAndIncrement}"
+ } else {
+ s"$name$$${context.getNameCounter.getAndIncrement}"
+ }
}
- def newNames(names: String*): Seq[String] = {
+ def newNames(context: CodeGeneratorContext, names: String*): Seq[String] = {
require(names.toSet.size == names.length, "Duplicated names")
- val newId = nameCounter.getAndIncrement
- names.map(name => s"$name$$$newId")
+ if (context == null || context.getNameCounter == null) {
Review Comment:
The returned new names use the same index, I keep it the same as before. So,
I did not call `newName`
--
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]