Skip to content
Merged
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 @@ -535,6 +535,7 @@ public void testInsertMultiRowWithWrongTimestampPrecision() throws SQLException
Statement st1 = connection.createStatement()) {
try {
st1.execute("use \"test\"");
st1.execute("CREATE TABLE wf16 (tag1 string tag, status boolean field)");
st1.execute(
"insert into wf16(tag1, time, status) values('wt01', 1618283005586000, true), ('wt01', 1618283005586001, false)");
fail();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ public void testInsertWithWrongMeasurementNum1() {
public void testInsertWithWrongMeasurementNum2() {
nonQuery(
sqlHandler(
"t1", "create table wf04 (tag1 string tag, status int32, temperature int32 field)"));
"t1", "create table wf05 (tag1 string tag, status int32, temperature int32 field)"));
JsonObject jsonObject =
nonQuery(
sqlHandler(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,10 +369,13 @@ public void testInformationSchema() throws SQLException {
Arrays.asList(
"create database information_schema",
"drop database information_schema",
"create table information_schema.tableA ()",
// table in information_schema do not have the time column, add time column just
// for simulate the base table
"create table information_schema.tableA (time timestamp time)",
"alter table information_schema.tableA add column a id",
"alter table information_schema.tableA set properties ttl=default",
"insert into information_schema.tables (database) values('db')",
// given that create table in information_schema is not allowed, skip insert
// "insert into information_schema.tables (database) values('db')",
"update information_schema.tables set status='RUNNING'"));

for (final String writeSQL : writeSQLs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -610,31 +610,9 @@ public void testManageTable() {
}

// Test time column
// More time column tests are included in other IT
statement.execute("create table test100 (time time)");
statement.execute("create table test101 (time timestamp time)");

try {
statement.execute("create table test102 (time timestamp tag)");
fail();
} catch (final SQLException e) {
assertEquals(
"701: The time column category shall be bounded with column name 'time'.",
e.getMessage());
}

try {
statement.execute("create table test102 (time tag)");
fail();
} catch (final SQLException e) {
assertEquals("701: The time column's type shall be 'timestamp'.", e.getMessage());
}

try {
statement.execute("create table test102 (time time, time time)");
fail();
} catch (final SQLException e) {
assertEquals("701: Columns in table shall not share the same name time.", e.getMessage());
}
} catch (final SQLException e) {
e.printStackTrace();
fail(e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ public void testCreateTable() {
"create table shared_time_name(device string tag, time int64 field, s1 int32 field)");
fail("Columns in table shall not share the same name time when creating table");
} catch (SQLException e) {
assertEquals("701: Columns in table shall not share the same name time.", e.getMessage());
assertEquals(
"701: Columns in table shall not share the same name: 'time'.", e.getMessage());
}

} catch (SQLException e) {
Expand Down Expand Up @@ -217,7 +218,8 @@ public void testCreateView() {
"create view shared_time_time(device string tag, time int64 field, s1 int32 field) as root.tt.**");
fail("Columns in view shall not share the same name time when creating table");
} catch (SQLException e) {
assertEquals("701: Columns in table shall not share the same name time.", e.getMessage());
assertEquals(
"701: Columns in table shall not share the same name: 'time'.", e.getMessage());
}

} catch (SQLException e) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,8 @@ public void testTableSerialization() throws Exception {
final TsTable table = tables.get(0);
assertEquals("table" + i, table.getTableName());
assertEquals(1, table.getTagNum());
assertEquals(4, table.getColumnNum());
// currently, only construct the TsTable would not carry the time column
assertEquals(3, table.getColumnNum());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ public static TableAccumulator createAccumulator(
boolean distinct) {
TableAccumulator result;

// Input expression size of 1 indicates aggregation split has occurred and this is a final
// aggregation
if (aggregationType == TAggregationType.UDAF) {
// If UDAF accumulator receives raw input, it needs to check input's attribute
result = createUDAFAccumulator(functionName, inputDataTypes, inputAttributes);
Expand Down Expand Up @@ -139,7 +141,7 @@ public static TableAccumulator createAccumulator(
: new FirstByDescAccumulator(
inputDataTypes.get(0), inputDataTypes.get(1), xIsTimeColumn, yIsTimeColumn);
}
} else if (LAST.getFunctionName().equals(functionName)) {
} else if (LAST.getFunctionName().equals(functionName) && inputExpressions.size() > 1) {
boolean orderKeyIsTimeColumn = isTimeColumn(inputExpressions.get(1), timeColumnName);
result =
ascending || !orderKeyIsTimeColumn
Expand All @@ -149,9 +151,8 @@ public static TableAccumulator createAccumulator(
isTimeColumn(inputExpressions.get(0), timeColumnName),
isMeasurementColumn(inputExpressions.get(0), measurementColumnNames),
isAggTableScan);
} else if (FIRST.getFunctionName().equals(functionName)) {
} else if (FIRST.getFunctionName().equals(functionName) && inputExpressions.size() > 1) {
boolean orderKeyIsTimeColumn = isTimeColumn(inputExpressions.get(1), timeColumnName);

result =
ascending && orderKeyIsTimeColumn
? new FirstAccumulator(inputDataTypes.get(0), isAggTableScan)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ private Pair<String, TsTable> parseTable4CreateTableOrView(

if (table.getColumnSchema(columnName) != null) {
throw new SemanticException(
String.format("Columns in table shall not share the same name %s.", columnName));
String.format("Columns in table shall not share the same name: '%s'.", columnName));
}

// allow the user create time column
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1188,20 +1188,20 @@ private boolean checkArgumentIsTimestamp(Expression argument, List<Field> visibl
(argument instanceof DereferenceExpression)
? ((DereferenceExpression) argument)
.getField()
.orElseThrow(() -> new SemanticException("the input field do not exists"))
.orElseThrow(() -> new SemanticException("the input field does not exist"))
.toString()
: argument.toString();

for (Field field : visibleFields) {
if (field
.getName()
.orElseThrow(() -> new SemanticException("the field in table do not hava the name"))
.orElseThrow(() -> new SemanticException("the field in table does not have a name"))
.equalsIgnoreCase(argumentName)) {
return field.getType() == TIMESTAMP;
}
}
// should never reach here
throw new SemanticException("the input argument do not exists");
throw new SemanticException("the input argument does not exist");
}

/** Retrieves the effective time column name from the relation's visible fields. */
Expand Down
Loading
Loading