mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-22 07:50:38 +00:00
feat: only allow timestamp type as time index (#2281)
* feat: only allow timestamp data type as time index * test: update sqltest cases, todo: need some fixes * fix: sqlness tests * fix: forgot adding back cte test * chore: style
This commit is contained in:
committed by
Ruihang Xia
parent
6e593401f7
commit
db89235474
@@ -276,7 +276,7 @@ mod tests {
|
||||
async fn test_create_table_with_options() {
|
||||
let sql = r#"
|
||||
CREATE TABLE demo_table (
|
||||
"timestamp" BIGINT TIME INDEX,
|
||||
"timestamp" timestamp TIME INDEX,
|
||||
"value" DOUBLE,
|
||||
host STRING PRIMARY KEY
|
||||
) engine=mito with(regions=1, ttl='7days',write_buffer_size='32MB',some='other');"#;
|
||||
@@ -297,7 +297,7 @@ mod tests {
|
||||
let parsed_stmt = sql_to_statement(
|
||||
r#"
|
||||
CREATE TABLE demo_table(
|
||||
"timestamp" BIGINT TIME INDEX,
|
||||
"timestamp" timestamp TIME INDEX,
|
||||
"value" DOUBLE,
|
||||
host STRING PRIMARY KEY
|
||||
) engine=mito with(regions=1);"#,
|
||||
@@ -335,7 +335,7 @@ mod tests {
|
||||
pub async fn test_multiple_primary_key_definitions() {
|
||||
let parsed_stmt = sql_to_statement(
|
||||
r#"create table demo_table (
|
||||
"timestamp" BIGINT TIME INDEX,
|
||||
"timestamp" timestamp TIME INDEX,
|
||||
"value" DOUBLE,
|
||||
host STRING PRIMARY KEY,
|
||||
PRIMARY KEY(host)) engine=mito with(regions=1);"#,
|
||||
@@ -350,7 +350,7 @@ mod tests {
|
||||
pub async fn test_multiple_inline_primary_key_definitions() {
|
||||
let parsed_stmt = sql_to_statement(
|
||||
r#"create table demo_table (
|
||||
"timestamp" BIGINT TIME INDEX,
|
||||
"timestamp" timestamp TIME INDEX,
|
||||
"value" DOUBLE PRIMARY KEY,
|
||||
host STRING PRIMARY KEY) engine=mito with(regions=1);"#,
|
||||
);
|
||||
@@ -379,16 +379,13 @@ mod tests {
|
||||
/// Constraints specified, not column cannot be found.
|
||||
#[tokio::test]
|
||||
pub async fn test_key_not_found() {
|
||||
let parsed_stmt = sql_to_statement(
|
||||
r#"create table demo_table(
|
||||
let sql = r#"create table demo_table(
|
||||
host string,
|
||||
TIME INDEX (ts)) engine=mito with(regions=1);"#,
|
||||
);
|
||||
TIME INDEX (ts)) engine=mito with(regions=1);"#;
|
||||
|
||||
let error =
|
||||
SqlHandler::create_to_request(42, parsed_stmt, &TableReference::bare("demo_table"))
|
||||
.unwrap_err();
|
||||
assert_matches!(error, Error::KeyColumnNotFound { .. });
|
||||
let res = ParserContext::create_with_dialect(sql, &GreptimeDbDialect {}).unwrap_err();
|
||||
|
||||
assert_matches!(res, sql::error::Error::InvalidTimeIndex { .. });
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
||||
@@ -359,13 +359,10 @@ impl<'a> ParserContext<'a> {
|
||||
}
|
||||
);
|
||||
ensure!(
|
||||
matches!(
|
||||
column.data_type,
|
||||
DataType::Timestamp(_, _) | DataType::BigInt(_)
|
||||
),
|
||||
matches!(column.data_type, DataType::Timestamp(_, _)),
|
||||
InvalidColumnOptionSnafu {
|
||||
name: column.name.to_string(),
|
||||
msg: "time index column data type should be timestamp or bigint",
|
||||
msg: "time index column data type should be timestamp",
|
||||
}
|
||||
);
|
||||
|
||||
@@ -598,8 +595,7 @@ fn validate_time_index(create_table: &CreateTable) -> Result<()> {
|
||||
} = c
|
||||
{
|
||||
if ident.value == TIME_INDEX {
|
||||
let column_names = columns.iter().map(|c| &c.value).collect::<Vec<_>>();
|
||||
Some(column_names)
|
||||
Some(columns)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
@@ -627,6 +623,28 @@ fn validate_time_index(create_table: &CreateTable) -> Result<()> {
|
||||
}
|
||||
);
|
||||
|
||||
// It's safe to use time_index_constraints[0][0],
|
||||
// we already check the bound above.
|
||||
let time_index_column_ident = &time_index_constraints[0][0];
|
||||
let time_index_column = create_table
|
||||
.columns
|
||||
.iter()
|
||||
.find(|c| c.name.value == *time_index_column_ident.value)
|
||||
.with_context(|| InvalidTimeIndexSnafu {
|
||||
msg: format!(
|
||||
"time index column {} not found in columns",
|
||||
time_index_column_ident
|
||||
),
|
||||
})?;
|
||||
|
||||
ensure!(
|
||||
matches!(time_index_column.data_type, DataType::Timestamp(_, _)),
|
||||
InvalidColumnOptionSnafu {
|
||||
name: time_index_column.name.to_string(),
|
||||
msg: "time index column data type should be timestamp",
|
||||
}
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -924,7 +942,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_validate_create() {
|
||||
let sql = r"
|
||||
CREATE TABLE rcx ( a INT, b STRING, c INT, ts BIGINT TIME INDEX)
|
||||
CREATE TABLE rcx ( a INT, b STRING, c INT, ts timestamp TIME INDEX)
|
||||
PARTITION BY RANGE COLUMNS(b, a) (
|
||||
PARTITION r0 VALUES LESS THAN ('hz', 1000),
|
||||
PARTITION r1 VALUES LESS THAN ('sh', 2000),
|
||||
@@ -1175,7 +1193,7 @@ ENGINE=mito";
|
||||
|
||||
assert_ne!(result1, result3);
|
||||
|
||||
// BIGINT as time index
|
||||
// BIGINT can't be time index any more
|
||||
let sql1 = r"
|
||||
CREATE TABLE monitor (
|
||||
host_id INT,
|
||||
@@ -1186,27 +1204,12 @@ CREATE TABLE monitor (
|
||||
PRIMARY KEY (host),
|
||||
)
|
||||
ENGINE=mito";
|
||||
let result1 = ParserContext::create_with_dialect(sql1, &GreptimeDbDialect {}).unwrap();
|
||||
let result1 = ParserContext::create_with_dialect(sql1, &GreptimeDbDialect {});
|
||||
|
||||
if let Statement::CreateTable(c) = &result1[0] {
|
||||
assert_eq!(c.constraints.len(), 2);
|
||||
let tc = c.constraints[0].clone();
|
||||
match tc {
|
||||
TableConstraint::Unique {
|
||||
name,
|
||||
columns,
|
||||
is_primary,
|
||||
} => {
|
||||
assert_eq!(name.unwrap().to_string(), "__time_index");
|
||||
assert_eq!(columns.len(), 1);
|
||||
assert_eq!(&columns[0].value, "b");
|
||||
assert!(!is_primary);
|
||||
}
|
||||
_ => panic!("should be time index constraint"),
|
||||
};
|
||||
} else {
|
||||
panic!("should be create_table statement");
|
||||
}
|
||||
assert!(result1
|
||||
.unwrap_err()
|
||||
.to_string()
|
||||
.contains("time index column data type should be timestamp"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -1385,7 +1388,7 @@ ENGINE=mito";
|
||||
pub fn test_parse_create_table() {
|
||||
let sql = r"create table demo(
|
||||
host string,
|
||||
ts int64,
|
||||
ts timestamp,
|
||||
cpu float64 default 0,
|
||||
memory float64,
|
||||
TIME INDEX (ts),
|
||||
@@ -1402,7 +1405,7 @@ ENGINE=mito";
|
||||
assert_eq!(4, c.columns.len());
|
||||
let columns = &c.columns;
|
||||
assert_column_def(&columns[0], "host", "STRING");
|
||||
assert_column_def(&columns[1], "ts", "int64");
|
||||
assert_column_def(&columns[1], "ts", "TIMESTAMP");
|
||||
assert_column_def(&columns[2], "cpu", "float64");
|
||||
assert_column_def(&columns[3], "memory", "float64");
|
||||
let constraints = &c.constraints;
|
||||
@@ -1449,7 +1452,7 @@ ENGINE=mito";
|
||||
fn test_duplicated_time_index() {
|
||||
let sql = r"create table demo(
|
||||
host string,
|
||||
ts int64 time index,
|
||||
ts timestamp time index,
|
||||
t timestamp time index,
|
||||
cpu float64 default 0,
|
||||
memory float64,
|
||||
@@ -1459,11 +1462,11 @@ ENGINE=mito";
|
||||
";
|
||||
let result = ParserContext::create_with_dialect(sql, &GreptimeDbDialect {});
|
||||
assert!(result.is_err());
|
||||
assert_matches!(result, Err(crate::error::Error::InvalidColumnOption { .. }));
|
||||
assert_matches!(result, Err(crate::error::Error::InvalidTimeIndex { .. }));
|
||||
|
||||
let sql = r"create table demo(
|
||||
host string,
|
||||
ts bigint time index,
|
||||
ts timestamp time index,
|
||||
cpu float64 default 0,
|
||||
t timestamp,
|
||||
memory float64,
|
||||
@@ -1478,7 +1481,7 @@ ENGINE=mito";
|
||||
|
||||
#[test]
|
||||
fn test_invalid_column_name() {
|
||||
let sql = "create table foo(user string, i bigint time index)";
|
||||
let sql = "create table foo(user string, i timestamp time index)";
|
||||
let result = ParserContext::create_with_dialect(sql, &GreptimeDbDialect {});
|
||||
assert!(result
|
||||
.unwrap_err()
|
||||
@@ -1487,7 +1490,7 @@ ENGINE=mito";
|
||||
|
||||
// If column name is quoted, it's valid even same with keyword.
|
||||
let sql = r#"
|
||||
create table foo("user" string, i bigint time index)
|
||||
create table foo("user" string, i timestamp time index)
|
||||
"#;
|
||||
let result = ParserContext::create_with_dialect(sql, &GreptimeDbDialect {});
|
||||
let _ = result.unwrap();
|
||||
|
||||
@@ -229,7 +229,7 @@ mod tests {
|
||||
fn test_display_create_table() {
|
||||
let sql = r"create table if not exists demo(
|
||||
host string,
|
||||
ts bigint,
|
||||
ts timestamp,
|
||||
cpu double default 0,
|
||||
memory double,
|
||||
TIME INDEX (ts),
|
||||
@@ -253,7 +253,7 @@ mod tests {
|
||||
r#"
|
||||
CREATE TABLE IF NOT EXISTS demo (
|
||||
host STRING,
|
||||
ts BIGINT,
|
||||
ts TIMESTAMP,
|
||||
cpu DOUBLE DEFAULT 0,
|
||||
memory DOUBLE,
|
||||
TIME INDEX (ts),
|
||||
@@ -284,7 +284,7 @@ WITH(
|
||||
fn test_display_empty_partition_column() {
|
||||
let sql = r"create table if not exists demo(
|
||||
host string,
|
||||
ts bigint,
|
||||
ts timestamp,
|
||||
cpu double default 0,
|
||||
memory double,
|
||||
TIME INDEX (ts),
|
||||
@@ -301,7 +301,7 @@ WITH(
|
||||
r#"
|
||||
CREATE TABLE IF NOT EXISTS demo (
|
||||
host STRING,
|
||||
ts BIGINT,
|
||||
ts TIMESTAMP,
|
||||
cpu DOUBLE DEFAULT 0,
|
||||
memory DOUBLE,
|
||||
TIME INDEX (ts),
|
||||
|
||||
@@ -19,7 +19,7 @@ use common_catalog::consts::DEFAULT_CATALOG_NAME;
|
||||
use common_query::Output;
|
||||
use common_recordbatch::util;
|
||||
use common_telemetry::logging;
|
||||
use datatypes::vectors::{Int64Vector, StringVector, UInt64Vector, VectorRef};
|
||||
use datatypes::vectors::{StringVector, TimestampMillisecondVector, UInt64Vector, VectorRef};
|
||||
use frontend::error::{Error, Result};
|
||||
use frontend::instance::Instance;
|
||||
use rstest::rstest;
|
||||
@@ -46,7 +46,7 @@ async fn test_create_database_and_insert_query(instance: Arc<dyn MockInstance>)
|
||||
host STRING,
|
||||
cpu DOUBLE,
|
||||
memory DOUBLE,
|
||||
ts bigint,
|
||||
ts timestamp,
|
||||
TIME INDEX(ts)
|
||||
)"#,
|
||||
)
|
||||
@@ -69,7 +69,9 @@ async fn test_create_database_and_insert_query(instance: Arc<dyn MockInstance>)
|
||||
let batches = util::collect(s).await.unwrap();
|
||||
assert_eq!(1, batches[0].num_columns());
|
||||
assert_eq!(
|
||||
Arc::new(Int64Vector::from_vec(vec![1655276557000_i64])) as VectorRef,
|
||||
Arc::new(TimestampMillisecondVector::from_vec(vec![
|
||||
1655276557000_i64
|
||||
])) as VectorRef,
|
||||
*batches[0].column(0)
|
||||
);
|
||||
}
|
||||
@@ -85,7 +87,7 @@ async fn test_show_create_table(instance: Arc<dyn MockInstance>) {
|
||||
host STRING,
|
||||
cpu DOUBLE,
|
||||
memory DOUBLE,
|
||||
ts bigint,
|
||||
ts timestamp,
|
||||
TIME INDEX(ts)
|
||||
)
|
||||
PARTITION BY RANGE COLUMNS (ts) (
|
||||
@@ -99,7 +101,7 @@ PARTITION BY RANGE COLUMNS (ts) (
|
||||
host STRING,
|
||||
cpu DOUBLE,
|
||||
memory DOUBLE,
|
||||
ts bigint,
|
||||
ts timestamp,
|
||||
TIME INDEX(ts)
|
||||
)"#
|
||||
};
|
||||
@@ -116,7 +118,7 @@ PARTITION BY RANGE COLUMNS (ts) (
|
||||
| | "host" STRING NULL, |
|
||||
| | "cpu" DOUBLE NULL, |
|
||||
| | "memory" DOUBLE NULL, |
|
||||
| | "ts" BIGINT NOT NULL, |
|
||||
| | "ts" TIMESTAMP(3) NOT NULL, |
|
||||
| | TIME INDEX ("ts") |
|
||||
| | ) |
|
||||
| | PARTITION BY RANGE COLUMNS ("ts") ( |
|
||||
@@ -138,7 +140,7 @@ PARTITION BY RANGE COLUMNS (ts) (
|
||||
| | "host" STRING NULL, |
|
||||
| | "cpu" DOUBLE NULL, |
|
||||
| | "memory" DOUBLE NULL, |
|
||||
| | "ts" BIGINT NOT NULL, |
|
||||
| | "ts" TIMESTAMP(3) NOT NULL, |
|
||||
| | TIME INDEX ("ts") |
|
||||
| | ) |
|
||||
| | ENGINE=mito |
|
||||
@@ -166,7 +168,7 @@ async fn test_issue477_same_table_name_in_different_databases(instance: Arc<dyn
|
||||
&instance,
|
||||
r#"create table a.demo(
|
||||
host STRING,
|
||||
ts bigint,
|
||||
ts timestamp,
|
||||
TIME INDEX(ts)
|
||||
)"#,
|
||||
)
|
||||
@@ -177,7 +179,7 @@ async fn test_issue477_same_table_name_in_different_databases(instance: Arc<dyn
|
||||
&instance,
|
||||
r#"create table b.demo(
|
||||
host STRING,
|
||||
ts bigint,
|
||||
ts timestamp,
|
||||
TIME INDEX(ts)
|
||||
)"#,
|
||||
)
|
||||
@@ -232,7 +234,7 @@ async fn assert_query_result(instance: &Arc<Instance>, sql: &str, ts: i64, host:
|
||||
*batches[0].column(0)
|
||||
);
|
||||
assert_eq!(
|
||||
Arc::new(Int64Vector::from_vec(vec![ts])) as VectorRef,
|
||||
Arc::new(TimestampMillisecondVector::from_vec(vec![ts])) as VectorRef,
|
||||
*batches[0].column(1)
|
||||
);
|
||||
}
|
||||
@@ -331,53 +333,6 @@ async fn test_execute_insert_by_select(instance: Arc<dyn MockInstance>) {
|
||||
check_output_stream(output, expected).await;
|
||||
}
|
||||
|
||||
#[apply(both_instances_cases)]
|
||||
async fn test_execute_insert_query_with_i64_timestamp(instance: Arc<dyn MockInstance>) {
|
||||
let instance = instance.frontend();
|
||||
|
||||
assert!(matches!(execute_sql(
|
||||
&instance,
|
||||
"create table demo(host string, cpu double, memory double, ts bigint time index, primary key (host));",
|
||||
).await, Output::AffectedRows(0)));
|
||||
|
||||
let output = execute_sql(
|
||||
&instance,
|
||||
r#"insert into demo(host, cpu, memory, ts) values
|
||||
('host1', 66.6, 1024, 1655276557000),
|
||||
('host2', 88.8, 333.3, 1655276558000)
|
||||
"#,
|
||||
)
|
||||
.await;
|
||||
assert!(matches!(output, Output::AffectedRows(2)));
|
||||
|
||||
let query_output = execute_sql(&instance, "select ts from demo order by ts limit 1").await;
|
||||
match query_output {
|
||||
Output::Stream(s) => {
|
||||
let batches = util::collect(s).await.unwrap();
|
||||
assert_eq!(1, batches[0].num_columns());
|
||||
assert_eq!(
|
||||
Arc::new(Int64Vector::from_vec(vec![1655276557000_i64,])) as VectorRef,
|
||||
*batches[0].column(0)
|
||||
);
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
|
||||
let query_output =
|
||||
execute_sql(&instance, "select ts as time from demo order by ts limit 1").await;
|
||||
match query_output {
|
||||
Output::Stream(s) => {
|
||||
let batches = util::collect(s).await.unwrap();
|
||||
assert_eq!(1, batches[0].num_columns());
|
||||
assert_eq!(
|
||||
Arc::new(Int64Vector::from_vec(vec![1655276557000_i64,])) as VectorRef,
|
||||
*batches[0].column(0)
|
||||
);
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
#[apply(both_instances_cases)]
|
||||
async fn test_execute_query(instance: Arc<dyn MockInstance>) {
|
||||
let instance = instance.frontend();
|
||||
@@ -1079,7 +1034,6 @@ async fn test_insert_with_default_value_for_type(instance: Arc<Instance>, type_n
|
||||
#[apply(standalone_instance_case)]
|
||||
async fn test_insert_with_default_value(instance: Arc<dyn MockInstance>) {
|
||||
test_insert_with_default_value_for_type(instance.frontend(), "timestamp").await;
|
||||
test_insert_with_default_value_for_type(instance.frontend(), "bigint").await;
|
||||
}
|
||||
|
||||
#[apply(both_instances_cases)]
|
||||
@@ -1092,7 +1046,7 @@ async fn test_use_database(instance: Arc<dyn MockInstance>) {
|
||||
let query_ctx = QueryContext::with(DEFAULT_CATALOG_NAME, "db1");
|
||||
let output = execute_sql_with(
|
||||
&instance,
|
||||
"create table tb1(col_i32 int, ts bigint, TIME INDEX(ts))",
|
||||
"create table tb1(col_i32 int, ts timestamp, TIME INDEX(ts))",
|
||||
query_ctx.clone(),
|
||||
)
|
||||
.await;
|
||||
@@ -1428,7 +1382,7 @@ async fn test_information_schema_dot_tables(instance: Arc<dyn MockInstance>) {
|
||||
let is_distributed_mode = instance.is_distributed_mode();
|
||||
let instance = instance.frontend();
|
||||
|
||||
let sql = "create table another_table(i bigint time index)";
|
||||
let sql = "create table another_table(i timestamp time index)";
|
||||
let query_ctx = QueryContext::with("another_catalog", "another_schema");
|
||||
let output = execute_sql_with(&instance, sql, query_ctx.clone()).await;
|
||||
assert!(matches!(output, Output::AffectedRows(0)));
|
||||
@@ -1495,7 +1449,7 @@ async fn test_information_schema_dot_tables(instance: Arc<dyn MockInstance>) {
|
||||
async fn test_information_schema_dot_columns(instance: Arc<dyn MockInstance>) {
|
||||
let instance = instance.frontend();
|
||||
|
||||
let sql = "create table another_table(i bigint time index)";
|
||||
let sql = "create table another_table(i timestamp time index)";
|
||||
let query_ctx = QueryContext::with("another_catalog", "another_schema");
|
||||
let output = execute_sql_with(&instance, sql, query_ctx.clone()).await;
|
||||
assert!(matches!(output, Output::AffectedRows(0)));
|
||||
@@ -1535,23 +1489,23 @@ async fn test_information_schema_dot_columns(instance: Arc<dyn MockInstance>) {
|
||||
|
||||
let output = execute_sql_with(&instance, sql, query_ctx).await;
|
||||
let expected = "\
|
||||
+-----------------+--------------------+---------------+---------------+-----------+---------------+
|
||||
| table_catalog | table_schema | table_name | column_name | data_type | semantic_type |
|
||||
+-----------------+--------------------+---------------+---------------+-----------+---------------+
|
||||
| another_catalog | another_schema | another_table | i | Int64 | TIMESTAMP |
|
||||
| another_catalog | information_schema | columns | table_catalog | String | FIELD |
|
||||
| another_catalog | information_schema | columns | table_schema | String | FIELD |
|
||||
| another_catalog | information_schema | columns | table_name | String | FIELD |
|
||||
| another_catalog | information_schema | columns | column_name | String | FIELD |
|
||||
| another_catalog | information_schema | columns | data_type | String | FIELD |
|
||||
| another_catalog | information_schema | columns | semantic_type | String | FIELD |
|
||||
| another_catalog | information_schema | tables | table_catalog | String | FIELD |
|
||||
| another_catalog | information_schema | tables | table_schema | String | FIELD |
|
||||
| another_catalog | information_schema | tables | table_name | String | FIELD |
|
||||
| another_catalog | information_schema | tables | table_type | String | FIELD |
|
||||
| another_catalog | information_schema | tables | table_id | UInt32 | FIELD |
|
||||
| another_catalog | information_schema | tables | engine | String | FIELD |
|
||||
+-----------------+--------------------+---------------+---------------+-----------+---------------+";
|
||||
+-----------------+--------------------+---------------+---------------+----------------------+---------------+
|
||||
| table_catalog | table_schema | table_name | column_name | data_type | semantic_type |
|
||||
+-----------------+--------------------+---------------+---------------+----------------------+---------------+
|
||||
| another_catalog | another_schema | another_table | i | TimestampMillisecond | TIMESTAMP |
|
||||
| another_catalog | information_schema | columns | table_catalog | String | FIELD |
|
||||
| another_catalog | information_schema | columns | table_schema | String | FIELD |
|
||||
| another_catalog | information_schema | columns | table_name | String | FIELD |
|
||||
| another_catalog | information_schema | columns | column_name | String | FIELD |
|
||||
| another_catalog | information_schema | columns | data_type | String | FIELD |
|
||||
| another_catalog | information_schema | columns | semantic_type | String | FIELD |
|
||||
| another_catalog | information_schema | tables | table_catalog | String | FIELD |
|
||||
| another_catalog | information_schema | tables | table_schema | String | FIELD |
|
||||
| another_catalog | information_schema | tables | table_name | String | FIELD |
|
||||
| another_catalog | information_schema | tables | table_type | String | FIELD |
|
||||
| another_catalog | information_schema | tables | table_id | UInt32 | FIELD |
|
||||
| another_catalog | information_schema | tables | engine | String | FIELD |
|
||||
+-----------------+--------------------+---------------+---------------+----------------------+---------------+";
|
||||
|
||||
check_output_stream(output, expected).await;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
CREATE TABLE integers(i BIGINT TIME INDEX);
|
||||
CREATE TABLE integers(i BIGINT, ts TIMESTAMP TIME INDEX);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -30,7 +30,7 @@ DROP TABLE integers;
|
||||
|
||||
Affected Rows: 1
|
||||
|
||||
CREATE TABLE test (a INTEGER, b INTEGER, t BIGINT TIME INDEX);
|
||||
CREATE TABLE test (a INTEGER, b INTEGER, t TIMESTAMP TIME INDEX);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
CREATE TABLE integers(i BIGINT TIME INDEX);
|
||||
CREATE TABLE integers(i BIGINT, ts TIMESTAMP TIME INDEX);
|
||||
|
||||
-- SQLNESS REPLACE (-+) -
|
||||
-- SQLNESS REPLACE (\s\s+) _
|
||||
@@ -10,7 +10,7 @@ EXPLAIN SELECT DISTINCT i%2 FROM integers ORDER BY 1;
|
||||
DROP TABLE integers;
|
||||
|
||||
|
||||
CREATE TABLE test (a INTEGER, b INTEGER, t BIGINT TIME INDEX);
|
||||
CREATE TABLE test (a INTEGER, b INTEGER, t TIMESTAMP TIME INDEX);
|
||||
|
||||
-- SQLNESS REPLACE (-+) -
|
||||
-- SQLNESS REPLACE (\s\s+) _
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
CREATE TABLE integers(i INTEGER, j BIGINT TIME INDEX);
|
||||
CREATE TABLE integers(i INTEGER, j TIMESTAMP TIME INDEX);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -130,32 +130,32 @@ SELECT i1.i,i2.i FROM integers i1 LEFT OUTER JOIN integers i2 ON 1=1 WHERE i1.i=
|
||||
|
||||
SELECT * FROM integers WHERE i IN ((SELECT i FROM integers)) ORDER BY i;
|
||||
|
||||
+---+---+
|
||||
| i | j |
|
||||
+---+---+
|
||||
| 1 | 1 |
|
||||
| 2 | 2 |
|
||||
| 3 | 3 |
|
||||
+---+---+
|
||||
+---+-------------------------+
|
||||
| i | j |
|
||||
+---+-------------------------+
|
||||
| 1 | 1970-01-01T00:00:00.001 |
|
||||
| 2 | 1970-01-01T00:00:00.002 |
|
||||
| 3 | 1970-01-01T00:00:00.003 |
|
||||
+---+-------------------------+
|
||||
|
||||
SELECT * FROM integers WHERE i NOT IN ((SELECT i FROM integers WHERE i=1)) ORDER BY i;
|
||||
|
||||
+---+---+
|
||||
| i | j |
|
||||
+---+---+
|
||||
| 2 | 2 |
|
||||
| 3 | 3 |
|
||||
| | 4 |
|
||||
+---+---+
|
||||
+---+-------------------------+
|
||||
| i | j |
|
||||
+---+-------------------------+
|
||||
| 2 | 1970-01-01T00:00:00.002 |
|
||||
| 3 | 1970-01-01T00:00:00.003 |
|
||||
| | 1970-01-01T00:00:00.004 |
|
||||
+---+-------------------------+
|
||||
|
||||
SELECT * FROM integers WHERE i IN ((SELECT i FROM integers)) AND i<3 ORDER BY i;
|
||||
|
||||
+---+---+
|
||||
| i | j |
|
||||
+---+---+
|
||||
| 1 | 1 |
|
||||
| 2 | 2 |
|
||||
+---+---+
|
||||
+---+-------------------------+
|
||||
| i | j |
|
||||
+---+-------------------------+
|
||||
| 1 | 1970-01-01T00:00:00.001 |
|
||||
| 2 | 1970-01-01T00:00:00.002 |
|
||||
+---+-------------------------+
|
||||
|
||||
SELECT i1.i,i2.i FROM integers i1, integers i2 WHERE i IN ((SELECT i FROM integers)) AND i1.i=i2.i ORDER BY 1;
|
||||
|
||||
@@ -169,21 +169,21 @@ SELECT i1.i,i2.i FROM integers i1, integers i2 WHERE i IN ((SELECT i FROM intege
|
||||
|
||||
SELECT * FROM integers i1 WHERE EXISTS(SELECT i FROM integers WHERE i=i1.i) ORDER BY i1.i;
|
||||
|
||||
+---+---+
|
||||
| i | j |
|
||||
+---+---+
|
||||
| 1 | 1 |
|
||||
| 2 | 2 |
|
||||
| 3 | 3 |
|
||||
+---+---+
|
||||
+---+-------------------------+
|
||||
| i | j |
|
||||
+---+-------------------------+
|
||||
| 1 | 1970-01-01T00:00:00.001 |
|
||||
| 2 | 1970-01-01T00:00:00.002 |
|
||||
| 3 | 1970-01-01T00:00:00.003 |
|
||||
+---+-------------------------+
|
||||
|
||||
SELECT * FROM integers i1 WHERE NOT EXISTS(SELECT i FROM integers WHERE i=i1.i) ORDER BY i1.i;
|
||||
|
||||
+---+---+
|
||||
| i | j |
|
||||
+---+---+
|
||||
| | 4 |
|
||||
+---+---+
|
||||
+---+-------------------------+
|
||||
| i | j |
|
||||
+---+-------------------------+
|
||||
| | 1970-01-01T00:00:00.004 |
|
||||
+---+-------------------------+
|
||||
|
||||
SELECT i1.i,i2.i FROM integers i1, integers i2 WHERE i1.i=(SELECT i FROM integers WHERE i1.i=i) AND i1.i=i2.i ORDER BY i1.i;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
CREATE TABLE integers(i INTEGER, j BIGINT TIME INDEX);
|
||||
CREATE TABLE integers(i INTEGER, j TIMESTAMP TIME INDEX);
|
||||
|
||||
INSERT INTO integers VALUES (1, 1), (2, 2), (3, 3), (NULL, 4);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
CREATE TABLE test (a INTEGER, b INTEGER, t BIGINT TIME INDEX);
|
||||
CREATE TABLE test (a INTEGER, b INTEGER, t TIMESTAMP TIME INDEX);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
CREATE TABLE test (a INTEGER, b INTEGER, t BIGINT TIME INDEX);
|
||||
CREATE TABLE test (a INTEGER, b INTEGER, t TIMESTAMP TIME INDEX);
|
||||
|
||||
INSERT INTO test VALUES (11, 22, 1), (13, 22, 2), (11, 21, 3), (11, 22, 4);
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
CREATE TABLE integers(i BIGINT TIME INDEX);
|
||||
CREATE TABLE integers(i bigint, ts TIMESTAMP TIME INDEX);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO integers VALUES (1), (2), (3);
|
||||
INSERT INTO integers VALUES (1, 1), (2, 2), (3, 3);
|
||||
|
||||
Affected Rows: 3
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
CREATE TABLE integers(i BIGINT TIME INDEX);
|
||||
CREATE TABLE integers(i bigint, ts TIMESTAMP TIME INDEX);
|
||||
|
||||
INSERT INTO integers VALUES (1), (2), (3);
|
||||
INSERT INTO integers VALUES (1, 1), (2, 2), (3, 3);
|
||||
|
||||
SELECT DISTINCT i%2 FROM integers ORDER BY 1;
|
||||
|
||||
|
||||
@@ -38,11 +38,11 @@ SELECT SUM(-1) FROM numbers WHERE number>10000 limit 1000;
|
||||
| |
|
||||
+----------------+
|
||||
|
||||
CREATE TABLE bigints(b BIGINT TIME INDEX);
|
||||
CREATE TABLE bigints(b bigint, ts TIMESTAMP TIME INDEX);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO bigints values (4611686018427387904), (4611686018427388904), (1);
|
||||
INSERT INTO bigints values (4611686018427387904, 1), (4611686018427388904, 2), (1, 3);
|
||||
|
||||
Affected Rows: 3
|
||||
|
||||
@@ -54,7 +54,7 @@ SELECT SUM(b) FROM bigints;
|
||||
| -9223372036854774807 |
|
||||
+----------------------+
|
||||
|
||||
CREATE TABLE doubles(n DOUBLE, ts BIGINT TIME INDEX);
|
||||
CREATE TABLE doubles(n DOUBLE, ts TIMESTAMP TIME INDEX);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
|
||||
@@ -8,13 +8,13 @@ SELECT SUM(-1) FROM numbers WHERE number=-1;
|
||||
|
||||
SELECT SUM(-1) FROM numbers WHERE number>10000 limit 1000;
|
||||
|
||||
CREATE TABLE bigints(b BIGINT TIME INDEX);
|
||||
CREATE TABLE bigints(b bigint, ts TIMESTAMP TIME INDEX);
|
||||
|
||||
INSERT INTO bigints values (4611686018427387904), (4611686018427388904), (1);
|
||||
INSERT INTO bigints values (4611686018427387904, 1), (4611686018427388904, 2), (1, 3);
|
||||
|
||||
SELECT SUM(b) FROM bigints;
|
||||
|
||||
CREATE TABLE doubles(n DOUBLE, ts BIGINT TIME INDEX);
|
||||
CREATE TABLE doubles(n DOUBLE, ts TIMESTAMP TIME INDEX);
|
||||
|
||||
INSERT INTO doubles (n, ts) VALUES (9007199254740992, 1), (1, 2), (1, 3), (0, 4);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
CREATE TABLE test(i INTEGER, j BIGINT TIME INDEX);
|
||||
CREATE TABLE test(i INTEGER, j TIMESTAMP TIME INDEX);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -12,12 +12,12 @@ Affected Rows: 0
|
||||
|
||||
SELECT * FROM test;
|
||||
|
||||
+---+---+---+
|
||||
| i | j | k |
|
||||
+---+---+---+
|
||||
| 1 | 1 | |
|
||||
| 2 | 2 | |
|
||||
+---+---+---+
|
||||
+---+-------------------------+---+
|
||||
| i | j | k |
|
||||
+---+-------------------------+---+
|
||||
| 1 | 1970-01-01T00:00:00.001 | |
|
||||
| 2 | 1970-01-01T00:00:00.002 | |
|
||||
+---+-------------------------+---+
|
||||
|
||||
DROP TABLE test;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
CREATE TABLE test(i INTEGER, j BIGINT TIME INDEX);
|
||||
CREATE TABLE test(i INTEGER, j TIMESTAMP TIME INDEX);
|
||||
|
||||
INSERT INTO test VALUES (1, 1), (2, 2);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
CREATE TABLE test(i INTEGER, j BIGINT TIME INDEX);
|
||||
CREATE TABLE test(i INTEGER, j TIMESTAMP TIME INDEX);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -24,13 +24,13 @@ Affected Rows: 0
|
||||
|
||||
SELECT * FROM test;
|
||||
|
||||
+---+---+---+---+---+
|
||||
| i | j | k | l | m |
|
||||
+---+---+---+---+---+
|
||||
| 1 | 1 | | | 3 |
|
||||
| 2 | 2 | | | 3 |
|
||||
| 3 | 3 | | | 3 |
|
||||
+---+---+---+---+---+
|
||||
+---+-------------------------+---+---+---+
|
||||
| i | j | k | l | m |
|
||||
+---+-------------------------+---+---+---+
|
||||
| 1 | 1970-01-01T00:00:00.001 | | | 3 |
|
||||
| 2 | 1970-01-01T00:00:00.002 | | | 3 |
|
||||
| 3 | 1970-01-01T00:00:00.003 | | | 3 |
|
||||
+---+-------------------------+---+---+---+
|
||||
|
||||
DROP TABLE test;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
CREATE TABLE test(i INTEGER, j BIGINT TIME INDEX);
|
||||
CREATE TABLE test(i INTEGER, j TIMESTAMP TIME INDEX);
|
||||
|
||||
INSERT INTO test VALUES (1, 1), (2, 2);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
CREATE TABLE test(i INTEGER, j BIGINT TIME INDEX);
|
||||
CREATE TABLE test(i INTEGER, j TIMESTAMP TIME INDEX);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -12,12 +12,12 @@ Affected Rows: 0
|
||||
|
||||
SELECT * FROM test;
|
||||
|
||||
+---+---+---+
|
||||
| i | j | k |
|
||||
+---+---+---+
|
||||
| 1 | 1 | 3 |
|
||||
| 2 | 2 | 3 |
|
||||
+---+---+---+
|
||||
+---+-------------------------+---+
|
||||
| i | j | k |
|
||||
+---+-------------------------+---+
|
||||
| 1 | 1970-01-01T00:00:00.001 | 3 |
|
||||
| 2 | 1970-01-01T00:00:00.002 | 3 |
|
||||
+---+-------------------------+---+
|
||||
|
||||
DROP TABLE test;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
CREATE TABLE test(i INTEGER, j BIGINT TIME INDEX);
|
||||
CREATE TABLE test(i INTEGER, j TIMESTAMP TIME INDEX);
|
||||
|
||||
INSERT INTO test VALUES (1, 1), (2, 2);
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
CREATE TABLE test_alt_table(i INTEGER, j BIGINT TIME INDEX);
|
||||
CREATE TABLE test_alt_table(i INTEGER, j TIMESTAMP TIME INDEX);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DESC TABLE test_alt_table;
|
||||
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
| Column | Type | Key | Null | Default | Semantic Type |
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
| i | Int32 | | YES | | FIELD |
|
||||
| j | Int64 | PRI | NO | | TIMESTAMP |
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
| Column | Type | Key | Null | Default | Semantic Type |
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
| i | Int32 | | YES | | FIELD |
|
||||
| j | TimestampMillisecond | PRI | NO | | TIMESTAMP |
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
|
||||
ALTER TABLE test_alt_table ADD COLUMN k INTEGER;
|
||||
|
||||
@@ -17,13 +17,13 @@ Affected Rows: 0
|
||||
|
||||
DESC TABLE test_alt_table;
|
||||
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
| Column | Type | Key | Null | Default | Semantic Type |
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
| i | Int32 | | YES | | FIELD |
|
||||
| j | Int64 | PRI | NO | | TIMESTAMP |
|
||||
| k | Int32 | | YES | | FIELD |
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
| Column | Type | Key | Null | Default | Semantic Type |
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
| i | Int32 | | YES | | FIELD |
|
||||
| j | TimestampMillisecond | PRI | NO | | TIMESTAMP |
|
||||
| k | Int32 | | YES | | FIELD |
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
|
||||
-- SQLNESS ARG restart=true
|
||||
ALTER TABLE test_alt_table ADD COLUMN m INTEGER;
|
||||
@@ -32,14 +32,14 @@ Affected Rows: 0
|
||||
|
||||
DESC TABLE test_alt_table;
|
||||
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
| Column | Type | Key | Null | Default | Semantic Type |
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
| i | Int32 | | YES | | FIELD |
|
||||
| j | Int64 | PRI | NO | | TIMESTAMP |
|
||||
| k | Int32 | | YES | | FIELD |
|
||||
| m | Int32 | | YES | | FIELD |
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
| Column | Type | Key | Null | Default | Semantic Type |
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
| i | Int32 | | YES | | FIELD |
|
||||
| j | TimestampMillisecond | PRI | NO | | TIMESTAMP |
|
||||
| k | Int32 | | YES | | FIELD |
|
||||
| m | Int32 | | YES | | FIELD |
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
|
||||
DROP TABLE test_alt_table;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
CREATE TABLE test_alt_table(i INTEGER, j BIGINT TIME INDEX);
|
||||
CREATE TABLE test_alt_table(i INTEGER, j TIMESTAMP TIME INDEX);
|
||||
|
||||
DESC TABLE test_alt_table;
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
CREATE TABLE t(i INTEGER, j BIGINT TIME INDEX);
|
||||
CREATE TABLE t(i INTEGER, j TIMESTAMP TIME INDEX);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DESC TABLE t;
|
||||
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
| Column | Type | Key | Null | Default | Semantic Type |
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
| i | Int32 | | YES | | FIELD |
|
||||
| j | Int64 | PRI | NO | | TIMESTAMP |
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
| Column | Type | Key | Null | Default | Semantic Type |
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
| i | Int32 | | YES | | FIELD |
|
||||
| j | TimestampMillisecond | PRI | NO | | TIMESTAMP |
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
|
||||
ALTER TABLE t ADD COLUMN k INTEGER;
|
||||
|
||||
@@ -17,24 +17,24 @@ Affected Rows: 0
|
||||
|
||||
DESC TABLE t;
|
||||
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
| Column | Type | Key | Null | Default | Semantic Type |
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
| i | Int32 | | YES | | FIELD |
|
||||
| j | Int64 | PRI | NO | | TIMESTAMP |
|
||||
| k | Int32 | | YES | | FIELD |
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
| Column | Type | Key | Null | Default | Semantic Type |
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
| i | Int32 | | YES | | FIELD |
|
||||
| j | TimestampMillisecond | PRI | NO | | TIMESTAMP |
|
||||
| k | Int32 | | YES | | FIELD |
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
|
||||
-- SQLNESS ARG restart=true
|
||||
DESC TABLE t;
|
||||
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
| Column | Type | Key | Null | Default | Semantic Type |
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
| i | Int32 | | YES | | FIELD |
|
||||
| j | Int64 | PRI | NO | | TIMESTAMP |
|
||||
| k | Int32 | | YES | | FIELD |
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
| Column | Type | Key | Null | Default | Semantic Type |
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
| i | Int32 | | YES | | FIELD |
|
||||
| j | TimestampMillisecond | PRI | NO | | TIMESTAMP |
|
||||
| k | Int32 | | YES | | FIELD |
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
|
||||
ALTER TABLE t ADD COLUMN m INTEGER;
|
||||
|
||||
@@ -42,14 +42,14 @@ Affected Rows: 0
|
||||
|
||||
DESC TABLE t;
|
||||
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
| Column | Type | Key | Null | Default | Semantic Type |
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
| i | Int32 | | YES | | FIELD |
|
||||
| j | Int64 | PRI | NO | | TIMESTAMP |
|
||||
| k | Int32 | | YES | | FIELD |
|
||||
| m | Int32 | | YES | | FIELD |
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
| Column | Type | Key | Null | Default | Semantic Type |
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
| i | Int32 | | YES | | FIELD |
|
||||
| j | TimestampMillisecond | PRI | NO | | TIMESTAMP |
|
||||
| k | Int32 | | YES | | FIELD |
|
||||
| m | Int32 | | YES | | FIELD |
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
|
||||
INSERT INTO t VALUES (1, 2, 3, 4);
|
||||
|
||||
@@ -57,11 +57,11 @@ Affected Rows: 1
|
||||
|
||||
SELECT * FROM t;
|
||||
|
||||
+---+---+---+---+
|
||||
| i | j | k | m |
|
||||
+---+---+---+---+
|
||||
| 1 | 2 | 3 | 4 |
|
||||
+---+---+---+---+
|
||||
+---+-------------------------+---+---+
|
||||
| i | j | k | m |
|
||||
+---+-------------------------+---+---+
|
||||
| 1 | 1970-01-01T00:00:00.002 | 3 | 4 |
|
||||
+---+-------------------------+---+---+
|
||||
|
||||
ALTER TABLE t ADD COLUMN n INTEGER FIRST;
|
||||
|
||||
@@ -69,23 +69,23 @@ Affected Rows: 0
|
||||
|
||||
DESC TABLE t;
|
||||
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
| Column | Type | Key | Null | Default | Semantic Type |
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
| n | Int32 | | YES | | FIELD |
|
||||
| i | Int32 | | YES | | FIELD |
|
||||
| j | Int64 | PRI | NO | | TIMESTAMP |
|
||||
| k | Int32 | | YES | | FIELD |
|
||||
| m | Int32 | | YES | | FIELD |
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
| Column | Type | Key | Null | Default | Semantic Type |
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
| n | Int32 | | YES | | FIELD |
|
||||
| i | Int32 | | YES | | FIELD |
|
||||
| j | TimestampMillisecond | PRI | NO | | TIMESTAMP |
|
||||
| k | Int32 | | YES | | FIELD |
|
||||
| m | Int32 | | YES | | FIELD |
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
|
||||
SELECT * FROM t;
|
||||
|
||||
+---+---+---+---+---+
|
||||
| n | i | j | k | m |
|
||||
+---+---+---+---+---+
|
||||
| | 1 | 2 | 3 | 4 |
|
||||
+---+---+---+---+---+
|
||||
+---+---+-------------------------+---+---+
|
||||
| n | i | j | k | m |
|
||||
+---+---+-------------------------+---+---+
|
||||
| | 1 | 1970-01-01T00:00:00.002 | 3 | 4 |
|
||||
+---+---+-------------------------+---+---+
|
||||
|
||||
INSERT INTO t VALUES (2, 3, 4, 5, 6);
|
||||
|
||||
@@ -97,25 +97,25 @@ Affected Rows: 0
|
||||
|
||||
DESC TABLE t;
|
||||
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
| Column | Type | Key | Null | Default | Semantic Type |
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
| n | Int32 | | YES | | FIELD |
|
||||
| i | Int32 | | YES | | FIELD |
|
||||
| j | Int64 | PRI | NO | | TIMESTAMP |
|
||||
| y | Int32 | | YES | | FIELD |
|
||||
| k | Int32 | | YES | | FIELD |
|
||||
| m | Int32 | | YES | | FIELD |
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
| Column | Type | Key | Null | Default | Semantic Type |
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
| n | Int32 | | YES | | FIELD |
|
||||
| i | Int32 | | YES | | FIELD |
|
||||
| j | TimestampMillisecond | PRI | NO | | TIMESTAMP |
|
||||
| y | Int32 | | YES | | FIELD |
|
||||
| k | Int32 | | YES | | FIELD |
|
||||
| m | Int32 | | YES | | FIELD |
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
|
||||
SELECT * FROM t;
|
||||
|
||||
+---+---+---+---+---+---+
|
||||
| n | i | j | y | k | m |
|
||||
+---+---+---+---+---+---+
|
||||
| | 1 | 2 | | 3 | 4 |
|
||||
| 2 | 3 | 4 | | 5 | 6 |
|
||||
+---+---+---+---+---+---+
|
||||
+---+---+-------------------------+---+---+---+
|
||||
| n | i | j | y | k | m |
|
||||
+---+---+-------------------------+---+---+---+
|
||||
| | 1 | 1970-01-01T00:00:00.002 | | 3 | 4 |
|
||||
| 2 | 3 | 1970-01-01T00:00:00.004 | | 5 | 6 |
|
||||
+---+---+-------------------------+---+---+---+
|
||||
|
||||
-- SQLNESS ARG restart=true
|
||||
ALTER TABLE t ADD COLUMN a INTEGER FIRST;
|
||||
@@ -124,17 +124,17 @@ Affected Rows: 0
|
||||
|
||||
DESC TABLE t;
|
||||
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
| Column | Type | Key | Null | Default | Semantic Type |
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
| a | Int32 | | YES | | FIELD |
|
||||
| n | Int32 | | YES | | FIELD |
|
||||
| i | Int32 | | YES | | FIELD |
|
||||
| j | Int64 | PRI | NO | | TIMESTAMP |
|
||||
| y | Int32 | | YES | | FIELD |
|
||||
| k | Int32 | | YES | | FIELD |
|
||||
| m | Int32 | | YES | | FIELD |
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
| Column | Type | Key | Null | Default | Semantic Type |
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
| a | Int32 | | YES | | FIELD |
|
||||
| n | Int32 | | YES | | FIELD |
|
||||
| i | Int32 | | YES | | FIELD |
|
||||
| j | TimestampMillisecond | PRI | NO | | TIMESTAMP |
|
||||
| y | Int32 | | YES | | FIELD |
|
||||
| k | Int32 | | YES | | FIELD |
|
||||
| m | Int32 | | YES | | FIELD |
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
|
||||
ALTER TABLE t ADD COLUMN b INTEGER AFTER j;
|
||||
|
||||
@@ -142,27 +142,27 @@ Affected Rows: 0
|
||||
|
||||
DESC TABLE t;
|
||||
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
| Column | Type | Key | Null | Default | Semantic Type |
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
| a | Int32 | | YES | | FIELD |
|
||||
| n | Int32 | | YES | | FIELD |
|
||||
| i | Int32 | | YES | | FIELD |
|
||||
| j | Int64 | PRI | NO | | TIMESTAMP |
|
||||
| b | Int32 | | YES | | FIELD |
|
||||
| y | Int32 | | YES | | FIELD |
|
||||
| k | Int32 | | YES | | FIELD |
|
||||
| m | Int32 | | YES | | FIELD |
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
| Column | Type | Key | Null | Default | Semantic Type |
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
| a | Int32 | | YES | | FIELD |
|
||||
| n | Int32 | | YES | | FIELD |
|
||||
| i | Int32 | | YES | | FIELD |
|
||||
| j | TimestampMillisecond | PRI | NO | | TIMESTAMP |
|
||||
| b | Int32 | | YES | | FIELD |
|
||||
| y | Int32 | | YES | | FIELD |
|
||||
| k | Int32 | | YES | | FIELD |
|
||||
| m | Int32 | | YES | | FIELD |
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
|
||||
SELECT * FROM t;
|
||||
|
||||
+---+---+---+---+---+---+---+---+
|
||||
| a | n | i | j | b | y | k | m |
|
||||
+---+---+---+---+---+---+---+---+
|
||||
| | | 1 | 2 | | | 3 | 4 |
|
||||
| | 2 | 3 | 4 | | | 5 | 6 |
|
||||
+---+---+---+---+---+---+---+---+
|
||||
+---+---+---+-------------------------+---+---+---+---+
|
||||
| a | n | i | j | b | y | k | m |
|
||||
+---+---+---+-------------------------+---+---+---+---+
|
||||
| | | 1 | 1970-01-01T00:00:00.002 | | | 3 | 4 |
|
||||
| | 2 | 3 | 1970-01-01T00:00:00.004 | | | 5 | 6 |
|
||||
+---+---+---+-------------------------+---+---+---+---+
|
||||
|
||||
ALTER TABLE t ADD COLUMN x int xxx;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
CREATE TABLE t(i INTEGER, j BIGINT TIME INDEX);
|
||||
CREATE TABLE t(i INTEGER, j TIMESTAMP TIME INDEX);
|
||||
|
||||
DESC TABLE t;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
CREATE TABLE test(i INTEGER, j BIGINT TIME INDEX);
|
||||
CREATE TABLE test(i INTEGER, j TIMESTAMP TIME INDEX);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -12,12 +12,12 @@ Affected Rows: 0
|
||||
|
||||
SELECT * FROM test;
|
||||
|
||||
+---+
|
||||
| j |
|
||||
+---+
|
||||
| 1 |
|
||||
| 2 |
|
||||
+---+
|
||||
+-------------------------+
|
||||
| j |
|
||||
+-------------------------+
|
||||
| 1970-01-01T00:00:00.001 |
|
||||
| 1970-01-01T00:00:00.002 |
|
||||
+-------------------------+
|
||||
|
||||
ALTER TABLE test DROP COLUMN j;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
CREATE TABLE test(i INTEGER, j BIGINT TIME INDEX);
|
||||
CREATE TABLE test(i INTEGER, j TIMESTAMP TIME INDEX);
|
||||
|
||||
INSERT INTO test VALUES (1, 1), (2, 2);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
CREATE TABLE test(i BIGINT TIME INDEX, j INTEGER NOT NULL);
|
||||
CREATE TABLE test(i TIMESTAMP TIME INDEX, j INTEGER NOT NULL);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -8,12 +8,12 @@ Affected Rows: 2
|
||||
|
||||
SELECT * FROM test;
|
||||
|
||||
+---+---+
|
||||
| i | j |
|
||||
+---+---+
|
||||
| 1 | 1 |
|
||||
| 2 | 2 |
|
||||
+---+---+
|
||||
+-------------------------+---+
|
||||
| i | j |
|
||||
+-------------------------+---+
|
||||
| 1970-01-01T00:00:00.001 | 1 |
|
||||
| 1970-01-01T00:00:00.002 | 2 |
|
||||
+-------------------------+---+
|
||||
|
||||
ALTER TABLE test DROP COLUMN j;
|
||||
|
||||
@@ -25,13 +25,13 @@ Affected Rows: 1
|
||||
|
||||
SELECT * FROM test;
|
||||
|
||||
+---+
|
||||
| i |
|
||||
+---+
|
||||
| 1 |
|
||||
| 2 |
|
||||
| 3 |
|
||||
+---+
|
||||
+-------------------------+
|
||||
| i |
|
||||
+-------------------------+
|
||||
| 1970-01-01T00:00:00.001 |
|
||||
| 1970-01-01T00:00:00.002 |
|
||||
| 1970-01-01T00:00:00.003 |
|
||||
+-------------------------+
|
||||
|
||||
DROP TABLE test;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
CREATE TABLE test(i BIGINT TIME INDEX, j INTEGER NOT NULL);
|
||||
CREATE TABLE test(i TIMESTAMP TIME INDEX, j INTEGER NOT NULL);
|
||||
|
||||
INSERT INTO test VALUES (1, 1), (2, 2);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
CREATE TABLE test(i BIGINT TIME INDEX, j INTEGER, k INTEGER NOT NULL);
|
||||
CREATE TABLE test(i TIMESTAMP TIME INDEX, j INTEGER, k INTEGER NOT NULL);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -8,12 +8,12 @@ Affected Rows: 2
|
||||
|
||||
SELECT * FROM test;
|
||||
|
||||
+---+---+----+
|
||||
| i | j | k |
|
||||
+---+---+----+
|
||||
| 1 | 1 | 11 |
|
||||
| 2 | 2 | 12 |
|
||||
+---+---+----+
|
||||
+-------------------------+---+----+
|
||||
| i | j | k |
|
||||
+-------------------------+---+----+
|
||||
| 1970-01-01T00:00:00.001 | 1 | 11 |
|
||||
| 1970-01-01T00:00:00.002 | 2 | 12 |
|
||||
+-------------------------+---+----+
|
||||
|
||||
ALTER TABLE test DROP COLUMN j;
|
||||
|
||||
@@ -29,13 +29,13 @@ Affected Rows: 1
|
||||
|
||||
SELECT * FROM test;
|
||||
|
||||
+---+----+
|
||||
| i | k |
|
||||
+---+----+
|
||||
| 1 | 11 |
|
||||
| 2 | 12 |
|
||||
| 3 | 13 |
|
||||
+---+----+
|
||||
+-------------------------+----+
|
||||
| i | k |
|
||||
+-------------------------+----+
|
||||
| 1970-01-01T00:00:00.001 | 11 |
|
||||
| 1970-01-01T00:00:00.002 | 12 |
|
||||
| 1970-01-01T00:00:00.003 | 13 |
|
||||
+-------------------------+----+
|
||||
|
||||
DROP TABLE test;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
CREATE TABLE test(i BIGINT TIME INDEX, j INTEGER, k INTEGER NOT NULL);
|
||||
CREATE TABLE test(i TIMESTAMP TIME INDEX, j INTEGER, k INTEGER NOT NULL);
|
||||
|
||||
INSERT INTO test VALUES (1, 1, 11), (2, 2, 12);
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
CREATE TABLE t(i INTEGER, j BIGINT TIME INDEX);
|
||||
CREATE TABLE t(i INTEGER, j TIMESTAMP TIME INDEX);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DESC TABLE t;
|
||||
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
| Column | Type | Key | Null | Default | Semantic Type |
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
| i | Int32 | | YES | | FIELD |
|
||||
| j | Int64 | PRI | NO | | TIMESTAMP |
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
| Column | Type | Key | Null | Default | Semantic Type |
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
| i | Int32 | | YES | | FIELD |
|
||||
| j | TimestampMillisecond | PRI | NO | | TIMESTAMP |
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
|
||||
INSERT INTO TABLE t VALUES (1, 1), (3, 3), (NULL, 4);
|
||||
|
||||
@@ -17,13 +17,13 @@ Affected Rows: 3
|
||||
|
||||
SELECT * from t;
|
||||
|
||||
+---+---+
|
||||
| i | j |
|
||||
+---+---+
|
||||
| 1 | 1 |
|
||||
| 3 | 3 |
|
||||
| | 4 |
|
||||
+---+---+
|
||||
+---+-------------------------+
|
||||
| i | j |
|
||||
+---+-------------------------+
|
||||
| 1 | 1970-01-01T00:00:00.001 |
|
||||
| 3 | 1970-01-01T00:00:00.003 |
|
||||
| | 1970-01-01T00:00:00.004 |
|
||||
+---+-------------------------+
|
||||
|
||||
ALTER TABLE t RENAME new_table;
|
||||
|
||||
@@ -37,29 +37,29 @@ SELECT * FROM t;
|
||||
|
||||
Error: 3000(PlanQuery), Error during planning: Table not found: greptime.public.t
|
||||
|
||||
CREATE TABLE t(i INTEGER, j BIGINT TIME INDEX);
|
||||
CREATE TABLE t(i INTEGER, j TIMESTAMP TIME INDEX);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DESC TABLE new_table;
|
||||
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
| Column | Type | Key | Null | Default | Semantic Type |
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
| i | Int32 | | YES | | FIELD |
|
||||
| j | Int64 | PRI | NO | | TIMESTAMP |
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
| Column | Type | Key | Null | Default | Semantic Type |
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
| i | Int32 | | YES | | FIELD |
|
||||
| j | TimestampMillisecond | PRI | NO | | TIMESTAMP |
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
|
||||
-- SQLNESS ARG restart=true
|
||||
SELECT * FROM new_table;
|
||||
|
||||
+---+---+
|
||||
| i | j |
|
||||
+---+---+
|
||||
| 1 | 1 |
|
||||
| 3 | 3 |
|
||||
| | 4 |
|
||||
+---+---+
|
||||
+---+-------------------------+
|
||||
| i | j |
|
||||
+---+-------------------------+
|
||||
| 1 | 1970-01-01T00:00:00.001 |
|
||||
| 3 | 1970-01-01T00:00:00.003 |
|
||||
| | 1970-01-01T00:00:00.004 |
|
||||
+---+-------------------------+
|
||||
|
||||
ALTER TABLE new_table RENAME new_table;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
CREATE TABLE t(i INTEGER, j BIGINT TIME INDEX);
|
||||
CREATE TABLE t(i INTEGER, j TIMESTAMP TIME INDEX);
|
||||
|
||||
DESC TABLE t;
|
||||
|
||||
@@ -12,7 +12,7 @@ DESC TABLE t;
|
||||
|
||||
SELECT * FROM t;
|
||||
|
||||
CREATE TABLE t(i INTEGER, j BIGINT TIME INDEX);
|
||||
CREATE TABLE t(i INTEGER, j TIMESTAMP TIME INDEX);
|
||||
|
||||
DESC TABLE new_table;
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ USE test_public_schema;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
CREATE TABLE hello(i BIGINT TIME INDEX);
|
||||
CREATE TABLE hello(i TIMESTAMP TIME INDEX);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -39,7 +39,7 @@ DROP TABLE hello;
|
||||
|
||||
Affected Rows: 1
|
||||
|
||||
CREATE TABLE hello(i BIGINT TIME INDEX);
|
||||
CREATE TABLE hello(i TIMESTAMP TIME INDEX);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -66,13 +66,13 @@ Affected Rows: 3
|
||||
|
||||
SELECT * FROM hello;
|
||||
|
||||
+---+
|
||||
| i |
|
||||
+---+
|
||||
| 2 |
|
||||
| 3 |
|
||||
| 4 |
|
||||
+---+
|
||||
+-------------------------+
|
||||
| i |
|
||||
+-------------------------+
|
||||
| 1970-01-01T00:00:00.002 |
|
||||
| 1970-01-01T00:00:00.003 |
|
||||
| 1970-01-01T00:00:00.004 |
|
||||
+-------------------------+
|
||||
|
||||
SHOW TABLES;
|
||||
|
||||
|
||||
@@ -10,11 +10,11 @@ SHOW DATABASES WHERE Schemas='test_public_schema';
|
||||
|
||||
USE test_public_schema;
|
||||
|
||||
CREATE TABLE hello(i BIGINT TIME INDEX);
|
||||
CREATE TABLE hello(i TIMESTAMP TIME INDEX);
|
||||
|
||||
DROP TABLE hello;
|
||||
|
||||
CREATE TABLE hello(i BIGINT TIME INDEX);
|
||||
CREATE TABLE hello(i TIMESTAMP TIME INDEX);
|
||||
|
||||
SHOW TABLES FROM test_public_schema;
|
||||
|
||||
|
||||
@@ -4,21 +4,21 @@ Error: 2000(InvalidSyntax), Missing time index constraint
|
||||
|
||||
CREATE TABLE integers (i INT TIME INDEX);
|
||||
|
||||
Error: 1004(InvalidArguments), Invalid column option, column name: i, error: time index column data type should be timestamp or bigint
|
||||
Error: 1004(InvalidArguments), Invalid column option, column name: i, error: time index column data type should be timestamp
|
||||
|
||||
CREATE TABLE integers (i BIGINT TIME INDEX NULL);
|
||||
CREATE TABLE integers (i TIMESTAMP TIME INDEX NULL);
|
||||
|
||||
Error: 1004(InvalidArguments), Invalid column option, column name: i, error: time index column can't be null
|
||||
|
||||
CREATE TABLE integers (i BIGINT TIME INDEX, j BIGINT, TIME INDEX(j));
|
||||
CREATE TABLE integers (i TIMESTAMP TIME INDEX, j BIGINT, TIME INDEX(j));
|
||||
|
||||
Error: 2000(InvalidSyntax), Invalid time index: expected only one time index constraint but actual 2
|
||||
|
||||
CREATE TABLE integers (i BIGINT TIME INDEX, j BIGINT, TIME INDEX(i, j));
|
||||
CREATE TABLE integers (i TIMESTAMP TIME INDEX, j BIGINT, TIME INDEX(i, j));
|
||||
|
||||
Error: 2000(InvalidSyntax), Invalid time index: it should contain only one column in time index
|
||||
|
||||
CREATE TABLE integers (i BIGINT TIME INDEX);
|
||||
CREATE TABLE integers (i TIMESTAMP TIME INDEX);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -26,7 +26,7 @@ CREATE TABLE times (i TIMESTAMP TIME INDEX DEFAULT CURRENT_TIMESTAMP);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
CREATE TABLE IF NOT EXISTS integers (i BIGINT TIME INDEX);
|
||||
CREATE TABLE IF NOT EXISTS integers (i TIMESTAMP TIME INDEX);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -34,43 +34,43 @@ CREATE TABLE test1 (i INTEGER, j INTEGER);
|
||||
|
||||
Error: 2000(InvalidSyntax), Missing time index constraint
|
||||
|
||||
CREATE TABLE test1 (i INTEGER, j BIGINT TIME INDEX NOT NULL);
|
||||
CREATE TABLE test1 (i INTEGER, j TIMESTAMP TIME INDEX NOT NULL);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
CREATE TABLE test2 (i INTEGER, j BIGINT TIME INDEX NULL);
|
||||
CREATE TABLE test2 (i INTEGER, j TIMESTAMP TIME INDEX NULL);
|
||||
|
||||
Error: 1004(InvalidArguments), Invalid column option, column name: j, error: time index column can't be null
|
||||
|
||||
CREATE TABLE test2 (i INTEGER, j BIGINT TIME INDEX);
|
||||
CREATE TABLE test2 (i INTEGER, j TIMESTAMP TIME INDEX);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DESC TABLE integers;
|
||||
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
| Column | Type | Key | Null | Default | Semantic Type |
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
| i | Int64 | PRI | NO | | TIMESTAMP |
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
| Column | Type | Key | Null | Default | Semantic Type |
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
| i | TimestampMillisecond | PRI | NO | | TIMESTAMP |
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
|
||||
DESC TABLE test1;
|
||||
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
| Column | Type | Key | Null | Default | Semantic Type |
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
| i | Int32 | | YES | | FIELD |
|
||||
| j | Int64 | PRI | NO | | TIMESTAMP |
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
| Column | Type | Key | Null | Default | Semantic Type |
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
| i | Int32 | | YES | | FIELD |
|
||||
| j | TimestampMillisecond | PRI | NO | | TIMESTAMP |
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
|
||||
DESC TABLE test2;
|
||||
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
| Column | Type | Key | Null | Default | Semantic Type |
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
| i | Int32 | | YES | | FIELD |
|
||||
| j | Int64 | PRI | NO | | TIMESTAMP |
|
||||
+--------+-------+-----+------+---------+---------------+
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
| Column | Type | Key | Null | Default | Semantic Type |
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
| i | Int32 | | YES | | FIELD |
|
||||
| j | TimestampMillisecond | PRI | NO | | TIMESTAMP |
|
||||
+--------+----------------------+-----+------+---------+---------------+
|
||||
|
||||
DROP TABLE integers;
|
||||
|
||||
@@ -88,33 +88,33 @@ DROP TABLE test2;
|
||||
|
||||
Affected Rows: 1
|
||||
|
||||
CREATE TABLE test_pk ("timestamp" BIGINT TIME INDEX, host STRING PRIMARY KEY, "value" DOUBLE);
|
||||
CREATE TABLE test_pk ("timestamp" TIMESTAMP TIME INDEX, host STRING PRIMARY KEY, "value" DOUBLE);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DESC TABLE test_pk;
|
||||
|
||||
+-----------+---------+-----+------+---------+---------------+
|
||||
| Column | Type | Key | Null | Default | Semantic Type |
|
||||
+-----------+---------+-----+------+---------+---------------+
|
||||
| timestamp | Int64 | PRI | NO | | TIMESTAMP |
|
||||
| host | String | PRI | YES | | TAG |
|
||||
| value | Float64 | | YES | | FIELD |
|
||||
+-----------+---------+-----+------+---------+---------------+
|
||||
+-----------+----------------------+-----+------+---------+---------------+
|
||||
| Column | Type | Key | Null | Default | Semantic Type |
|
||||
+-----------+----------------------+-----+------+---------+---------------+
|
||||
| timestamp | TimestampMillisecond | PRI | NO | | TIMESTAMP |
|
||||
| host | String | PRI | YES | | TAG |
|
||||
| value | Float64 | | YES | | FIELD |
|
||||
+-----------+----------------------+-----+------+---------+---------------+
|
||||
|
||||
DROP TABLE test_pk;
|
||||
|
||||
Affected Rows: 1
|
||||
|
||||
CREATE TABLE test_multiple_pk_definitions ("timestamp" BIGINT TIME INDEX, host STRING PRIMARY KEY, "value" DOUBLE, PRIMARY KEY(host));
|
||||
CREATE TABLE test_multiple_pk_definitions ("timestamp" TIMESTAMP TIME INDEX, host STRING PRIMARY KEY, "value" DOUBLE, PRIMARY KEY(host));
|
||||
|
||||
Error: 1004(InvalidArguments), Illegal primary keys definition: found definitions of primary keys in multiple places
|
||||
|
||||
CREATE TABLE test_multiple_pk_definitions ("timestamp" BIGINT TIME INDEX, host STRING PRIMARY KEY, "value" DOUBLE, PRIMARY KEY(host), PRIMARY KEY(host));
|
||||
CREATE TABLE test_multiple_pk_definitions ("timestamp" TIMESTAMP TIME INDEX, host STRING PRIMARY KEY, "value" DOUBLE, PRIMARY KEY(host), PRIMARY KEY(host));
|
||||
|
||||
Error: 1004(InvalidArguments), Illegal primary keys definition: found definitions of primary keys in multiple places
|
||||
|
||||
CREATE TABLE test_multiple_inline_pk_definitions ("timestamp" BIGINT TIME INDEX, host STRING PRIMARY KEY, "value" DOUBLE PRIMARY KEY);
|
||||
CREATE TABLE test_multiple_inline_pk_definitions ("timestamp" TIMESTAMP TIME INDEX, host STRING PRIMARY KEY, "value" DOUBLE PRIMARY KEY);
|
||||
|
||||
Error: 1004(InvalidArguments), Illegal primary keys definition: not allowed to inline multiple primary keys in columns options
|
||||
|
||||
|
||||
@@ -2,25 +2,25 @@ CREATE TABLE integers (i BIGINT);
|
||||
|
||||
CREATE TABLE integers (i INT TIME INDEX);
|
||||
|
||||
CREATE TABLE integers (i BIGINT TIME INDEX NULL);
|
||||
CREATE TABLE integers (i TIMESTAMP TIME INDEX NULL);
|
||||
|
||||
CREATE TABLE integers (i BIGINT TIME INDEX, j BIGINT, TIME INDEX(j));
|
||||
CREATE TABLE integers (i TIMESTAMP TIME INDEX, j BIGINT, TIME INDEX(j));
|
||||
|
||||
CREATE TABLE integers (i BIGINT TIME INDEX, j BIGINT, TIME INDEX(i, j));
|
||||
CREATE TABLE integers (i TIMESTAMP TIME INDEX, j BIGINT, TIME INDEX(i, j));
|
||||
|
||||
CREATE TABLE integers (i BIGINT TIME INDEX);
|
||||
CREATE TABLE integers (i TIMESTAMP TIME INDEX);
|
||||
|
||||
CREATE TABLE times (i TIMESTAMP TIME INDEX DEFAULT CURRENT_TIMESTAMP);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS integers (i BIGINT TIME INDEX);
|
||||
CREATE TABLE IF NOT EXISTS integers (i TIMESTAMP TIME INDEX);
|
||||
|
||||
CREATE TABLE test1 (i INTEGER, j INTEGER);
|
||||
|
||||
CREATE TABLE test1 (i INTEGER, j BIGINT TIME INDEX NOT NULL);
|
||||
CREATE TABLE test1 (i INTEGER, j TIMESTAMP TIME INDEX NOT NULL);
|
||||
|
||||
CREATE TABLE test2 (i INTEGER, j BIGINT TIME INDEX NULL);
|
||||
CREATE TABLE test2 (i INTEGER, j TIMESTAMP TIME INDEX NULL);
|
||||
|
||||
CREATE TABLE test2 (i INTEGER, j BIGINT TIME INDEX);
|
||||
CREATE TABLE test2 (i INTEGER, j TIMESTAMP TIME INDEX);
|
||||
|
||||
DESC TABLE integers;
|
||||
|
||||
@@ -36,15 +36,15 @@ DROP TABLE test1;
|
||||
|
||||
DROP TABLE test2;
|
||||
|
||||
CREATE TABLE test_pk ("timestamp" BIGINT TIME INDEX, host STRING PRIMARY KEY, "value" DOUBLE);
|
||||
CREATE TABLE test_pk ("timestamp" TIMESTAMP TIME INDEX, host STRING PRIMARY KEY, "value" DOUBLE);
|
||||
|
||||
DESC TABLE test_pk;
|
||||
|
||||
DROP TABLE test_pk;
|
||||
|
||||
CREATE TABLE test_multiple_pk_definitions ("timestamp" BIGINT TIME INDEX, host STRING PRIMARY KEY, "value" DOUBLE, PRIMARY KEY(host));
|
||||
CREATE TABLE test_multiple_pk_definitions ("timestamp" TIMESTAMP TIME INDEX, host STRING PRIMARY KEY, "value" DOUBLE, PRIMARY KEY(host));
|
||||
|
||||
CREATE TABLE test_multiple_pk_definitions ("timestamp" BIGINT TIME INDEX, host STRING PRIMARY KEY, "value" DOUBLE, PRIMARY KEY(host), PRIMARY KEY(host));
|
||||
CREATE TABLE test_multiple_pk_definitions ("timestamp" TIMESTAMP TIME INDEX, host STRING PRIMARY KEY, "value" DOUBLE, PRIMARY KEY(host), PRIMARY KEY(host));
|
||||
|
||||
CREATE TABLE test_multiple_inline_pk_definitions ("timestamp" BIGINT TIME INDEX, host STRING PRIMARY KEY, "value" DOUBLE PRIMARY KEY);
|
||||
CREATE TABLE test_multiple_inline_pk_definitions ("timestamp" TIMESTAMP TIME INDEX, host STRING PRIMARY KEY, "value" DOUBLE PRIMARY KEY);
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
create table a(i bigint time index);
|
||||
create table a(i integer, ts TIMESTAMP TIME INDEX);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
insert into a values (42);
|
||||
insert into a values (42, 1);
|
||||
|
||||
Affected Rows: 1
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
create table a(i bigint time index);
|
||||
create table a(i integer, ts TIMESTAMP TIME INDEX);
|
||||
|
||||
insert into a values (42);
|
||||
insert into a values (42, 1);
|
||||
|
||||
with cte1 as (Select i as j from a) select * from cte1;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
create table a(i bigint time index);
|
||||
create table a(i integer, ts TIMESTAMP TIME INDEX);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
insert into a values (42);
|
||||
insert into a values (42, 1);
|
||||
|
||||
Affected Rows: 1
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
create table a(i bigint time index);
|
||||
create table a(i integer, ts TIMESTAMP TIME INDEX);
|
||||
|
||||
insert into a values (42);
|
||||
insert into a values (42, 1);
|
||||
|
||||
with cte1 as (Select i as j from a) select * from cte1;
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,4 +1,4 @@
|
||||
CREATE TABLE test1 (i INTEGER, j BIGINT TIME INDEX, k STRING DEFAULT 'blabla');
|
||||
CREATE TABLE test1 (i INTEGER, j TIMESTAMP TIME INDEX, k STRING DEFAULT 'blabla');
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -20,16 +20,16 @@ Affected Rows: 4
|
||||
|
||||
SELECT * FROM test1;
|
||||
|
||||
+---+---+--------+
|
||||
| i | j | k |
|
||||
+---+---+--------+
|
||||
| | 1 | blabla |
|
||||
| | 2 | blabla |
|
||||
| | 3 | blabla |
|
||||
| | 4 | blabla |
|
||||
+---+---+--------+
|
||||
+---+-------------------------+--------+
|
||||
| i | j | k |
|
||||
+---+-------------------------+--------+
|
||||
| | 1970-01-01T00:00:00.001 | blabla |
|
||||
| | 1970-01-01T00:00:00.002 | blabla |
|
||||
| | 1970-01-01T00:00:00.003 | blabla |
|
||||
| | 1970-01-01T00:00:00.004 | blabla |
|
||||
+---+-------------------------+--------+
|
||||
|
||||
CREATE TABLE test2 (i INTEGER, j BIGINT TIME INDEX DEFAULT CURRENT_TIMESTAMP, k STRING DEFAULT 'blabla');
|
||||
CREATE TABLE test2 (i INTEGER, j TIMESTAMP TIME INDEX DEFAULT CURRENT_TIMESTAMP, k STRING DEFAULT 'blabla');
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -43,18 +43,18 @@ Affected Rows: 3
|
||||
|
||||
SELECT * FROM test2;
|
||||
|
||||
+---+---+--------+
|
||||
| i | j | k |
|
||||
+---+---+--------+
|
||||
| 1 | 1 | a |
|
||||
| | 2 | blabla |
|
||||
| 3 | 3 | b |
|
||||
| | 4 | blabla |
|
||||
| 5 | 5 | c |
|
||||
| 6 | 6 | blabla |
|
||||
| 7 | 7 | d |
|
||||
| | 8 | e |
|
||||
+---+---+--------+
|
||||
+---+-------------------------+--------+
|
||||
| i | j | k |
|
||||
+---+-------------------------+--------+
|
||||
| 1 | 1970-01-01T00:00:00.001 | a |
|
||||
| | 1970-01-01T00:00:00.002 | blabla |
|
||||
| 3 | 1970-01-01T00:00:00.003 | b |
|
||||
| | 1970-01-01T00:00:00.004 | blabla |
|
||||
| 5 | 1970-01-01T00:00:00.005 | c |
|
||||
| 6 | 1970-01-01T00:00:00.006 | blabla |
|
||||
| 7 | 1970-01-01T00:00:00.007 | d |
|
||||
| | 1970-01-01T00:00:00.008 | e |
|
||||
+---+-------------------------+--------+
|
||||
|
||||
DROP TABLE test1;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
CREATE TABLE test1 (i INTEGER, j BIGINT TIME INDEX, k STRING DEFAULT 'blabla');
|
||||
CREATE TABLE test1 (i INTEGER, j TIMESTAMP TIME INDEX, k STRING DEFAULT 'blabla');
|
||||
|
||||
INSERT INTO test1 VALUES (DEFAULT);
|
||||
|
||||
@@ -10,7 +10,7 @@ INSERT INTO test1 VALUES (DEFAULT, 1, DEFAULT), (default, 2, default), (DeFaUlT,
|
||||
|
||||
SELECT * FROM test1;
|
||||
|
||||
CREATE TABLE test2 (i INTEGER, j BIGINT TIME INDEX DEFAULT CURRENT_TIMESTAMP, k STRING DEFAULT 'blabla');
|
||||
CREATE TABLE test2 (i INTEGER, j TIMESTAMP TIME INDEX DEFAULT CURRENT_TIMESTAMP, k STRING DEFAULT 'blabla');
|
||||
|
||||
INSERT INTO test2 VALUES (1,1,'a'), (default, 2, default), (3,3,'b'), (default, 4, default), (5, 5, 'c');
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
CREATE TABLE strings(i STRING, t BIGINT, time index(t));
|
||||
CREATE TABLE strings(i STRING, t TIMESTAMP, time index(t));
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -12,13 +12,13 @@ Error: 2000(InvalidSyntax), Failed to parse value: Fail to parse number 3, inval
|
||||
|
||||
SELECT * FROM strings WHERE i = 'â‚(';
|
||||
|
||||
+-----+---+
|
||||
| i | t |
|
||||
+-----+---+
|
||||
| â‚( | 1 |
|
||||
+-----+---+
|
||||
+-----+-------------------------+
|
||||
| i | t |
|
||||
+-----+-------------------------+
|
||||
| â‚( | 1970-01-01T00:00:00.001 |
|
||||
+-----+-------------------------+
|
||||
|
||||
CREATE TABLE a(i integer, j BIGINT, time index(j));
|
||||
CREATE TABLE a(i integer, j TIMESTAMP, time index(j));
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
CREATE TABLE strings(i STRING, t BIGINT, time index(t));
|
||||
CREATE TABLE strings(i STRING, t TIMESTAMP, time index(t));
|
||||
|
||||
INSERT INTO strings VALUES ('â‚(', 1);
|
||||
|
||||
@@ -6,7 +6,7 @@ INSERT INTO strings VALUES (3, 4);
|
||||
|
||||
SELECT * FROM strings WHERE i = 'â‚(';
|
||||
|
||||
CREATE TABLE a(i integer, j BIGINT, time index(j));
|
||||
CREATE TABLE a(i integer, j TIMESTAMP, time index(j));
|
||||
|
||||
INSERT INTO a VALUES (1, 2);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
CREATE TABLE test (a BIGINT time index, b INTEGER);
|
||||
CREATE TABLE test (a TIMESTAMP TIME INDEX, b INTEGER);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -8,11 +8,11 @@ Affected Rows: 3
|
||||
|
||||
SELECT a FROM test LIMIT 1;
|
||||
|
||||
+----+
|
||||
| a |
|
||||
+----+
|
||||
| 11 |
|
||||
+----+
|
||||
+-------------------------+
|
||||
| a |
|
||||
+-------------------------+
|
||||
| 1970-01-01T00:00:00.011 |
|
||||
+-------------------------+
|
||||
|
||||
SELECT a FROM test LIMIT 1.25;
|
||||
|
||||
@@ -38,7 +38,7 @@ SELECT a FROM test LIMIT row_number() OVER ();
|
||||
|
||||
Error: 3000(PlanQuery), Error during planning: LIMIT must not be negative
|
||||
|
||||
CREATE TABLE test2 (a STRING, ts BIGINT TIME INDEX);
|
||||
CREATE TABLE test2 (a STRING, ts TIMESTAMP TIME INDEX);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -48,17 +48,17 @@ Affected Rows: 1
|
||||
|
||||
SELECT * FROM test2 LIMIT 3;
|
||||
|
||||
+-------------+----+
|
||||
| a | ts |
|
||||
+-------------+----+
|
||||
| Hello World | 1 |
|
||||
+-------------+----+
|
||||
+-------------+-------------------------+
|
||||
| a | ts |
|
||||
+-------------+-------------------------+
|
||||
| Hello World | 1970-01-01T00:00:00.001 |
|
||||
+-------------+-------------------------+
|
||||
|
||||
select 1 limit date '1992-01-01';
|
||||
|
||||
Error: 3000(PlanQuery), Error during planning: LIMIT must not be negative
|
||||
|
||||
CREATE TABLE integers(i BIGINT TIME INDEX);
|
||||
CREATE TABLE integers(i TIMESTAMP TIME INDEX);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -68,24 +68,24 @@ Affected Rows: 5
|
||||
|
||||
SELECT * FROM integers LIMIT 3;
|
||||
|
||||
+---+
|
||||
| i |
|
||||
+---+
|
||||
| 1 |
|
||||
| 2 |
|
||||
| 3 |
|
||||
+---+
|
||||
+-------------------------+
|
||||
| i |
|
||||
+-------------------------+
|
||||
| 1970-01-01T00:00:00.001 |
|
||||
| 1970-01-01T00:00:00.002 |
|
||||
| 1970-01-01T00:00:00.003 |
|
||||
+-------------------------+
|
||||
|
||||
SELECT * FROM integers LIMIT 4;
|
||||
|
||||
+---+
|
||||
| i |
|
||||
+---+
|
||||
| 1 |
|
||||
| 2 |
|
||||
| 3 |
|
||||
| 4 |
|
||||
+---+
|
||||
+-------------------------+
|
||||
| i |
|
||||
+-------------------------+
|
||||
| 1970-01-01T00:00:00.001 |
|
||||
| 1970-01-01T00:00:00.002 |
|
||||
| 1970-01-01T00:00:00.003 |
|
||||
| 1970-01-01T00:00:00.004 |
|
||||
+-------------------------+
|
||||
|
||||
SELECT * FROM integers as int LIMIT (SELECT MIN(integers.i) FROM integers);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
CREATE TABLE test (a BIGINT time index, b INTEGER);
|
||||
CREATE TABLE test (a TIMESTAMP TIME INDEX, b INTEGER);
|
||||
|
||||
INSERT INTO test VALUES (11, 22), (12, 21), (13, 22);
|
||||
|
||||
@@ -16,7 +16,7 @@ SELECT a FROM test LIMIT SUM(42);
|
||||
|
||||
SELECT a FROM test LIMIT row_number() OVER ();
|
||||
|
||||
CREATE TABLE test2 (a STRING, ts BIGINT TIME INDEX);
|
||||
CREATE TABLE test2 (a STRING, ts TIMESTAMP TIME INDEX);
|
||||
|
||||
INSERT INTO test2 VALUES ('Hello World', 1);
|
||||
|
||||
@@ -24,7 +24,7 @@ SELECT * FROM test2 LIMIT 3;
|
||||
|
||||
select 1 limit date '1992-01-01';
|
||||
|
||||
CREATE TABLE integers(i BIGINT TIME INDEX);
|
||||
CREATE TABLE integers(i TIMESTAMP TIME INDEX);
|
||||
|
||||
INSERT INTO integers VALUES (1), (2), (3), (4), (5);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
CREATE TABLE integers(i BIGINT TIME INDEX);
|
||||
CREATE TABLE integers(i TIMESTAMP TIME INDEX);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -8,17 +8,17 @@ Affected Rows: 5
|
||||
|
||||
SELECT * FROM integers UNION ALL SELECT * FROM integers LIMIT 7;
|
||||
|
||||
+---+
|
||||
| i |
|
||||
+---+
|
||||
| 0 |
|
||||
| 1 |
|
||||
| 2 |
|
||||
| 3 |
|
||||
| 4 |
|
||||
| 0 |
|
||||
| 1 |
|
||||
+---+
|
||||
+-------------------------+
|
||||
| i |
|
||||
+-------------------------+
|
||||
| 1970-01-01T00:00:00 |
|
||||
| 1970-01-01T00:00:00.001 |
|
||||
| 1970-01-01T00:00:00.002 |
|
||||
| 1970-01-01T00:00:00.003 |
|
||||
| 1970-01-01T00:00:00.004 |
|
||||
| 1970-01-01T00:00:00 |
|
||||
| 1970-01-01T00:00:00.001 |
|
||||
+-------------------------+
|
||||
|
||||
SELECT COUNT(*) FROM (SELECT * FROM integers UNION ALL SELECT * FROM integers LIMIT 7) tbl;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
CREATE TABLE integers(i BIGINT TIME INDEX);
|
||||
CREATE TABLE integers(i TIMESTAMP TIME INDEX);
|
||||
|
||||
INSERT INTO integers VALUES (0), (1), (2), (3), (4);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
CREATE TABLE test(i INTEGER, j INTEGER, t BIGINT TIME INDEX);
|
||||
CREATE TABLE test(i INTEGER, j INTEGER, t TIMESTAMP TIME INDEX);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -8,33 +8,33 @@ Affected Rows: 3
|
||||
|
||||
SELECT * FROM test ORDER BY i NULLS FIRST, j NULLS LAST;
|
||||
|
||||
+---+---+---+
|
||||
| i | j | t |
|
||||
+---+---+---+
|
||||
| | 1 | 2 |
|
||||
| 1 | 1 | 1 |
|
||||
| 1 | | 3 |
|
||||
+---+---+---+
|
||||
+---+---+-------------------------+
|
||||
| i | j | t |
|
||||
+---+---+-------------------------+
|
||||
| | 1 | 1970-01-01T00:00:00.002 |
|
||||
| 1 | 1 | 1970-01-01T00:00:00.001 |
|
||||
| 1 | | 1970-01-01T00:00:00.003 |
|
||||
+---+---+-------------------------+
|
||||
|
||||
SELECT * FROM test ORDER BY i NULLS FIRST, j NULLS FIRST;
|
||||
|
||||
+---+---+---+
|
||||
| i | j | t |
|
||||
+---+---+---+
|
||||
| | 1 | 2 |
|
||||
| 1 | | 3 |
|
||||
| 1 | 1 | 1 |
|
||||
+---+---+---+
|
||||
+---+---+-------------------------+
|
||||
| i | j | t |
|
||||
+---+---+-------------------------+
|
||||
| | 1 | 1970-01-01T00:00:00.002 |
|
||||
| 1 | | 1970-01-01T00:00:00.003 |
|
||||
| 1 | 1 | 1970-01-01T00:00:00.001 |
|
||||
+---+---+-------------------------+
|
||||
|
||||
SELECT * FROM test ORDER BY i NULLS LAST, j NULLS FIRST;
|
||||
|
||||
+---+---+---+
|
||||
| i | j | t |
|
||||
+---+---+---+
|
||||
| 1 | | 3 |
|
||||
| 1 | 1 | 1 |
|
||||
| | 1 | 2 |
|
||||
+---+---+---+
|
||||
+---+---+-------------------------+
|
||||
| i | j | t |
|
||||
+---+---+-------------------------+
|
||||
| 1 | | 1970-01-01T00:00:00.003 |
|
||||
| 1 | 1 | 1970-01-01T00:00:00.001 |
|
||||
| | 1 | 1970-01-01T00:00:00.002 |
|
||||
+---+---+-------------------------+
|
||||
|
||||
SELECT i, j, row_number() OVER (PARTITION BY i ORDER BY j NULLS FIRST) FROM test ORDER BY i NULLS FIRST, j NULLS FIRST;
|
||||
|
||||
@@ -58,51 +58,51 @@ SELECT i, j, row_number() OVER (PARTITION BY i ORDER BY j NULLS LAST) FROM test
|
||||
|
||||
SELECT * FROM test ORDER BY i NULLS FIRST, j NULLS LAST LIMIT 2;
|
||||
|
||||
+---+---+---+
|
||||
| i | j | t |
|
||||
+---+---+---+
|
||||
| | 1 | 2 |
|
||||
| 1 | 1 | 1 |
|
||||
+---+---+---+
|
||||
+---+---+-------------------------+
|
||||
| i | j | t |
|
||||
+---+---+-------------------------+
|
||||
| | 1 | 1970-01-01T00:00:00.002 |
|
||||
| 1 | 1 | 1970-01-01T00:00:00.001 |
|
||||
+---+---+-------------------------+
|
||||
|
||||
SELECT * FROM test ORDER BY i NULLS LAST, j NULLS LAST LIMIT 2;
|
||||
|
||||
+---+---+---+
|
||||
| i | j | t |
|
||||
+---+---+---+
|
||||
| 1 | 1 | 1 |
|
||||
| 1 | | 3 |
|
||||
+---+---+---+
|
||||
+---+---+-------------------------+
|
||||
| i | j | t |
|
||||
+---+---+-------------------------+
|
||||
| 1 | 1 | 1970-01-01T00:00:00.001 |
|
||||
| 1 | | 1970-01-01T00:00:00.003 |
|
||||
+---+---+-------------------------+
|
||||
|
||||
SELECT * FROM test ORDER BY i;
|
||||
|
||||
+---+---+---+
|
||||
| i | j | t |
|
||||
+---+---+---+
|
||||
| 1 | 1 | 1 |
|
||||
| 1 | | 3 |
|
||||
| | 1 | 2 |
|
||||
+---+---+---+
|
||||
+---+---+-------------------------+
|
||||
| i | j | t |
|
||||
+---+---+-------------------------+
|
||||
| 1 | 1 | 1970-01-01T00:00:00.001 |
|
||||
| 1 | | 1970-01-01T00:00:00.003 |
|
||||
| | 1 | 1970-01-01T00:00:00.002 |
|
||||
+---+---+-------------------------+
|
||||
|
||||
SELECT * FROM test ORDER BY i NULLS FIRST;
|
||||
|
||||
+---+---+---+
|
||||
| i | j | t |
|
||||
+---+---+---+
|
||||
| | 1 | 2 |
|
||||
| 1 | 1 | 1 |
|
||||
| 1 | | 3 |
|
||||
+---+---+---+
|
||||
+---+---+-------------------------+
|
||||
| i | j | t |
|
||||
+---+---+-------------------------+
|
||||
| | 1 | 1970-01-01T00:00:00.002 |
|
||||
| 1 | 1 | 1970-01-01T00:00:00.001 |
|
||||
| 1 | | 1970-01-01T00:00:00.003 |
|
||||
+---+---+-------------------------+
|
||||
|
||||
SELECT * FROM test ORDER BY i NULLS LAST;
|
||||
|
||||
+---+---+---+
|
||||
| i | j | t |
|
||||
+---+---+---+
|
||||
| 1 | 1 | 1 |
|
||||
| 1 | | 3 |
|
||||
| | 1 | 2 |
|
||||
+---+---+---+
|
||||
+---+---+-------------------------+
|
||||
| i | j | t |
|
||||
+---+---+-------------------------+
|
||||
| 1 | 1 | 1970-01-01T00:00:00.001 |
|
||||
| 1 | | 1970-01-01T00:00:00.003 |
|
||||
| | 1 | 1970-01-01T00:00:00.002 |
|
||||
+---+---+-------------------------+
|
||||
|
||||
DROP TABLE test;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
CREATE TABLE test(i INTEGER, j INTEGER, t BIGINT TIME INDEX);
|
||||
CREATE TABLE test(i INTEGER, j INTEGER, t TIMESTAMP TIME INDEX);
|
||||
|
||||
INSERT INTO test VALUES (1, 1, 1), (NULL, 1, 2), (1, NULL, 3);
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
CREATE TABLE test (a BIGINT, b INTEGER, time index(a));
|
||||
CREATE TABLE test (a INTEGER, b INTEGER, ts TIMESTAMP TIME INDEX);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO test VALUES (11, 22), (12, 21), (13, 22);
|
||||
INSERT INTO test VALUES (11, 22, 1), (12, 21, 2), (13, 22, 3);
|
||||
|
||||
Affected Rows: 3
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
CREATE TABLE test (a BIGINT, b INTEGER, time index(a));
|
||||
CREATE TABLE test (a INTEGER, b INTEGER, ts TIMESTAMP TIME INDEX);
|
||||
|
||||
INSERT INTO test VALUES (11, 22), (12, 21), (13, 22);
|
||||
INSERT INTO test VALUES (11, 22, 1), (12, 21, 2), (13, 22, 3);
|
||||
|
||||
select b from test where a = 12;
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
CREATE TABLE test (a BIGINT TIME INDEX, b INTEGER);
|
||||
CREATE TABLE test (a INTEGER, b INTEGER, ts TIMESTAMP TIME INDEX);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO test VALUES (11, 22), (12, 21), (13, 22);
|
||||
INSERT INTO test VALUES (11, 22, 1), (12, 21, 2), (13, 22, 3);
|
||||
|
||||
Affected Rows: 3
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
CREATE TABLE test (a BIGINT TIME INDEX, b INTEGER);
|
||||
CREATE TABLE test (a INTEGER, b INTEGER, ts TIMESTAMP TIME INDEX);
|
||||
|
||||
INSERT INTO test VALUES (11, 22), (12, 21), (13, 22);
|
||||
INSERT INTO test VALUES (11, 22, 1), (12, 21, 2), (13, 22, 3);
|
||||
|
||||
SELECT a FROM test ORDER BY 2;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
create table t0 (c0 varchar, t BIGINT TIME INDEX);
|
||||
create table t0 (c0 varchar, t TIMESTAMP TIME INDEX);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -8,19 +8,19 @@ Affected Rows: 7
|
||||
|
||||
SELECT * FROM t0 ORDER BY t0.c0 DESC;
|
||||
|
||||
+----+---+
|
||||
| c0 | t |
|
||||
+----+---+
|
||||
| | 7 |
|
||||
| | 6 |
|
||||
| | 5 |
|
||||
| | 4 |
|
||||
| | 3 |
|
||||
| | 2 |
|
||||
| a | 1 |
|
||||
+----+---+
|
||||
+----+-------------------------+
|
||||
| c0 | t |
|
||||
+----+-------------------------+
|
||||
| | 1970-01-01T00:00:00.007 |
|
||||
| | 1970-01-01T00:00:00.006 |
|
||||
| | 1970-01-01T00:00:00.005 |
|
||||
| | 1970-01-01T00:00:00.004 |
|
||||
| | 1970-01-01T00:00:00.003 |
|
||||
| | 1970-01-01T00:00:00.002 |
|
||||
| a | 1970-01-01T00:00:00.001 |
|
||||
+----+-------------------------+
|
||||
|
||||
CREATE TABLE test0 (job VARCHAR, name VARCHAR, t BIGINT TIME INDEX);
|
||||
CREATE TABLE test0 (job VARCHAR, name VARCHAR, t TIMESTAMP TIME INDEX);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -30,31 +30,31 @@ Affected Rows: 6
|
||||
|
||||
SELECT * FROM test0 ORDER BY job, name;
|
||||
|
||||
+-----------------------------------+----------+---+
|
||||
| job | name | t |
|
||||
+-----------------------------------+----------+---+
|
||||
| Production Supervisor - WC40 | Dsa | 6 |
|
||||
| Production Supervisor - WC60 | Brown | 4 |
|
||||
| Production Supervisor - WC60 | Campbell | 5 |
|
||||
| Shipping and Receiving Clerk | Berndt | 2 |
|
||||
| Shipping and Receiving Clerk | Kuppa | 3 |
|
||||
| Shipping and Receiving Supervisor | Ackerman | 1 |
|
||||
+-----------------------------------+----------+---+
|
||||
+-----------------------------------+----------+-------------------------+
|
||||
| job | name | t |
|
||||
+-----------------------------------+----------+-------------------------+
|
||||
| Production Supervisor - WC40 | Dsa | 1970-01-01T00:00:00.006 |
|
||||
| Production Supervisor - WC60 | Brown | 1970-01-01T00:00:00.004 |
|
||||
| Production Supervisor - WC60 | Campbell | 1970-01-01T00:00:00.005 |
|
||||
| Shipping and Receiving Clerk | Berndt | 1970-01-01T00:00:00.002 |
|
||||
| Shipping and Receiving Clerk | Kuppa | 1970-01-01T00:00:00.003 |
|
||||
| Shipping and Receiving Supervisor | Ackerman | 1970-01-01T00:00:00.001 |
|
||||
+-----------------------------------+----------+-------------------------+
|
||||
|
||||
SELECT * FROM test0 ORDER BY job DESC, name DESC;
|
||||
|
||||
+-----------------------------------+----------+---+
|
||||
| job | name | t |
|
||||
+-----------------------------------+----------+---+
|
||||
| Shipping and Receiving Supervisor | Ackerman | 1 |
|
||||
| Shipping and Receiving Clerk | Kuppa | 3 |
|
||||
| Shipping and Receiving Clerk | Berndt | 2 |
|
||||
| Production Supervisor - WC60 | Campbell | 5 |
|
||||
| Production Supervisor - WC60 | Brown | 4 |
|
||||
| Production Supervisor - WC40 | Dsa | 6 |
|
||||
+-----------------------------------+----------+---+
|
||||
+-----------------------------------+----------+-------------------------+
|
||||
| job | name | t |
|
||||
+-----------------------------------+----------+-------------------------+
|
||||
| Shipping and Receiving Supervisor | Ackerman | 1970-01-01T00:00:00.001 |
|
||||
| Shipping and Receiving Clerk | Kuppa | 1970-01-01T00:00:00.003 |
|
||||
| Shipping and Receiving Clerk | Berndt | 1970-01-01T00:00:00.002 |
|
||||
| Production Supervisor - WC60 | Campbell | 1970-01-01T00:00:00.005 |
|
||||
| Production Supervisor - WC60 | Brown | 1970-01-01T00:00:00.004 |
|
||||
| Production Supervisor - WC40 | Dsa | 1970-01-01T00:00:00.006 |
|
||||
+-----------------------------------+----------+-------------------------+
|
||||
|
||||
CREATE TABLE test1 (s VARCHAR, t BIGINT TIME INDEX);
|
||||
CREATE TABLE test1 (s VARCHAR, t TIMESTAMP TIME INDEX);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -64,20 +64,20 @@ Affected Rows: 8
|
||||
|
||||
SELECT * FROM test1 ORDER BY s;
|
||||
|
||||
+---------------+---+
|
||||
| s | t |
|
||||
+---------------+---+
|
||||
| 1 | 4 |
|
||||
| 10 | 6 |
|
||||
| 2 | 1 |
|
||||
| 3555555555551 | 8 |
|
||||
| 3555555555552 | 3 |
|
||||
| 3555555555553 | 7 |
|
||||
| 355555555556 | 5 |
|
||||
| | 2 |
|
||||
+---------------+---+
|
||||
+---------------+-------------------------+
|
||||
| s | t |
|
||||
+---------------+-------------------------+
|
||||
| 1 | 1970-01-01T00:00:00.004 |
|
||||
| 10 | 1970-01-01T00:00:00.006 |
|
||||
| 2 | 1970-01-01T00:00:00.001 |
|
||||
| 3555555555551 | 1970-01-01T00:00:00.008 |
|
||||
| 3555555555552 | 1970-01-01T00:00:00.003 |
|
||||
| 3555555555553 | 1970-01-01T00:00:00.007 |
|
||||
| 355555555556 | 1970-01-01T00:00:00.005 |
|
||||
| | 1970-01-01T00:00:00.002 |
|
||||
+---------------+-------------------------+
|
||||
|
||||
CREATE TABLE test4 (i INT, j INT, t BIGINT TIME INDEX);
|
||||
CREATE TABLE test4 (i INT, j INT, t TIMESTAMP TIME INDEX);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -87,38 +87,38 @@ Affected Rows: 4
|
||||
|
||||
SELECT * FROM test4 ORDER BY cast(i AS VARCHAR), j;
|
||||
|
||||
+---+---+---+
|
||||
| i | j | t |
|
||||
+---+---+---+
|
||||
| 2 | 2 | 3 |
|
||||
| 2 | 3 | 2 |
|
||||
| 3 | 2 | 4 |
|
||||
| 3 | 3 | 1 |
|
||||
+---+---+---+
|
||||
+---+---+-------------------------+
|
||||
| i | j | t |
|
||||
+---+---+-------------------------+
|
||||
| 2 | 2 | 1970-01-01T00:00:00.003 |
|
||||
| 2 | 3 | 1970-01-01T00:00:00.002 |
|
||||
| 3 | 2 | 1970-01-01T00:00:00.004 |
|
||||
| 3 | 3 | 1970-01-01T00:00:00.001 |
|
||||
+---+---+-------------------------+
|
||||
|
||||
SELECT * FROM test4 ORDER BY i, cast(j AS VARCHAR);
|
||||
|
||||
+---+---+---+
|
||||
| i | j | t |
|
||||
+---+---+---+
|
||||
| 2 | 2 | 3 |
|
||||
| 2 | 3 | 2 |
|
||||
| 3 | 2 | 4 |
|
||||
| 3 | 3 | 1 |
|
||||
+---+---+---+
|
||||
+---+---+-------------------------+
|
||||
| i | j | t |
|
||||
+---+---+-------------------------+
|
||||
| 2 | 2 | 1970-01-01T00:00:00.003 |
|
||||
| 2 | 3 | 1970-01-01T00:00:00.002 |
|
||||
| 3 | 2 | 1970-01-01T00:00:00.004 |
|
||||
| 3 | 3 | 1970-01-01T00:00:00.001 |
|
||||
+---+---+-------------------------+
|
||||
|
||||
SELECT * FROM test4 ORDER BY cast(i AS VARCHAR), cast(j AS VARCHAR);
|
||||
|
||||
+---+---+---+
|
||||
| i | j | t |
|
||||
+---+---+---+
|
||||
| 2 | 2 | 3 |
|
||||
| 2 | 3 | 2 |
|
||||
| 3 | 2 | 4 |
|
||||
| 3 | 3 | 1 |
|
||||
+---+---+---+
|
||||
+---+---+-------------------------+
|
||||
| i | j | t |
|
||||
+---+---+-------------------------+
|
||||
| 2 | 2 | 1970-01-01T00:00:00.003 |
|
||||
| 2 | 3 | 1970-01-01T00:00:00.002 |
|
||||
| 3 | 2 | 1970-01-01T00:00:00.004 |
|
||||
| 3 | 3 | 1970-01-01T00:00:00.001 |
|
||||
+---+---+-------------------------+
|
||||
|
||||
CREATE TABLE tpch_q1_agg (l_returnflag VARCHAR, l_linestatus VARCHAR, sum_qty INT, sum_base_price DOUBLE, sum_disc_price DOUBLE, sum_charge DOUBLE, avg_qty DOUBLE, avg_price DOUBLE, avg_disc DOUBLE, count_order BIGINT, t BIGINT TIME INDEX);
|
||||
CREATE TABLE tpch_q1_agg (l_returnflag VARCHAR, l_linestatus VARCHAR, sum_qty INT, sum_base_price DOUBLE, sum_disc_price DOUBLE, sum_charge DOUBLE, avg_qty DOUBLE, avg_price DOUBLE, avg_disc DOUBLE, count_order BIGINT, t TIMESTAMP TIME INDEX);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -128,20 +128,20 @@ Affected Rows: 4
|
||||
|
||||
SELECT * FROM tpch_q1_agg ORDER BY l_returnflag, l_linestatus;
|
||||
|
||||
+--------------+--------------+---------+------------------+-----------------+-----------------------+--------------------+--------------------+---------------------+-------------+---+
|
||||
| l_returnflag | l_linestatus | sum_qty | sum_base_price | sum_disc_price | sum_charge | avg_qty | avg_price | avg_disc | count_order | t |
|
||||
+--------------+--------------+---------+------------------+-----------------+-----------------------+--------------------+--------------------+---------------------+-------------+---+
|
||||
| A | F | 3774200 | 5320753880.69 | 5054096266.6828 | 5256751331.449234 | 25.537587116854997 | 36002.12382901414 | 0.05014459706340077 | 147790 | 3 |
|
||||
| N | F | 95257 | 133737795.84 | 127132372.6512 | 132286291.229445 | 25.30066401062417 | 35521.32691633466 | 0.04939442231075697 | 3765 | 4 |
|
||||
| N | O | 7459297 | 1.05122700089e10 | 9986238338.3847 | 1.0385578376585466e10 | 25.545537671232875 | 36000.9246880137 | 0.05009595890410959 | 292000 | 1 |
|
||||
| R | F | 3785523 | 5337950526.47 | 5071818532.942 | 5274405503.049367 | 25.5259438574251 | 35994.029214030925 | 0.04998927856184382 | 148301 | 2 |
|
||||
+--------------+--------------+---------+------------------+-----------------+-----------------------+--------------------+--------------------+---------------------+-------------+---+
|
||||
+--------------+--------------+---------+------------------+-----------------+-----------------------+--------------------+--------------------+---------------------+-------------+-------------------------+
|
||||
| l_returnflag | l_linestatus | sum_qty | sum_base_price | sum_disc_price | sum_charge | avg_qty | avg_price | avg_disc | count_order | t |
|
||||
+--------------+--------------+---------+------------------+-----------------+-----------------------+--------------------+--------------------+---------------------+-------------+-------------------------+
|
||||
| A | F | 3774200 | 5320753880.69 | 5054096266.6828 | 5256751331.449234 | 25.537587116854997 | 36002.12382901414 | 0.05014459706340077 | 147790 | 1970-01-01T00:00:00.003 |
|
||||
| N | F | 95257 | 133737795.84 | 127132372.6512 | 132286291.229445 | 25.30066401062417 | 35521.32691633466 | 0.04939442231075697 | 3765 | 1970-01-01T00:00:00.004 |
|
||||
| N | O | 7459297 | 1.05122700089e10 | 9986238338.3847 | 1.0385578376585466e10 | 25.545537671232875 | 36000.9246880137 | 0.05009595890410959 | 292000 | 1970-01-01T00:00:00.001 |
|
||||
| R | F | 3785523 | 5337950526.47 | 5071818532.942 | 5274405503.049367 | 25.5259438574251 | 35994.029214030925 | 0.04998927856184382 | 148301 | 1970-01-01T00:00:00.002 |
|
||||
+--------------+--------------+---------+------------------+-----------------+-----------------------+--------------------+--------------------+---------------------+-------------+-------------------------+
|
||||
|
||||
create table test5 (i int, s varchar, t BIGINT TIME INDEX);
|
||||
create table test5 (i int, s varchar, t TIMESTAMP TIME INDEX);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
CREATE TABLE test6 (i1 INT, s1 VARCHAR, i2 int, s2 VARCHAR, t BIGINT TIME INDEX);
|
||||
CREATE TABLE test6 (i1 INT, s1 VARCHAR, i2 int, s2 VARCHAR, t TIMESTAMP TIME INDEX);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -303,7 +303,7 @@ SELECT s1, s2, i1, i2 FROM test6 ORDER BY i2 DESC, s1, s2, i1;
|
||||
| 0reallylongstring2 | 1reallylongstring8 | 6 | 3 |
|
||||
+--------------------+--------------------+----+----+
|
||||
|
||||
create table test7 (p_brand VARCHAR, p_type VARCHAR, p_size INT, supplier_cnt BIGINT, t BIGINT TIME INDEX);
|
||||
create table test7 (p_brand VARCHAR, p_type VARCHAR, p_size INT, supplier_cnt BIGINT, t TIMESTAMP TIME INDEX);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -327,7 +327,7 @@ SELECT p_brand, p_type, p_size, supplier_cnt FROM test7 ORDER BY supplier_cnt DE
|
||||
| Brand#11 | ECONOMY BURNISHED NICKEL | 49 | 4 |
|
||||
+----------+--------------------------+--------+--------------+
|
||||
|
||||
create table test8 (i int, s varchar, t BIGINT TIME INDEX);
|
||||
create table test8 (i int, s varchar, t TIMESTAMP TIME INDEX);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -353,7 +353,7 @@ CREATE TABLE DirectReports
|
||||
Title varchar NOT NULL,
|
||||
EmployeeLevel int NOT NULL,
|
||||
"Sort" varchar NOT NULL,
|
||||
"Timestamp" BIGINT TIME INDEX,
|
||||
"Timestamp" TIMESTAMP TIME INDEX,
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
create table t0 (c0 varchar, t BIGINT TIME INDEX);
|
||||
create table t0 (c0 varchar, t TIMESTAMP TIME INDEX);
|
||||
|
||||
insert into t0 values ('a', 1), (NULL,2), (NULL, 3), (NULL, 4), (NULL, 5), (NULL,6), (NULL,7);
|
||||
|
||||
SELECT * FROM t0 ORDER BY t0.c0 DESC;
|
||||
|
||||
CREATE TABLE test0 (job VARCHAR, name VARCHAR, t BIGINT TIME INDEX);
|
||||
CREATE TABLE test0 (job VARCHAR, name VARCHAR, t TIMESTAMP TIME INDEX);
|
||||
|
||||
INSERT INTO test0 VALUES ('Shipping and Receiving Supervisor', 'Ackerman', 1), ('Shipping and Receiving Clerk', 'Berndt', 2), ('Shipping and Receiving Clerk', 'Kuppa', 3), ('Production Supervisor - WC60', 'Brown', 4), ('Production Supervisor - WC60', 'Campbell', 5), ('Production Supervisor - WC40', 'Dsa', 6);
|
||||
|
||||
@@ -12,13 +12,13 @@ SELECT * FROM test0 ORDER BY job, name;
|
||||
|
||||
SELECT * FROM test0 ORDER BY job DESC, name DESC;
|
||||
|
||||
CREATE TABLE test1 (s VARCHAR, t BIGINT TIME INDEX);
|
||||
CREATE TABLE test1 (s VARCHAR, t TIMESTAMP TIME INDEX);
|
||||
|
||||
INSERT INTO test1 VALUES ('2', 1), (NULL, 2), ('3555555555552', 3), ('1', 4), ('355555555556', 5), ('10', 6), ('3555555555553', 7), ('3555555555551', 8);
|
||||
|
||||
SELECT * FROM test1 ORDER BY s;
|
||||
|
||||
CREATE TABLE test4 (i INT, j INT, t BIGINT TIME INDEX);
|
||||
CREATE TABLE test4 (i INT, j INT, t TIMESTAMP TIME INDEX);
|
||||
|
||||
INSERT INTO test4 VALUES (3, 3, 1), (2, 3, 2), (2, 2, 3), (3, 2, 4);
|
||||
|
||||
@@ -29,15 +29,15 @@ SELECT * FROM test4 ORDER BY i, cast(j AS VARCHAR);
|
||||
|
||||
SELECT * FROM test4 ORDER BY cast(i AS VARCHAR), cast(j AS VARCHAR);
|
||||
|
||||
CREATE TABLE tpch_q1_agg (l_returnflag VARCHAR, l_linestatus VARCHAR, sum_qty INT, sum_base_price DOUBLE, sum_disc_price DOUBLE, sum_charge DOUBLE, avg_qty DOUBLE, avg_price DOUBLE, avg_disc DOUBLE, count_order BIGINT, t BIGINT TIME INDEX);
|
||||
CREATE TABLE tpch_q1_agg (l_returnflag VARCHAR, l_linestatus VARCHAR, sum_qty INT, sum_base_price DOUBLE, sum_disc_price DOUBLE, sum_charge DOUBLE, avg_qty DOUBLE, avg_price DOUBLE, avg_disc DOUBLE, count_order BIGINT, t TIMESTAMP TIME INDEX);
|
||||
|
||||
INSERT INTO tpch_q1_agg VALUES ('N', 'O', 7459297, 10512270008.90, 9986238338.3847, 10385578376.585467, 25.545537671232875, 36000.9246880137, 0.05009595890410959, 292000, 1), ('R', 'F', 3785523, 5337950526.47, 5071818532.9420, 5274405503.049367, 25.5259438574251, 35994.029214030925, 0.04998927856184382, 148301, 2), ('A', 'F', 3774200, 5320753880.69, 5054096266.6828, 5256751331.449234, 25.537587116854997, 36002.12382901414, 0.05014459706340077, 147790, 3), ('N', 'F', 95257, 133737795.84, 127132372.6512, 132286291.229445, 25.30066401062417, 35521.32691633466, 0.04939442231075697, 3765, 4);
|
||||
|
||||
SELECT * FROM tpch_q1_agg ORDER BY l_returnflag, l_linestatus;
|
||||
|
||||
create table test5 (i int, s varchar, t BIGINT TIME INDEX);
|
||||
create table test5 (i int, s varchar, t TIMESTAMP TIME INDEX);
|
||||
|
||||
CREATE TABLE test6 (i1 INT, s1 VARCHAR, i2 int, s2 VARCHAR, t BIGINT TIME INDEX);
|
||||
CREATE TABLE test6 (i1 INT, s1 VARCHAR, i2 int, s2 VARCHAR, t TIMESTAMP TIME INDEX);
|
||||
|
||||
INSERT INTO test6 VALUES
|
||||
(6, '0reallylongstring1', 3, '1reallylongstring8', 1),
|
||||
@@ -69,13 +69,13 @@ SELECT i1, i2, s1, s2 FROM test6 ORDER BY i1, i2, s1, s2;
|
||||
|
||||
SELECT s1, s2, i1, i2 FROM test6 ORDER BY i2 DESC, s1, s2, i1;
|
||||
|
||||
create table test7 (p_brand VARCHAR, p_type VARCHAR, p_size INT, supplier_cnt BIGINT, t BIGINT TIME INDEX);
|
||||
create table test7 (p_brand VARCHAR, p_type VARCHAR, p_size INT, supplier_cnt BIGINT, t TIMESTAMP TIME INDEX);
|
||||
|
||||
insert into test7 values ('Brand#11', 'ECONOMY BRUSHED COPPER', 3, 4, 1), ('Brand#11', 'ECONOMY BRUSHED COPPER', 9, 4, 2), ('Brand#11', 'ECONOMY BRUSHED STEEL', 36, 4, 3), ('Brand#11', 'ECONOMY BRUSHED STEEL', 9, 4, 4), ('Brand#11', 'ECONOMY BURNISHED BRASS', 36, 4, 5), ('Brand#11', 'ECONOMY BURNISHED COPPER', 49, 4, 6), ('Brand#11', 'ECONOMY BURNISHED COPPER', 9, 4, 7), ('Brand#11', 'ECONOMY BURNISHED NICKEL', 14, 4,8), ('Brand#11', 'ECONOMY BURNISHED NICKEL', 49, 4, 9);
|
||||
|
||||
SELECT p_brand, p_type, p_size, supplier_cnt FROM test7 ORDER BY supplier_cnt DESC, p_brand, p_type, p_size;
|
||||
|
||||
create table test8 (i int, s varchar, t BIGINT TIME INDEX);
|
||||
create table test8 (i int, s varchar, t TIMESTAMP TIME INDEX);
|
||||
|
||||
insert into test8 values (3, 'aba', 1), (1, 'ccbcc', 2), (NULL, 'dbdbd', 3), (2, NULL, 4);
|
||||
|
||||
@@ -88,7 +88,7 @@ CREATE TABLE DirectReports
|
||||
Title varchar NOT NULL,
|
||||
EmployeeLevel int NOT NULL,
|
||||
"Sort" varchar NOT NULL,
|
||||
"Timestamp" BIGINT TIME INDEX,
|
||||
"Timestamp" TIMESTAMP TIME INDEX,
|
||||
);
|
||||
|
||||
INSERT INTO DirectReports VALUES
|
||||
|
||||
@@ -50,7 +50,7 @@ Affected Rows: 0
|
||||
|
||||
create table foo
|
||||
(
|
||||
ts bigint time index
|
||||
ts TIMESTAMP TIME INDEX
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
@@ -86,11 +86,11 @@ where table_catalog = 'greptime'
|
||||
and table_schema != 'information_schema'
|
||||
order by table_schema, table_name;
|
||||
|
||||
+---------------+--------------+------------+-------------+-----------+---------------+
|
||||
| table_catalog | table_schema | table_name | column_name | data_type | semantic_type |
|
||||
+---------------+--------------+------------+-------------+-----------+---------------+
|
||||
| greptime | my_db | foo | ts | Int64 | TIMESTAMP |
|
||||
+---------------+--------------+------------+-------------+-----------+---------------+
|
||||
+---------------+--------------+------------+-------------+----------------------+---------------+
|
||||
| table_catalog | table_schema | table_name | column_name | data_type | semantic_type |
|
||||
+---------------+--------------+------------+-------------+----------------------+---------------+
|
||||
| greptime | my_db | foo | ts | TimestampMillisecond | TIMESTAMP |
|
||||
+---------------+--------------+------------+-------------+----------------------+---------------+
|
||||
|
||||
use public;
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ use my_db;
|
||||
|
||||
create table foo
|
||||
(
|
||||
ts bigint time index
|
||||
ts TIMESTAMP TIME INDEX
|
||||
);
|
||||
|
||||
select table_name
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
CREATE TABLE integers(i INTEGER, j BIGINT TIME INDEX);
|
||||
CREATE TABLE integers(i INTEGER, j TIMESTAMP TIME INDEX);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -92,32 +92,32 @@ SELECT i1.i,i2.i FROM integers i1 LEFT OUTER JOIN integers i2 ON 1=1 WHERE i1.i=
|
||||
|
||||
SELECT * FROM integers WHERE i IN ((SELECT i FROM integers)) ORDER BY i;
|
||||
|
||||
+---+---+
|
||||
| i | j |
|
||||
+---+---+
|
||||
| 1 | 1 |
|
||||
| 2 | 2 |
|
||||
| 3 | 3 |
|
||||
+---+---+
|
||||
+---+-------------------------+
|
||||
| i | j |
|
||||
+---+-------------------------+
|
||||
| 1 | 1970-01-01T00:00:00.001 |
|
||||
| 2 | 1970-01-01T00:00:00.002 |
|
||||
| 3 | 1970-01-01T00:00:00.003 |
|
||||
+---+-------------------------+
|
||||
|
||||
SELECT * FROM integers WHERE i NOT IN ((SELECT i FROM integers WHERE i=1)) ORDER BY i;
|
||||
|
||||
+---+---+
|
||||
| i | j |
|
||||
+---+---+
|
||||
| 2 | 2 |
|
||||
| 3 | 3 |
|
||||
| | 4 |
|
||||
+---+---+
|
||||
+---+-------------------------+
|
||||
| i | j |
|
||||
+---+-------------------------+
|
||||
| 2 | 1970-01-01T00:00:00.002 |
|
||||
| 3 | 1970-01-01T00:00:00.003 |
|
||||
| | 1970-01-01T00:00:00.004 |
|
||||
+---+-------------------------+
|
||||
|
||||
SELECT * FROM integers WHERE i IN ((SELECT i FROM integers)) AND i<3 ORDER BY i;
|
||||
|
||||
+---+---+
|
||||
| i | j |
|
||||
+---+---+
|
||||
| 1 | 1 |
|
||||
| 2 | 2 |
|
||||
+---+---+
|
||||
+---+-------------------------+
|
||||
| i | j |
|
||||
+---+-------------------------+
|
||||
| 1 | 1970-01-01T00:00:00.001 |
|
||||
| 2 | 1970-01-01T00:00:00.002 |
|
||||
+---+-------------------------+
|
||||
|
||||
SELECT i1.i,i2.i FROM integers i1, integers i2 WHERE i IN ((SELECT i FROM integers)) AND i1.i=i2.i ORDER BY 1;
|
||||
|
||||
@@ -131,21 +131,21 @@ SELECT i1.i,i2.i FROM integers i1, integers i2 WHERE i IN ((SELECT i FROM intege
|
||||
|
||||
SELECT * FROM integers i1 WHERE EXISTS(SELECT i FROM integers WHERE i=i1.i) ORDER BY i1.i;
|
||||
|
||||
+---+---+
|
||||
| i | j |
|
||||
+---+---+
|
||||
| 1 | 1 |
|
||||
| 2 | 2 |
|
||||
| 3 | 3 |
|
||||
+---+---+
|
||||
+---+-------------------------+
|
||||
| i | j |
|
||||
+---+-------------------------+
|
||||
| 1 | 1970-01-01T00:00:00.001 |
|
||||
| 2 | 1970-01-01T00:00:00.002 |
|
||||
| 3 | 1970-01-01T00:00:00.003 |
|
||||
+---+-------------------------+
|
||||
|
||||
SELECT * FROM integers i1 WHERE NOT EXISTS(SELECT i FROM integers WHERE i=i1.i) ORDER BY i1.i;
|
||||
|
||||
+---+---+
|
||||
| i | j |
|
||||
+---+---+
|
||||
| | 4 |
|
||||
+---+---+
|
||||
+---+-------------------------+
|
||||
| i | j |
|
||||
+---+-------------------------+
|
||||
| | 1970-01-01T00:00:00.004 |
|
||||
+---+-------------------------+
|
||||
|
||||
SELECT i1.i,i2.i FROM integers i1, integers i2 WHERE i1.i=(SELECT i FROM integers WHERE i1.i=i) AND i1.i=i2.i ORDER BY i1.i;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
CREATE TABLE integers(i INTEGER, j BIGINT TIME INDEX);
|
||||
CREATE TABLE integers(i INTEGER, j TIMESTAMP TIME INDEX);
|
||||
|
||||
INSERT INTO integers VALUES (1, 1), (2, 2), (3, 3), (NULL, 4);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user