|
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | + * or more contributor license agreements. See the NOTICE file |
| 4 | + * distributed with this work for additional information |
| 5 | + * regarding copyright ownership. The ASF licenses this file |
| 6 | + * to you under the Apache License, Version 2.0 (the |
| 7 | + * "License"); you may not use this file except in compliance |
| 8 | + * with the License. You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | + |
| 20 | +package org.apache.iotdb.relational.it.query.view.recent; |
| 21 | + |
| 22 | +import org.apache.iotdb.isession.ITableSession; |
| 23 | +import org.apache.iotdb.isession.SessionDataSet; |
| 24 | +import org.apache.iotdb.it.env.EnvFactory; |
| 25 | +import org.apache.iotdb.itbase.category.TableClusterIT; |
| 26 | +import org.apache.iotdb.itbase.category.TableLocalStandaloneIT; |
| 27 | +import org.apache.iotdb.rpc.IoTDBConnectionException; |
| 28 | +import org.apache.iotdb.rpc.StatementExecutionException; |
| 29 | + |
| 30 | +import org.junit.After; |
| 31 | +import org.junit.Assert; |
| 32 | +import org.junit.Before; |
| 33 | +import org.junit.Test; |
| 34 | +import org.junit.experimental.categories.Category; |
| 35 | +import org.junit.runner.RunWith; |
| 36 | +import org.junit.runners.Parameterized; |
| 37 | + |
| 38 | +import java.util.Arrays; |
| 39 | +import java.util.Collection; |
| 40 | + |
| 41 | +import static org.apache.iotdb.db.it.utils.TestUtils.prepareData; |
| 42 | +import static org.apache.iotdb.db.it.utils.TestUtils.prepareTableData; |
| 43 | + |
| 44 | +@RunWith(Parameterized.class) |
| 45 | +@Category({TableLocalStandaloneIT.class, TableClusterIT.class}) |
| 46 | +public class IoTDBTableViewQueryWithNotMatchedDataTypeIT { |
| 47 | + |
| 48 | + protected static final String DATABASE_NAME = "test"; |
| 49 | + |
| 50 | + private final boolean aligned; |
| 51 | + |
| 52 | + protected static final String[] createTreeAlignedDataSqls = |
| 53 | + new String[] { |
| 54 | + "CREATE ALIGNED TIMESERIES root.db.battery.b1(current FLOAT)", |
| 55 | + "INSERT INTO root.db.battery.b1(time, current) aligned values (1, 1)", |
| 56 | + }; |
| 57 | + |
| 58 | + protected static final String[] createTreeNonAlignedDataSqls = |
| 59 | + new String[] { |
| 60 | + "CREATE TIMESERIES root.db.battery.b1.current FLOAT", |
| 61 | + "INSERT INTO root.db.battery.b1(time, current) values (1, 1)", |
| 62 | + }; |
| 63 | + |
| 64 | + protected static String[] createTableSqls = { |
| 65 | + "create database " + DATABASE_NAME, |
| 66 | + "use " + DATABASE_NAME, |
| 67 | + "CREATE VIEW view1 (battery TAG, current BLOB FIELD) as root.db.battery.**", |
| 68 | + }; |
| 69 | + |
| 70 | + public IoTDBTableViewQueryWithNotMatchedDataTypeIT(boolean aligned) { |
| 71 | + this.aligned = aligned; |
| 72 | + } |
| 73 | + |
| 74 | + @Parameterized.Parameters(name = "aligned={0}") |
| 75 | + public static Collection<Object[]> data() { |
| 76 | + return Arrays.asList(new Object[][] {{true}, {false}}); |
| 77 | + } |
| 78 | + |
| 79 | + @Before |
| 80 | + public void setUp() throws Exception { |
| 81 | + EnvFactory.getEnv().getConfig().getCommonConfig().setSortBufferSize(128 * 1024); |
| 82 | + EnvFactory.getEnv().getConfig().getCommonConfig().setMaxTsBlockSizeInByte(4 * 1024); |
| 83 | + EnvFactory.getEnv().initClusterEnvironment(); |
| 84 | + prepareData(aligned ? createTreeAlignedDataSqls : createTreeNonAlignedDataSqls); |
| 85 | + prepareTableData(createTableSqls); |
| 86 | + } |
| 87 | + |
| 88 | + @After |
| 89 | + public void tearDown() throws Exception { |
| 90 | + EnvFactory.getEnv().cleanClusterEnvironment(); |
| 91 | + } |
| 92 | + |
| 93 | + @Test |
| 94 | + public void test() throws IoTDBConnectionException, StatementExecutionException { |
| 95 | + try (ITableSession session = EnvFactory.getEnv().getTableSessionConnection()) { |
| 96 | + session.executeNonQueryStatement("USE " + DATABASE_NAME); |
| 97 | + SessionDataSet sessionDataSet = session.executeQueryStatement("select * from view1"); |
| 98 | + Assert.assertFalse(sessionDataSet.hasNext()); |
| 99 | + sessionDataSet.close(); |
| 100 | + } |
| 101 | + } |
| 102 | +} |
0 commit comments