philo-he commented on code in PR #13455: URL: https://github.com/apache/gluten/pull/13455#discussion_r4440250354
########## gluten-flink/ut/src/test/java/org/apache/gluten/table/runtime/stream/custom/CurrentTimeFunctionsTest.java: ########## @@ -0,0 +1,71 @@ +/* + * 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.gluten.table.runtime.stream.custom; + +import org.apache.gluten.table.runtime.stream.common.GlutenStreamingTestBase; + +import org.apache.flink.types.Row; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.time.LocalTime; +import java.util.Arrays; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +class CurrentTimeFunctionsTest extends GlutenStreamingTestBase { + + @Override + @BeforeEach + public void before() throws Exception { + super.before(); + } + + @Test + void testCurrentTimeIsMillisOfDay() { + List<Row> rows = Arrays.asList(Row.of(1), Row.of(2), Row.of(3)); + createSimpleBoundedValuesTable("tblCT", "x int", rows); + String query = "select x, CAST(CURRENT_TIME AS TIME) from tblCT"; + // The velox print sink renders TIME as the underlying INT millis-of-day; + // each row must be close to the local wall clock. + List<String> result = runQuery(query); + assertThat(result).hasSize(3); + int nowMillis = (int) (LocalTime.now().toNanoOfDay() / 1_000_000); + for (int i = 0; i < result.size(); i++) { + String prefix = "+I[" + (i + 1) + ", "; + assertThat(result.get(i)).startsWith(prefix).endsWith("]"); + int millis = + Integer.parseInt(result.get(i).substring(prefix.length(), result.get(i).length() - 1)); + assertThat(millis).isBetween(0, 86_400_000 - 1); + long delta = Math.abs(millis - nowMillis); + delta = Math.min(delta, 86_400_000L - delta); // midnight wraparound + assertThat(delta).isLessThanOrEqualTo(60_000L); + } + } + + @Test + void testCurrentTimeComparisons() { + List<Row> rows = Arrays.asList(Row.of(1), Row.of(2)); + createSimpleBoundedValuesTable("tblCT2", "x int", rows); + // TIME literals become INT millis-of-day constants. + String query = + "select x, CURRENT_TIME > TIME '00:00:01', CURRENT_TIME < TIME '23:59:59' from tblCT2"; Review Comment: Could we keep evaluating CURRENT_TIME, but use inclusive bounds covering the entire day, such as >= TIME '00:00:00' and <= TIME '23:59:59.999'? The current strict comparisons can correctly return false near midnight, so always expecting true makes the test flaky. ########## gluten-flink/ut/log/taskmanager.out: ########## Review Comment: Was this added by mistake? ########## gluten-flink/docs/Flink.md: ########## @@ -48,7 +48,7 @@ As some features have not been committed to upstream, you have to use the follow ## fetch velox4j code git clone -b gluten-20260829 https://github.com/bigo-sg/velox4j.git cd velox4j -git reset --hard 2d08448f556bff669fe413874d04dd8cd96f65b2 +git reset --hard 540ed0535f0fe73239f9cd67f4e6d102457e2c51 Review Comment: Can we create a file to maintain the commit hash in one unified place? Then, only modify once and make the version consistently referenced. Before every build, we can execute a version init script. -- 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]
