felipepessoto commented on code in PR #13041:
URL: https://github.com/apache/gluten/pull/13041#discussion_r4471742562


##########
cpp/velox/substrait/VeloxToSubstraitExpr.cc:
##########
@@ -99,9 +99,45 @@ const ::substrait::Expression_Literal& 
toSubstraitNullLiteral(
   return *substraitField;
 }
 
+const ::substrait::Expression_Literal& toSubstraitNullLiteral(
+    google::protobuf::Arena& arena,
+    const velox::TypePtr& type) {
+  auto nestedType = type;
+  while (nestedType->isArray()) {
+    nestedType = nestedType->asArray().elementType();
+  }
+  // Preserve physical-kind encoding for non-timestamp nulls.
+  if (nestedType->kind() != TypeKind::TIMESTAMP) {
+    return toSubstraitNullLiteral(arena, type->kind());
+  }
+  ::substrait::Expression_Literal* substraitField =

Review Comment:
   The limitation is the `TypeKind` argument. Both Velox `TIMESTAMP()` and 
`TIMESTAMP_UTC()` have `TypeKind::TIMESTAMP`, but their typed nulls need 
different Substrait types: `precision_timestamp_tz` and `precision_timestamp`, 
respectively. Passing only the kind loses that distinction.
   
   The `TypePtr` overload preserves the logical type, including element types 
for null timestamp arrays, and reuses the existing type converter. It delegates 
non-timestamp nulls to the original overload to keep their encoding unchanged.
   
   We could instead change the original function to accept the full type, but 
adding a timestamp case to its current signature would not be sufficient.



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

Reply via email to