snuyanzin commented on code in PR #26862:
URL: https://github.com/apache/flink/pull/26862#discussion_r2251146191


##########
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/codegen/CodeGenUtils.scala:
##########
@@ -312,6 +310,17 @@ object CodeGenUtils {
     case _ => "null"
   }
 
+  /**
+   * Gets a properly typed default value for a primitive type. For example: 
((short) -1) for
+   * SMALLINT, ((byte) -1) for TINYINT. This ensures the generated code 
compiles correctly when the
+   * default value is used in method calls expecting specific primitive types.
+   */
+  def primitiveDefaultValueWithCast(logicalType: LogicalType): String = {
+    val resultTerm = primitiveDefaultValue(logicalType)
+    val resultTypeTerm = primitiveTypeTermForType(logicalType)
+    s"(($resultTypeTerm) $resultTerm)"
+  }

Review Comment:
   isn't this code becoming more error prone since now need to remember that 
`primitiveDefaultValue` doesn't work properly and need to call extra cast 
separately?
   
   Also `primitiveDefaultValue` doesn't seem following scaladoc ...



-- 
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]

Reply via email to