uranusjr commented on code in PR #68983:
URL: https://github.com/apache/airflow/pull/68983#discussion_r3488399255


##########
java-sdk/example/src/java/org/apache/airflow/example/XComCastingExample.java:
##########
@@ -0,0 +1,65 @@
+/*
+ * 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.airflow.example;
+
+import static java.lang.System.Logger.Level.INFO;
+
+import org.apache.airflow.sdk.*;
+
+// Exercises numeric XCom handling end to end: a value flows int -> long -> 
double
+// across tasks (wire integers arrive as Long, so each hop widens via Number), 
and a
+// boxed parameter stays null when the upstream XCom is absent.
[email protected](id = "java_xcom_casting_example")
+public class XComCastingExample {
+  private static final System.Logger log = 
System.getLogger(XComCastingExample.class.getName());
+
+  @Builder.Task(id = "produce_number")
+  public int produceNumber() {
+    log.log(INFO, "Producing int 7");
+    return 7;
+  }
+
+  @Builder.Task(id = "widen_to_long")
+  public long widenToLong(@Builder.XCom(task = "produce_number") long value) {
+    log.log(INFO, "Got long {0}", value);

Review Comment:
   I wonder if we should allow parameter type int here. It feels natural if you 
pushed an int.



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