shuai-xu commented on code in PR #9893: URL: https://github.com/apache/incubator-gluten/pull/9893#discussion_r2131620647
########## gluten-flink/runtime/src/main/java/org/apache/gluten/vectorized/ArrowVectorAccessor.java: ########## @@ -21,15 +21,10 @@ import org.apache.flink.table.data.GenericArrayData; import org.apache.flink.table.data.GenericMapData; import org.apache.flink.table.data.GenericRowData; +import org.apache.flink.table.data.TimestampData; import org.apache.flink.table.data.binary.BinaryStringData; -import org.apache.arrow.vector.BigIntVector; -import org.apache.arrow.vector.BitVector; -import org.apache.arrow.vector.DateDayVector; -import org.apache.arrow.vector.FieldVector; -import org.apache.arrow.vector.Float8Vector; -import org.apache.arrow.vector.IntVector; -import org.apache.arrow.vector.VarCharVector; +import org.apache.arrow.vector.*; Review Comment: It's better not use * in import. ########## gluten-flink/ut/src/test/java/org/apache/gluten/table/runtime/stream/custom/NexmarkTest.java: ########## @@ -0,0 +1,216 @@ +/* + * 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.Velox4jEnvironment; + +import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment; +import org.apache.flink.table.api.EnvironmentSettings; +import org.apache.flink.table.api.TableResult; +import org.apache.flink.table.api.bridge.java.StreamTableEnvironment; +import org.apache.flink.types.Row; +import org.apache.flink.util.CloseableIterator; + +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +public class NexmarkTest { + + private static final Logger LOG = LoggerFactory.getLogger(NexmarkTest.class); + + private StreamExecutionEnvironment env; + private StreamTableEnvironment tEnv; + + @BeforeAll + public static void setupAll() { + LOG.info("NexmarkTest setup"); + Velox4jEnvironment.initializeOnce(); + } + + @BeforeEach + public void setup() { + env = StreamExecutionEnvironment.getExecutionEnvironment(); + env.setParallelism(1); + + EnvironmentSettings settings = EnvironmentSettings.newInstance().inStreamingMode().build(); + tEnv = StreamTableEnvironment.create(env, settings); + } + + @Test + void testNexmarkDDLGeneration() { + String createDatagenTable = Review Comment: Can we put the the queries in files, and read them from file like TPC-H tests in gluten? ########## gluten-flink/ut/src/test/java/org/apache/gluten/table/runtime/stream/custom/NexmarkTest.java: ########## @@ -0,0 +1,216 @@ +/* + * 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.Velox4jEnvironment; + +import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment; +import org.apache.flink.table.api.EnvironmentSettings; +import org.apache.flink.table.api.TableResult; +import org.apache.flink.table.api.bridge.java.StreamTableEnvironment; +import org.apache.flink.types.Row; +import org.apache.flink.util.CloseableIterator; + +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +public class NexmarkTest { + + private static final Logger LOG = LoggerFactory.getLogger(NexmarkTest.class); + + private StreamExecutionEnvironment env; + private StreamTableEnvironment tEnv; + + @BeforeAll + public static void setupAll() { + LOG.info("NexmarkTest setup"); + Velox4jEnvironment.initializeOnce(); + } + + @BeforeEach + public void setup() { + env = StreamExecutionEnvironment.getExecutionEnvironment(); + env.setParallelism(1); + + EnvironmentSettings settings = EnvironmentSettings.newInstance().inStreamingMode().build(); + tEnv = StreamTableEnvironment.create(env, settings); + } + + @Test + void testNexmarkDDLGeneration() { + String createDatagenTable = + "CREATE TABLE datagen (" + + " event_type INT," + + " person ROW<id BIGINT, name STRING, dateTime TIMESTAMP(3)>," + + " auction ROW<id BIGINT, itemName STRING, dateTime TIMESTAMP(3)>," + + " bid ROW<auction BIGINT, bidder BIGINT, price BIGINT, dateTime TIMESTAMP(3), extra STRING>" + + ") WITH (" + + " 'connector' = 'datagen'," + + " 'number-of-rows' = '10'" + + ")"; + + TableResult result = tEnv.executeSql(createDatagenTable); + assertThat(result.getJobClient().isPresent()).isFalse(); + + String createBidTable = + "CREATE TABLE bid (" + + " auction BIGINT," + + " bidder BIGINT," + + " price BIGINT," + + " dateTime TIMESTAMP(3)," + + " extra STRING," + + " WATERMARK FOR dateTime AS dateTime - INTERVAL '4' SECOND" + + ") WITH (" + + " 'connector' = 'datagen'," + + " 'number-of-rows' = '5'" + + ")"; + + TableResult bidResult = tEnv.executeSql(createBidTable); + assertThat(bidResult.getJobClient().isPresent()).isFalse(); + + String describeQuery = "DESCRIBE datagen"; + TableResult describeResult = tEnv.executeSql(describeQuery); + + List<Row> schemaRows = new ArrayList<>(); + try (CloseableIterator<Row> iterator = describeResult.collect()) { + while (iterator.hasNext()) { + schemaRows.add(iterator.next()); + } + } catch (Exception e) { + LOG.error("Error collecting schema info", e); + } + + assertThat(schemaRows).hasSize(4); + } + + @Test + void testNexmarkQ0Query() { + String createSourceTable = Review Comment: As above, we can copy the nexmark quiries in files and run them. Check the supported ones can run without fallback and then read the results to verify correctness. -- 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]
