diff --git a/src/servers/src/influxdb.rs b/src/servers/src/influxdb.rs index f9ffd754dd..2ebfd9dd08 100644 --- a/src/servers/src/influxdb.rs +++ b/src/servers/src/influxdb.rs @@ -15,6 +15,7 @@ use api::v1::value::ValueData; use api::v1::{ColumnDataType, RowInsertRequests}; use common_grpc::precision::Precision; +use common_query::prelude::GREPTIME_TIMESTAMP; use hyper::Request; use influxdb_line_protocol::{FieldValue, parse_lines}; use snafu::ResultExt; @@ -24,7 +25,6 @@ use crate::row_writer::{self, MultiTableData}; const INFLUXDB_API_PATH_NAME: &str = "influxdb"; const INFLUXDB_API_V2_PATH_NAME: &str = "influxdb/api/v2"; -const INFLUXDB_TIMESTAMP_COLUMN_NAME: &str = "ts"; const DEFAULT_TIME_PRECISION: Precision = Precision::Nanosecond; #[inline] @@ -91,7 +91,7 @@ impl TryFrom for RowInsertRequests { // timestamp row_writer::write_ts_to_nanos( table_data, - INFLUXDB_TIMESTAMP_COLUMN_NAME, + GREPTIME_TIMESTAMP, ts, precision, &mut one_row, @@ -193,7 +193,7 @@ monitor2,host=host4 cpu=66.3,memory=1029 1663840496400340003"; } } } - "ts" => { + "greptime_timestamp" => { assert_eq!( ColumnDataType::TimestampNanosecond as i32, column_schema.datatype @@ -268,7 +268,7 @@ monitor2,host=host4 cpu=66.3,memory=1029 1663840496400340003"; } } } - "ts" => { + "greptime_timestamp" => { assert_eq!( ColumnDataType::TimestampNanosecond as i32, column_schema.datatype diff --git a/tests-integration/src/influxdb.rs b/tests-integration/src/influxdb.rs index 85ea8fc2a7..e0eb7192c6 100644 --- a/tests-integration/src/influxdb.rs +++ b/tests-integration/src/influxdb.rs @@ -42,7 +42,7 @@ monitor1,host=host2 memory=1027"; let mut output = instance .do_query( - "SELECT ts, host, cpu, memory FROM monitor1 ORDER BY ts", + "SELECT greptime_timestamp, host, cpu, memory FROM monitor1 ORDER BY greptime_timestamp", QueryContext::arc(), ) .await; @@ -74,7 +74,7 @@ monitor1,host=host2 memory=1027 1663840496400340001"; let mut output = instance .do_query( - "SELECT ts, host, cpu, memory FROM monitor1 ORDER BY ts", + "SELECT greptime_timestamp, host, cpu, memory FROM monitor1 ORDER BY greptime_timestamp", QueryContext::arc(), ) .await; @@ -87,7 +87,7 @@ monitor1,host=host2 memory=1027 1663840496400340001"; recordbatches.pretty_print().unwrap(), "\ +-------------------------------+-------+------+--------+ -| ts | host | cpu | memory | +| greptime_timestamp | host | cpu | memory | +-------------------------------+-------+------+--------+ | 2022-09-22T09:54:56.100023100 | host1 | 66.6 | 1024.0 | | 2022-09-22T09:54:56.400340001 | host2 | | 1027.0 | @@ -105,7 +105,7 @@ monitor1,host=host2 cpu=32 1663840496400340001"; let mut output = instance .do_query( - "SELECT ts, host, cpu, memory FROM monitor1 ORDER BY ts", + "SELECT greptime_timestamp, host, cpu, memory FROM monitor1 ORDER BY greptime_timestamp", QueryContext::arc(), ) .await; @@ -118,7 +118,7 @@ monitor1,host=host2 cpu=32 1663840496400340001"; recordbatches.pretty_print().unwrap(), "\ +-------------------------------+-------+------+--------+ -| ts | host | cpu | memory | +| greptime_timestamp | host | cpu | memory | +-------------------------------+-------+------+--------+ | 2022-09-22T09:54:56.100023100 | host1 | 66.6 | 1024.0 | | 2022-09-22T09:54:56.400340001 | host2 | 32.0 | 1027.0 | diff --git a/tests-integration/tests/http.rs b/tests-integration/tests/http.rs index 4a3a2beb34..2bae3bf8c8 100644 --- a/tests-integration/tests/http.rs +++ b/tests-integration/tests/http.rs @@ -6448,7 +6448,7 @@ pub async fn test_influxdb_write(store_type: StorageType) { validate_data( "test_influxdb_write", &client, - "select * from test_alter order by ts;", + "select * from test_alter order by greptime_timestamp;", expected, ) .await;