From 8a89615ddb63070d6ce3420c54f281c41677d76c Mon Sep 17 00:00:00 2001 From: xxhZs <1060434431@qq.com> Date: Wed, 19 Feb 2025 16:49:59 +0800 Subject: [PATCH] fix comm --- proto/data.proto | 4 +- .../executors/src/executor/postgres_query.rs | 1 - src/common/src/array/arrow/arrow_iceberg.rs | 4 +- src/common/src/array/arrow/arrow_impl.rs | 42 +++--- src/common/src/array/chrono_array.rs | 6 +- src/common/src/array/mod.rs | 4 +- src/common/src/array/primitive_array.rs | 2 +- src/common/src/array/proto_reader.rs | 4 +- src/common/src/hash/key.rs | 8 +- src/common/src/row/owned_row.rs | 8 +- src/common/src/test_utils/rand_array.rs | 6 +- src/common/src/test_utils/rand_chunk.rs | 8 +- src/common/src/types/datetime.rs | 134 ++++++++++-------- src/common/src/types/macros.rs | 2 +- src/common/src/types/map_type.rs | 2 +- src/common/src/types/mod.rs | 39 +++-- src/common/src/types/postgres_type.rs | 8 +- src/common/src/types/scalar_impl.rs | 12 +- src/common/src/types/to_binary.rs | 6 +- src/common/src/types/to_sql.rs | 4 +- src/common/src/types/with_data_type.rs | 4 +- src/common/src/util/memcmp_encoding.rs | 6 +- src/common/src/util/value_encoding/mod.rs | 12 +- src/connector/src/parser/csv_parser.rs | 4 +- src/connector/src/parser/mysql.rs | 6 +- src/connector/src/parser/postgres.rs | 3 +- src/connector/src/parser/unified/json.rs | 8 +- src/connector/src/sink/big_query.rs | 28 ++-- src/connector/src/sink/clickhouse.rs | 10 +- src/connector/src/sink/doris.rs | 15 +- src/connector/src/sink/dynamodb.rs | 2 +- src/connector/src/sink/encoder/avro.rs | 2 +- src/connector/src/sink/encoder/bson.rs | 2 +- src/connector/src/sink/encoder/json.rs | 2 +- src/connector/src/sink/encoder/proto.rs | 4 +- .../src/sink/formatter/debezium_json.rs | 2 +- src/connector/src/sink/remote.rs | 3 +- src/connector/src/sink/sqlserver.rs | 7 +- src/connector/src/sink/starrocks.rs | 5 +- .../source/iceberg/parquet_file_handler.rs | 2 +- src/expr/impl/src/aggregate/general.rs | 1 + src/expr/impl/src/scalar/cmp.rs | 25 ++++ src/expr/impl/src/scalar/date_trunc.rs | 7 +- src/expr/impl/src/scalar/extract.rs | 42 ++++-- src/expr/impl/src/scalar/make_time.rs | 10 +- src/expr/impl/src/scalar/timestamptz.rs | 8 +- src/expr/impl/src/scalar/to_char.rs | 8 +- src/expr/impl/src/scalar/to_jsonb.rs | 7 +- src/expr/impl/src/udf/wasm.rs | 2 +- src/expr/macro/src/lib.rs | 2 +- src/expr/macro/src/types.rs | 4 +- src/frontend/src/binder/expr/mod.rs | 2 +- src/frontend/src/expr/literal.rs | 2 +- src/frontend/src/expr/session_timezone.rs | 6 +- src/frontend/src/expr/type_inference/cast.rs | 36 ++--- .../src/optimizer/property/monotonicity.rs | 3 +- .../optimizer/rule/index_selection_rule.rs | 5 +- src/frontend/src/utils/data_type.rs | 4 +- src/tests/sqlsmith/src/sql_gen/types.rs | 2 +- 59 files changed, 323 insertions(+), 284 deletions(-) diff --git a/proto/data.proto b/proto/data.proto index 478fc3e522c8f..5335aed4900fa 100644 --- a/proto/data.proto +++ b/proto/data.proto @@ -53,7 +53,7 @@ message DataType { SERIAL = 19; INT256 = 20; MAP = 21; - TIMESTAMP_NANOSECOND = 22; + Timestamp_ns = 22; } TypeName type_name = 1; // Data length for char. @@ -105,7 +105,7 @@ enum ArrayType { SERIAL = 17; INT256 = 18; MAP = 20; - TIMESTAMP_NANOSECOND = 21; + Timestamp_ns = 21; } message Array { diff --git a/src/batch/executors/src/executor/postgres_query.rs b/src/batch/executors/src/executor/postgres_query.rs index 9a265a195f054..e7ce698e1e841 100644 --- a/src/batch/executors/src/executor/postgres_query.rs +++ b/src/batch/executors/src/executor/postgres_query.rs @@ -85,7 +85,6 @@ fn postgres_cell_to_scalar_impl( | DataType::Date | DataType::Time | DataType::Timestamp - | DataType::TimestampNanosecond | DataType::Timestamptz | DataType::Jsonb | DataType::Interval diff --git a/src/common/src/array/arrow/arrow_iceberg.rs b/src/common/src/array/arrow/arrow_iceberg.rs index 10f0041e24eaa..172172bd97208 100644 --- a/src/common/src/array/arrow/arrow_iceberg.rs +++ b/src/common/src/array/arrow/arrow_iceberg.rs @@ -97,7 +97,7 @@ impl ToArrow for IcebergArrowConvert { DataType::Date => self.date_type_to_arrow(), DataType::Time => self.time_type_to_arrow(), DataType::Timestamp => self.timestamp_type_to_arrow(), - DataType::TimestampNanosecond => self.timestampns_type_to_arrow(), + DataType::TimestampNs => self.timestamp_ns_type_to_arrow(), DataType::Timestamptz => self.timestamptz_type_to_arrow(), DataType::Interval => self.interval_type_to_arrow(), DataType::Varchar => self.varchar_type_to_arrow(), @@ -247,7 +247,7 @@ impl ToArrow for IcebergCreateTableArrowConvert { DataType::Date => self.date_type_to_arrow(), DataType::Time => self.time_type_to_arrow(), DataType::Timestamp => self.timestamp_type_to_arrow(), - DataType::TimestampNanosecond => self.timestampns_type_to_arrow(), + DataType::TimestampNs => self.timestamp_ns_type_to_arrow(), DataType::Timestamptz => self.timestamptz_type_to_arrow(), DataType::Interval => self.interval_type_to_arrow(), DataType::Varchar => self.varchar_type_to_arrow(), diff --git a/src/common/src/array/arrow/arrow_impl.rs b/src/common/src/array/arrow/arrow_impl.rs index 199b8dfd48c5c..ba36dea80dd47 100644 --- a/src/common/src/array/arrow/arrow_impl.rs +++ b/src/common/src/array/arrow/arrow_impl.rs @@ -107,7 +107,7 @@ pub trait ToArrow { ArrayImpl::Date(array) => self.date_to_arrow(array), ArrayImpl::Time(array) => self.time_to_arrow(array), ArrayImpl::Timestamp(array) => self.timestamp_to_arrow(array), - ArrayImpl::TimestampNanosecond(array) => self.timestampns_to_arrow(array), + ArrayImpl::TimestampNs(array) => self.timestamp_ns_to_arrow(array), ArrayImpl::Timestamptz(array) => self.timestamptz_to_arrow(array), ArrayImpl::Interval(array) => self.interval_to_arrow(array), ArrayImpl::Utf8(array) => self.utf8_to_arrow(array), @@ -182,9 +182,9 @@ pub trait ToArrow { } #[inline] - fn timestampns_to_arrow( + fn timestamp_ns_to_arrow( &self, - array: &TimestampNanosecondArray, + array: &TimestampNsArray, ) -> Result { Ok(Arc::new(arrow_array::TimestampNanosecondArray::from(array))) } @@ -328,7 +328,7 @@ pub trait ToArrow { DataType::Date => self.date_type_to_arrow(), DataType::Time => self.time_type_to_arrow(), DataType::Timestamp => self.timestamp_type_to_arrow(), - DataType::TimestampNanosecond => self.timestampns_type_to_arrow(), + DataType::TimestampNs => self.timestamp_ns_type_to_arrow(), DataType::Timestamptz => self.timestamptz_type_to_arrow(), DataType::Interval => self.interval_type_to_arrow(), DataType::Varchar => self.varchar_type_to_arrow(), @@ -393,7 +393,7 @@ pub trait ToArrow { arrow_schema::DataType::Timestamp(arrow_schema::TimeUnit::Microsecond, None) } #[inline] - fn timestampns_type_to_arrow(&self) -> arrow_schema::DataType { + fn timestamp_ns_type_to_arrow(&self) -> arrow_schema::DataType { arrow_schema::DataType::Timestamp(arrow_schema::TimeUnit::Nanosecond, None) } @@ -537,7 +537,7 @@ pub trait FromArrow { Timestamp(Second, Some(_)) => DataType::Timestamptz, Timestamp(Millisecond, None) => DataType::Timestamp, Timestamp(Millisecond, Some(_)) => DataType::Timestamptz, - Timestamp(Nanosecond, None) => DataType::TimestampNanosecond, + Timestamp(Nanosecond, None) => DataType::TimestampNs, Timestamp(Nanosecond, Some(_)) => DataType::Timestamptz, Interval(MonthDayNano) => DataType::Interval, Utf8 => DataType::Varchar, @@ -636,10 +636,10 @@ pub trait FromArrow { self.from_timestampus_some_array(array.as_any().downcast_ref().unwrap()) } Timestamp(Nanosecond, None) => { - self.from_timestampns_array(array.as_any().downcast_ref().unwrap()) + self.from_timestamp_ns_array(array.as_any().downcast_ref().unwrap()) } Timestamp(Nanosecond, Some(_)) => { - self.from_timestampns_some_array(array.as_any().downcast_ref().unwrap()) + self.from_timestamp_ns_some_array(array.as_any().downcast_ref().unwrap()) } Interval(MonthDayNano) => { self.from_interval_array(array.as_any().downcast_ref().unwrap()) @@ -811,14 +811,14 @@ pub trait FromArrow { Ok(ArrayImpl::Timestamptz(array.into())) } - fn from_timestampns_array( + fn from_timestamp_ns_array( &self, array: &arrow_array::TimestampNanosecondArray, ) -> Result { - Ok(ArrayImpl::TimestampNanosecond(array.into())) + Ok(ArrayImpl::TimestampNs(array.into())) } - fn from_timestampns_some_array( + fn from_timestamp_ns_some_array( &self, array: &arrow_array::TimestampNanosecondArray, ) -> Result { @@ -1060,10 +1060,10 @@ converts_with_timeunit!(TimestamptzArray, arrow_array::TimestampMillisecondArray converts_with_timeunit!(TimestamptzArray, arrow_array::TimestampMicrosecondArray, TimeUnit::Microsecond, @map); converts_with_timeunit!(TimestamptzArray, arrow_array::TimestampNanosecondArray, TimeUnit::Nanosecond, @map); -converts_with_timeunit!(TimestampNanosecondArray, arrow_array::TimestampSecondArray, TimeUnit::Second, @map); -converts_with_timeunit!(TimestampNanosecondArray, arrow_array::TimestampMillisecondArray, TimeUnit::Millisecond, @map); -converts_with_timeunit!(TimestampNanosecondArray, arrow_array::TimestampMicrosecondArray, TimeUnit::Microsecond, @map); -converts_with_timeunit!(TimestampNanosecondArray, arrow_array::TimestampNanosecondArray, TimeUnit::Nanosecond, @map); +converts_with_timeunit!(TimestampNsArray, arrow_array::TimestampSecondArray, TimeUnit::Second, @map); +converts_with_timeunit!(TimestampNsArray, arrow_array::TimestampMillisecondArray, TimeUnit::Millisecond, @map); +converts_with_timeunit!(TimestampNsArray, arrow_array::TimestampMicrosecondArray, TimeUnit::Microsecond, @map); +converts_with_timeunit!(TimestampNsArray, arrow_array::TimestampNanosecondArray, TimeUnit::Nanosecond, @map); /// Converts RisingWave value from and into Arrow value. trait FromIntoArrow { @@ -1181,24 +1181,22 @@ impl FromIntoArrowWithUnit for Timestamp { } } -impl FromIntoArrowWithUnit for TimestampNanosecond { +impl FromIntoArrowWithUnit for TimestampNs { type ArrowType = i64; type TimestampType = TimeUnit; fn from_arrow_with_unit(value: Self::ArrowType, time_unit: Self::TimestampType) -> Self { match time_unit { TimeUnit::Second => { - TimestampNanosecond(DateTime::from_timestamp(value as _, 0).unwrap().naive_utc()) + TimestampNs(DateTime::from_timestamp(value as _, 0).unwrap().naive_utc()) } TimeUnit::Millisecond => { - TimestampNanosecond(DateTime::from_timestamp_millis(value).unwrap().naive_utc()) + TimestampNs(DateTime::from_timestamp_millis(value).unwrap().naive_utc()) } TimeUnit::Microsecond => { - TimestampNanosecond(DateTime::from_timestamp_micros(value).unwrap().naive_utc()) - } - TimeUnit::Nanosecond => { - TimestampNanosecond(DateTime::from_timestamp_nanos(value).naive_utc()) + TimestampNs(DateTime::from_timestamp_micros(value).unwrap().naive_utc()) } + TimeUnit::Nanosecond => TimestampNs(DateTime::from_timestamp_nanos(value).naive_utc()), } } diff --git a/src/common/src/array/chrono_array.rs b/src/common/src/array/chrono_array.rs index 91fb84d4feb0b..91399fb62d15c 100644 --- a/src/common/src/array/chrono_array.rs +++ b/src/common/src/array/chrono_array.rs @@ -12,19 +12,19 @@ // See the License for the specific language governing permissions and // limitations under the License. -use super::{PrimitiveArray, PrimitiveArrayBuilder, TimestampNanosecond}; +use super::{PrimitiveArray, PrimitiveArrayBuilder, TimestampNs}; use crate::types::{Date, Time, Timestamp, Timestamptz}; pub type DateArray = PrimitiveArray; pub type TimeArray = PrimitiveArray