Au-Miner commented on PR #30080:
URL: https://github.com/apache/flink/pull/30080#issuecomment-7151901415

   > **Compiled-plan execution fails for `UNIX_TIMESTAMP(ts)` at `08cb2981`.** 
Direct execution of the same SQL succeeds, and the compiled-plan round trip 
succeeds at the parent commit `b1f051d0`. A job loading this plan fails before 
it starts.
   > 
   > Minimal reproduction in a `JsonPlanTestBase` subclass:
   > 
   > @Test
   > void restoresUnixTimestamp() throws Exception {
   >     tableEnv.getConfig().setLocalTimeZone(ZoneId.of("UTC"));
   >     createTestValuesSourceTable(
   >             "InputTimes", List.of(Row.of("2020-01-01 00:00:00")), "ts 
STRING");
   >     createTestValuesSinkTable("Result", "now BIGINT", "parsed BIGINT");
   > 
   >     String sql = "INSERT INTO Result "
   >             + "SELECT UNIX_TIMESTAMP(), UNIX_TIMESTAMP(ts) FROM 
InputTimes";
   >     String json = tableEnv.compilePlanSql(sql).asJsonString();
   >     
tableEnv.loadPlan(PlanReference.fromJsonString(json)).execute().await();
   > }
   > The expected row has `parsed = 1577836800`. Instead, the PR commit throws 
`CodeGenException: Unsupported call: UNIX_TIMESTAMP(STRING)` during code 
generation. 
[`deserializeCall`](https://github.com/apache/flink/blob/08cb2981020f14a5fbbf59bb98b62ef8a9dc9d30/flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/plan/nodes/exec/serde/RexNodeJsonDeserializer.java#L375-L396)
 resolves the operator before reading its operands, and [the 
lookup](https://github.com/apache/flink/blob/08cb2981020f14a5fbbf59bb98b62ef8a9dc9d30/flink-table/flink-table-planner/src/main/java/org/apache/flink/table/planner/plan/nodes/exec/serde/RexNodeJsonDeserializer.java#L610-L628)
 returns the first same-name candidate. Could restoration select the overload 
by the serialized operand count? A round-trip test with a nonconstant `ts` 
would cover this path.
   
   Thank you for discovering this issue. Yes, because of the introduction of 
the parameterless UNIX_TIMESTAMP, the current deserialization process results 
in multiple built-in functions, and the default first one is taken as the 
deserialization result. This logic should be replaced with selecting different 
built-in functions based on the number of overloaded parameters. I will try to 
fix this logic and address it as a pre-PR. What do you think


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