chore: rename the default ts column name to greptime_timestamp for influxdb line protocol (#7046)

* chore: rename influxdb ts column name to greptime_timestamp

Signed-off-by: shuiyisong <xixing.sys@gmail.com>

* fix: tests

Signed-off-by: shuiyisong <xixing.sys@gmail.com>

---------

Signed-off-by: shuiyisong <xixing.sys@gmail.com>
This commit is contained in:
shuiyisong
2025-10-09 10:14:11 +08:00
committed by GitHub
parent 1aa4f346a0
commit b24a55cea4
3 changed files with 10 additions and 10 deletions

View File

@@ -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<InfluxdbRequest> 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

View File

@@ -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 |

View File

@@ -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;