|
| 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.recent; |
| 21 | + |
| 22 | +import org.apache.iotdb.it.env.EnvFactory; |
| 23 | +import org.apache.iotdb.it.framework.IoTDBTestRunner; |
| 24 | +import org.apache.iotdb.itbase.category.TableClusterIT; |
| 25 | +import org.apache.iotdb.itbase.category.TableLocalStandaloneIT; |
| 26 | +import org.apache.iotdb.rpc.IoTDBConnectionException; |
| 27 | +import org.apache.iotdb.rpc.StatementExecutionException; |
| 28 | + |
| 29 | +import org.junit.AfterClass; |
| 30 | +import org.junit.BeforeClass; |
| 31 | +import org.junit.Test; |
| 32 | +import org.junit.experimental.categories.Category; |
| 33 | +import org.junit.runner.RunWith; |
| 34 | + |
| 35 | +import static org.apache.iotdb.db.it.utils.TestUtils.prepareTableData; |
| 36 | +import static org.apache.iotdb.db.it.utils.TestUtils.tableResultSetEqualTest; |
| 37 | + |
| 38 | +@RunWith(IoTDBTestRunner.class) |
| 39 | +@Category({TableLocalStandaloneIT.class, TableClusterIT.class}) |
| 40 | +public class IoTDBQueryAttributeTableIT { |
| 41 | + protected static final String DATABASE_NAME = "test_db"; |
| 42 | + protected static final String[] createSqls = |
| 43 | + new String[] { |
| 44 | + "CREATE DATABASE " + DATABASE_NAME, |
| 45 | + "USE " + DATABASE_NAME, |
| 46 | + "create table t1(device STRING TAG, a1 STRING ATTRIBUTE, s1 INT32 FIELD)", |
| 47 | + "insert into t1 (time, device, a1, s1) values (1, 'd1', 'ATTR1', 1)" |
| 48 | + }; |
| 49 | + |
| 50 | + @BeforeClass |
| 51 | + public static void setUp() throws Exception { |
| 52 | + EnvFactory.getEnv().initClusterEnvironment(); |
| 53 | + prepareTableData(createSqls); |
| 54 | + } |
| 55 | + |
| 56 | + @AfterClass |
| 57 | + public static void tearDown() throws Exception { |
| 58 | + EnvFactory.getEnv().cleanClusterEnvironment(); |
| 59 | + } |
| 60 | + |
| 61 | + @Test |
| 62 | + public void test1() throws IoTDBConnectionException, StatementExecutionException { |
| 63 | + String[] expectedHeader = new String[] {"time", "device", "a1", "s1"}; |
| 64 | + String[] retArray = new String[] {"1970-01-01T00:00:00.001Z,d1,ATTR1,1,"}; |
| 65 | + tableResultSetEqualTest( |
| 66 | + "select * from t1 where lower(a1) = 'attr1' and device = 'd1'", |
| 67 | + expectedHeader, |
| 68 | + retArray, |
| 69 | + DATABASE_NAME); |
| 70 | + } |
| 71 | +} |
0 commit comments