Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename table concept #14537

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ public static void main(String[] args) {
List<Tablet.ColumnCategory> columnTypeList =
new ArrayList<>(
Arrays.asList(
Tablet.ColumnCategory.ID,
Tablet.ColumnCategory.ID,
Tablet.ColumnCategory.ID,
Tablet.ColumnCategory.TAG,
Tablet.ColumnCategory.TAG,
Tablet.ColumnCategory.TAG,
Tablet.ColumnCategory.ATTRIBUTE,
Tablet.ColumnCategory.MEASUREMENT,
Tablet.ColumnCategory.MEASUREMENT));
Tablet.ColumnCategory.FIELD,
Tablet.ColumnCategory.FIELD));
Tablet tablet = new Tablet("test1", columnNameList, dataTypeList, columnTypeList, 100);
for (long timestamp = 0; timestamp < 100; timestamp++) {
int rowIndex = tablet.getRowSize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,12 @@ public static void main(String[] args) {
List<ColumnCategory> columnTypeList =
new ArrayList<>(
Arrays.asList(
ColumnCategory.ID,
ColumnCategory.ID,
ColumnCategory.ID,
ColumnCategory.TAG,
ColumnCategory.TAG,
ColumnCategory.TAG,
ColumnCategory.ATTRIBUTE,
ColumnCategory.MEASUREMENT,
ColumnCategory.MEASUREMENT));
ColumnCategory.FIELD,
ColumnCategory.FIELD));
Tablet tablet = new Tablet("test1", columnNameList, dataTypeList, columnTypeList, 100);
for (long timestamp = 0; timestamp < 100; timestamp++) {
int rowIndex = tablet.getRowSize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ private Tablet generateTabletAndMeasurementSchema(
for (int i = 0; i < objects.length; i++) {
MeasurementSchema schema = pairs.get(i).left;
measurementSchemas.add(schema);
columnTypes.add(Tablet.ColumnCategory.MEASUREMENT);
columnTypes.add(Tablet.ColumnCategory.FIELD);
switch (schema.getType()) {
case INT64:
objects[i] = createTestDataForInt64();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.apache.tsfile.utils.DateUtils;
import org.apache.tsfile.utils.Pair;
import org.apache.tsfile.write.record.Tablet;
import org.apache.tsfile.write.record.Tablet.ColumnCategory;
import org.apache.tsfile.write.schema.IMeasurementSchema;
import org.apache.tsfile.write.schema.MeasurementSchema;
import org.junit.Test;
Expand Down Expand Up @@ -454,12 +455,12 @@ private Tablet generateTabletAndMeasurementSchema(

private List<Tablet.ColumnCategory> generateTabletColumnCategory(int size) {
List<Tablet.ColumnCategory> columnTypes = new ArrayList<>(size);
columnTypes.add(Tablet.ColumnCategory.ID);
columnTypes.add(Tablet.ColumnCategory.ID);
columnTypes.add(Tablet.ColumnCategory.ID);
columnTypes.add(Tablet.ColumnCategory.ID);
columnTypes.add(Tablet.ColumnCategory.TAG);
columnTypes.add(Tablet.ColumnCategory.TAG);
columnTypes.add(Tablet.ColumnCategory.TAG);
columnTypes.add(Tablet.ColumnCategory.TAG);
for (int i = 0; i < size - 4; i++) {
columnTypes.add(Tablet.ColumnCategory.MEASUREMENT);
columnTypes.add(ColumnCategory.FIELD);
}
return columnTypes;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,15 +382,15 @@ public static Tablet generateTablet(

final List<Tablet.ColumnCategory> columnTypes =
Arrays.asList(
Tablet.ColumnCategory.ID,
Tablet.ColumnCategory.MEASUREMENT,
Tablet.ColumnCategory.MEASUREMENT,
Tablet.ColumnCategory.MEASUREMENT,
Tablet.ColumnCategory.MEASUREMENT,
Tablet.ColumnCategory.MEASUREMENT,
Tablet.ColumnCategory.MEASUREMENT,
Tablet.ColumnCategory.MEASUREMENT,
Tablet.ColumnCategory.MEASUREMENT);
Tablet.ColumnCategory.TAG,
Tablet.ColumnCategory.FIELD,
Tablet.ColumnCategory.FIELD,
Tablet.ColumnCategory.FIELD,
Tablet.ColumnCategory.FIELD,
Tablet.ColumnCategory.FIELD,
Tablet.ColumnCategory.FIELD,
Tablet.ColumnCategory.FIELD,
Tablet.ColumnCategory.FIELD);
Tablet tablet =
new Tablet(
tableName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,7 @@ public void testPartialInsertTablet() {
schemaList.add(new MeasurementSchema("s3", TSDataType.INT64));
final List<ColumnCategory> columnTypes =
Arrays.asList(
ColumnCategory.ID,
ColumnCategory.MEASUREMENT,
ColumnCategory.MEASUREMENT,
ColumnCategory.MEASUREMENT);
ColumnCategory.TAG, ColumnCategory.FIELD, ColumnCategory.FIELD, ColumnCategory.FIELD);
Tablet tablet =
new Tablet(
"sg6",
Expand Down Expand Up @@ -578,7 +575,7 @@ public void testInsertCaseSensitivity()
schemaList.add(new MeasurementSchema("attr1", TSDataType.STRING));
schemaList.add(new MeasurementSchema("m1", TSDataType.DOUBLE));
final List<ColumnCategory> columnTypes =
Arrays.asList(ColumnCategory.ID, ColumnCategory.ATTRIBUTE, ColumnCategory.MEASUREMENT);
Arrays.asList(ColumnCategory.TAG, ColumnCategory.ATTRIBUTE, ColumnCategory.FIELD);

long timestamp = 0;

Expand Down Expand Up @@ -626,7 +623,7 @@ public void testInsertCaseSensitivity()
schemaList.add(new MeasurementSchema("attr1", TSDataType.STRING));
schemaList.add(new MeasurementSchema("m1", TSDataType.DOUBLE));
final List<ColumnCategory> columnTypes =
Arrays.asList(ColumnCategory.ID, ColumnCategory.ATTRIBUTE, ColumnCategory.MEASUREMENT);
Arrays.asList(ColumnCategory.TAG, ColumnCategory.ATTRIBUTE, ColumnCategory.FIELD);
List<String> measurementIds =
schemaList.stream()
.map(IMeasurementSchema::getMeasurementName)
Expand Down Expand Up @@ -675,7 +672,7 @@ public void testInsertCaseSensitivity()
schemaList.add(new MeasurementSchema("attr1", TSDataType.STRING));
schemaList.add(new MeasurementSchema("m1", TSDataType.DOUBLE));
final List<ColumnCategory> columnTypes =
Arrays.asList(ColumnCategory.ID, ColumnCategory.ATTRIBUTE, ColumnCategory.MEASUREMENT);
Arrays.asList(ColumnCategory.TAG, ColumnCategory.ATTRIBUTE, ColumnCategory.FIELD);

long timestamp = 0;
Tablet tablet =
Expand Down Expand Up @@ -730,7 +727,7 @@ public void testInsertCaseSensitivity()
schemaList.add(new MeasurementSchema("attr1", TSDataType.STRING));
schemaList.add(new MeasurementSchema("m1", TSDataType.DOUBLE));
final List<ColumnCategory> columnTypes =
Arrays.asList(ColumnCategory.ID, ColumnCategory.ATTRIBUTE, ColumnCategory.MEASUREMENT);
Arrays.asList(ColumnCategory.TAG, ColumnCategory.ATTRIBUTE, ColumnCategory.FIELD);

long timestamp = 0;
Tablet tablet =
Expand Down Expand Up @@ -807,18 +804,18 @@ public void testInsertKeyword() throws IoTDBConnectionException, StatementExecut
schemas.add(new MeasurementSchema("date", TSDataType.DATE));
final List<ColumnCategory> columnTypes =
Arrays.asList(
ColumnCategory.ID,
ColumnCategory.TAG,
ColumnCategory.ATTRIBUTE,
ColumnCategory.MEASUREMENT,
ColumnCategory.MEASUREMENT,
ColumnCategory.MEASUREMENT,
ColumnCategory.MEASUREMENT,
ColumnCategory.MEASUREMENT,
ColumnCategory.MEASUREMENT,
ColumnCategory.MEASUREMENT,
ColumnCategory.MEASUREMENT,
ColumnCategory.MEASUREMENT,
ColumnCategory.MEASUREMENT);
ColumnCategory.FIELD,
ColumnCategory.FIELD,
ColumnCategory.FIELD,
ColumnCategory.FIELD,
ColumnCategory.FIELD,
ColumnCategory.FIELD,
ColumnCategory.FIELD,
ColumnCategory.FIELD,
ColumnCategory.FIELD,
ColumnCategory.FIELD);

long timestamp = 0;
Tablet tablet =
Expand Down Expand Up @@ -949,7 +946,7 @@ public void testInsertTabletWithTTL()
schemaList.add(new MeasurementSchema("id1", TSDataType.STRING));
schemaList.add(new MeasurementSchema("s1", TSDataType.INT64));
final List<ColumnCategory> columnTypes =
Arrays.asList(ColumnCategory.ID, ColumnCategory.MEASUREMENT);
Arrays.asList(ColumnCategory.TAG, ColumnCategory.FIELD);

// all expired
long timestamp = 0;
Expand Down Expand Up @@ -1024,10 +1021,10 @@ public void testInsertUnsequenceData()
schemaList.add(new MeasurementSchema("m2", TSDataType.DOUBLE));
final List<ColumnCategory> columnTypes =
Arrays.asList(
ColumnCategory.ID,
ColumnCategory.TAG,
ColumnCategory.ATTRIBUTE,
ColumnCategory.MEASUREMENT,
ColumnCategory.MEASUREMENT);
ColumnCategory.FIELD,
ColumnCategory.FIELD);

long timestamp = 0;
Tablet tablet =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1477,13 +1477,13 @@ protected static void sessionInsertData1() {
schemaList.add(new MeasurementSchema("bool", TSDataType.BOOLEAN));
final List<Tablet.ColumnCategory> columnTypes =
Arrays.asList(
Tablet.ColumnCategory.ID,
Tablet.ColumnCategory.TAG,
Tablet.ColumnCategory.ATTRIBUTE,
Tablet.ColumnCategory.MEASUREMENT,
Tablet.ColumnCategory.MEASUREMENT,
Tablet.ColumnCategory.MEASUREMENT,
Tablet.ColumnCategory.MEASUREMENT,
Tablet.ColumnCategory.MEASUREMENT);
Tablet.ColumnCategory.FIELD,
Tablet.ColumnCategory.FIELD,
Tablet.ColumnCategory.FIELD,
Tablet.ColumnCategory.FIELD,
Tablet.ColumnCategory.FIELD);
List<String> measurementIds = IMeasurementSchema.getMeasurementNameList(schemaList);
List<TSDataType> dataTypes = IMeasurementSchema.getDataTypeList(schemaList);

Expand Down Expand Up @@ -1532,13 +1532,13 @@ protected static void sessionInsertData2() {
schemaList.add(new MeasurementSchema("bool", TSDataType.BOOLEAN));
final List<Tablet.ColumnCategory> columnTypes =
Arrays.asList(
Tablet.ColumnCategory.ID,
Tablet.ColumnCategory.TAG,
Tablet.ColumnCategory.ATTRIBUTE,
Tablet.ColumnCategory.MEASUREMENT,
Tablet.ColumnCategory.MEASUREMENT,
Tablet.ColumnCategory.MEASUREMENT,
Tablet.ColumnCategory.MEASUREMENT,
Tablet.ColumnCategory.MEASUREMENT);
Tablet.ColumnCategory.FIELD,
Tablet.ColumnCategory.FIELD,
Tablet.ColumnCategory.FIELD,
Tablet.ColumnCategory.FIELD,
Tablet.ColumnCategory.FIELD);
List<String> measurementIds = IMeasurementSchema.getMeasurementNameList(schemaList);
List<TSDataType> dataTypes = IMeasurementSchema.getDataTypeList(schemaList);
List<Object[]> values =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
import org.apache.iotdb.it.env.EnvFactory;
import org.apache.iotdb.it.env.cluster.node.DataNodeWrapper;
import org.apache.iotdb.it.framework.IoTDBTestRunner;
import org.apache.iotdb.itbase.category.ClusterIT;
import org.apache.iotdb.itbase.category.LocalStandaloneIT;
import org.apache.iotdb.itbase.category.RemoteIT;
import org.apache.iotdb.itbase.category.TableClusterIT;
import org.apache.iotdb.itbase.category.TableLocalStandaloneIT;
import org.apache.iotdb.itbase.env.BaseEnv;

import com.google.gson.JsonArray;
Expand All @@ -50,7 +50,7 @@
import static org.junit.Assert.fail;

@RunWith(IoTDBTestRunner.class)
@Category({LocalStandaloneIT.class, ClusterIT.class, RemoteIT.class})
@Category({TableLocalStandaloneIT.class, TableClusterIT.class, RemoteIT.class})
public class IoTDBRestServiceIT {

private int port = 18080;
Expand Down Expand Up @@ -274,7 +274,7 @@ public void testInsertTablet() {
RestUtils.nonQuery(httpClient, port, sqlHandler("test", sql));
}
String json =
"{\"database\":\"test\",\"column_types\":[\"ID\",\"ATTRIBUTE\",\"MEASUREMENT\"],\"timestamps\":[1635232143960,1635232153960,1635232163960,1635232173960,1635232183960],\"column_names\":[\"id1\",\"t1\",\"s1\"],\"data_types\":[\"STRING\",\"STRING\",\"FLOAT\"],\"values\":[[\"a11\",\"true\",11],[\"a11\",\"false\",22],[\"a13\",\"false1\",23],[\"a14\",\"false2\",24],[\"a15\",\"false3\",25]],\"table\":\"sg211\"}";
"{\"database\":\"test\",\"column_types\":[\"TAG\",\"ATTRIBUTE\",\"FIELD\"],\"timestamps\":[1635232143960,1635232153960,1635232163960,1635232173960,1635232183960],\"column_names\":[\"id1\",\"t1\",\"s1\"],\"data_types\":[\"STRING\",\"STRING\",\"FLOAT\"],\"values\":[[\"a11\",\"true\",11],[\"a11\",\"false\",22],[\"a13\",\"false1\",23],[\"a14\",\"false2\",24],[\"a15\",\"false3\",25]],\"table\":\"sg211\"}";
rightInsertTablet(json);
}

Expand All @@ -286,7 +286,7 @@ public void testInsertTabletNoDatabase() {
RestUtils.nonQuery(httpClient, port, sqlHandler("test", sql));
}
String json =
"{\"database\":\"\",\"column_types\":[\"ID\",\"ATTRIBUTE\",\"MEASUREMENT\"],\"timestamps\":[1635232143960,1635232153960,1635232163960,1635232173960,1635232183960],\"column_names\":[\"id1\",\"t1\",\"s1\"],\"data_types\":[\"STRING\",\"STRING\",\"FLOAT\"],\"values\":[[\"a11\",\"true\",11],[\"a11\",\"false\",22],[\"a13\",\"false1\",23],[\"a14\",\"false2\",24],[\"a15\",\"false3\",25]],\"table\":\"sg211\"}";
"{\"database\":\"\",\"column_types\":[\"TAG\",\"ATTRIBUTE\",\"FIELD\"],\"timestamps\":[1635232143960,1635232153960,1635232163960,1635232173960,1635232183960],\"column_names\":[\"id1\",\"t1\",\"s1\"],\"data_types\":[\"STRING\",\"STRING\",\"FLOAT\"],\"values\":[[\"a11\",\"true\",11],[\"a11\",\"false\",22],[\"a13\",\"false1\",23],[\"a14\",\"false2\",24],[\"a15\",\"false3\",25]],\"table\":\"sg211\"}";
JsonObject result = RestUtils.insertTablet(httpClient, port, json);
assertEquals(305, Integer.parseInt(result.get("code").toString()));
}
Expand All @@ -299,7 +299,7 @@ public void testInsertTablet1() {
RestUtils.nonQuery(httpClient, port, sqlHandler("test", sql));
}
String json =
"{\"database\":\"test\",\"column_types\":[\"ATTRIBUTE\",\"MEASUREMENT\"],\"timestamps\":[1635232143960,1635232153960,1635232163960,1635232173960,1635232183960],\"column_names\":[\"id1\",\"t1\",\"s1\"],\"data_types\":[\"STRING\",\"STRING\",\"FLOAT\"],\"values\":[[\"a11\",\"true\",11],[\"a11\",\"false\",22],[\"a13\",\"false1\",23],[\"a14\",\"false2\",24],[\"a15\",\"false3\",25]],\"table\":\"sg211\"}";
"{\"database\":\"test\",\"column_types\":[\"ATTRIBUTE\",\"FIELD\"],\"timestamps\":[1635232143960,1635232153960,1635232163960,1635232173960,1635232183960],\"column_names\":[\"id1\",\"t1\",\"s1\"],\"data_types\":[\"STRING\",\"STRING\",\"FLOAT\"],\"values\":[[\"a11\",\"true\",11],[\"a11\",\"false\",22],[\"a13\",\"false1\",23],[\"a14\",\"false2\",24],[\"a15\",\"false3\",25]],\"table\":\"sg211\"}";
JsonObject result = RestUtils.insertTablet(httpClient, port, json);
assertEquals(305, Integer.parseInt(result.get("code").toString()));
assertEquals(
Expand All @@ -315,7 +315,7 @@ public void testInsertTablet2() {
RestUtils.nonQuery(httpClient, port, sqlHandler("test", sql));
}
String json =
"{\"database\":\"test\",\"column_types\":[\"ID\",\"ATTRIBUTE\",\"MEASUREMENT\"],\"timestamps\":[1635232143960,1635232153960,1635232163960,1635232183960],\"column_names\":[\"id1\",\"t1\",\"s1\"],\"data_types\":[\"STRING\",\"STRING\",\"FLOAT\"],\"values\":[[\"a11\",\"true\",11],[\"a11\",\"false\",22],[\"a13\",\"false1\",23],[\"a14\",\"false2\",24],[\"a15\",\"false3\",25]],\"table\":\"sg211\"}";
"{\"database\":\"test\",\"column_types\":[\"TAG\",\"ATTRIBUTE\",\"FIELD\"],\"timestamps\":[1635232143960,1635232153960,1635232163960,1635232183960],\"column_names\":[\"id1\",\"t1\",\"s1\"],\"data_types\":[\"STRING\",\"STRING\",\"FLOAT\"],\"values\":[[\"a11\",\"true\",11],[\"a11\",\"false\",22],[\"a13\",\"false1\",23],[\"a14\",\"false2\",24],[\"a15\",\"false3\",25]],\"table\":\"sg211\"}";
JsonObject result = RestUtils.insertTablet(httpClient, port, json);
assertEquals(305, Integer.parseInt(result.get("code").toString()));
assertEquals(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ public void testInformationSchema() throws SQLException {
"ColumnName,DataType,Category,",
new HashSet<>(
Arrays.asList(
"database,STRING,ID,",
"database,STRING,TAG,",
"ttl(ms),STRING,ATTRIBUTE,",
"schema_replication_factor,INT32,ATTRIBUTE,",
"data_replication_factor,INT32,ATTRIBUTE,",
Expand All @@ -381,18 +381,18 @@ public void testInformationSchema() throws SQLException {
"ColumnName,DataType,Category,",
new HashSet<>(
Arrays.asList(
"database,STRING,ID,",
"table_name,STRING,ID,",
"database,STRING,TAG,",
"table_name,STRING,TAG,",
"ttl(ms),STRING,ATTRIBUTE,",
"status,STRING,ATTRIBUTE,")));
TestUtils.assertResultSetEqual(
statement.executeQuery("desc columns"),
"ColumnName,DataType,Category,",
new HashSet<>(
Arrays.asList(
"database,STRING,ID,",
"table_name,STRING,ID,",
"column_name,STRING,ID,",
"database,STRING,TAG,",
"table_name,STRING,TAG,",
"column_name,STRING,TAG,",
"datatype,STRING,ATTRIBUTE,",
"category,STRING,ATTRIBUTE,",
"status,STRING,ATTRIBUTE,")));
Expand All @@ -401,7 +401,7 @@ public void testInformationSchema() throws SQLException {
"ColumnName,DataType,Category,",
new HashSet<>(
Arrays.asList(
"query_id,STRING,ID,",
"query_id,STRING,TAG,",
"start_time,TIMESTAMP,ATTRIBUTE,",
"datanode_id,INT32,ATTRIBUTE,",
"elapsed_time,FLOAT,ATTRIBUTE,",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void testManageTable() {

// or use full qualified table name
// test "TTL=INF"
// "MEASUREMENT" can be omitted when type is specified
// "FIELD" can be omitted when type is specified
// "STRING" can be omitted when id/attribute is specified
statement.execute(
"create table test1.table1(region_id STRING ID, plant_id STRING ID, device_id ID, model STRING ATTRIBUTE, temperature FLOAT MEASUREMENT, humidity DOUBLE) with (TTL='INF')");
Expand Down Expand Up @@ -347,7 +347,7 @@ public void testManageTable() {
String[] dataTypes =
new String[] {"TIMESTAMP", "STRING", "STRING", "STRING", "STRING", "FLOAT", "DOUBLE"};
String[] categories =
new String[] {"TIME", "ID", "ID", "ID", "ATTRIBUTE", "MEASUREMENT", "MEASUREMENT"};
new String[] {"TIME", "TAG", "TAG", "TAG", "ATTRIBUTE", "FIELD", "FIELD"};

try (final ResultSet resultSet = statement.executeQuery("describe test1.table1")) {
int cnt = 0;
Expand All @@ -368,7 +368,7 @@ public void testManageTable() {

columnNames = new String[] {"time", "region_id", "plant_id", "color", "temperature", "speed"};
dataTypes = new String[] {"TIMESTAMP", "STRING", "STRING", "STRING", "FLOAT", "DOUBLE"};
categories = new String[] {"TIME", "ID", "ID", "ATTRIBUTE", "MEASUREMENT", "MEASUREMENT"};
categories = new String[] {"TIME", "TAG", "TAG", "ATTRIBUTE", "FIELD", "FIELD"};

try (final ResultSet resultSet = statement.executeQuery("desc table2")) {
int cnt = 0;
Expand Down Expand Up @@ -397,7 +397,7 @@ public void testManageTable() {

columnNames = new String[] {"time", "region_id", "plant_id", "temperature", "speed"};
dataTypes = new String[] {"TIMESTAMP", "STRING", "STRING", "FLOAT", "DOUBLE"};
categories = new String[] {"TIME", "ID", "ID", "MEASUREMENT", "MEASUREMENT"};
categories = new String[] {"TIME", "TAG", "TAG", "FIELD", "FIELD"};
final String[] statuses = new String[] {"USING", "USING", "USING", "USING", "USING"};
try (final ResultSet resultSet = statement.executeQuery("describe table2 details")) {
int cnt = 0;
Expand Down
Loading
Loading