Skip to content

Commit

Permalink
Merge branch 'main' into wkx/fix-timestamp-to_text
Browse files Browse the repository at this point in the history
  • Loading branch information
KeXiangWang authored Feb 23, 2024
2 parents 49c8bc3 + e6d8d88 commit f0da66f
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 18 deletions.
5 changes: 3 additions & 2 deletions e2e_test/batch/catalog/pg_cast.slt.part
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ SELECT * FROM pg_catalog.pg_cast;
78 3802 701 e
79 3802 1700 e
80 3802 1043 a
81 1301 701 e
82 1301 1043 a
81 20 20 e
82 1301 701 e
83 1301 1043 a

query TT rowsort
SELECT s.typname, t.typname
Expand Down
6 changes: 6 additions & 0 deletions src/common/src/types/serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ use crate::util::row_id::RowId;
#[derive(Debug, Copy, Clone, PartialEq, Eq, Ord, PartialOrd, Default, Hash)]
pub struct Serial(i64);

impl From<Serial> for i64 {
fn from(value: Serial) -> i64 {
value.0
}
}

impl From<i64> for Serial {
fn from(value: i64) -> Self {
Self(value)
Expand Down
1 change: 1 addition & 0 deletions src/expr/impl/src/scalar/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ pub fn jsonb_to_number<T: TryFrom<F64>>(v: JsonbRef<'_>) -> Result<T> {
#[function("cast(int4) -> int2")]
#[function("cast(int8) -> int2")]
#[function("cast(int8) -> int4")]
#[function("cast(serial) -> int8")]
#[function("cast(float4) -> int2")]
#[function("cast(float8) -> int2")]
#[function("cast(float4) -> int4")]
Expand Down
33 changes: 17 additions & 16 deletions src/frontend/src/expr/type_inference/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,22 +216,23 @@ pub static CAST_MAP: LazyLock<CastMap> = LazyLock::new(|| {
use DataTypeName::*;
const CAST_TABLE: &[(&str, DataTypeName)] = &[
// 123456789ABCDEF
(". e a", Boolean), // 0
(" .iiiiii a", Int16), // 1
("ea.iiiii a", Int32), // 2
(" aa.iiii a", Int64), // 3
(" aaa.ii a", Decimal), // 4
(" aaaa.i a", Float32), // 5
(" aaaaa. a", Float64), // 6
(" e. a", Int256), // 7
(" .ii a", Date), // 8
(" a.ia a", Timestamp), // 9
(" aa.a a", Timestamptz), // A
(" .i a", Time), // B
(" a. a", Interval), // C
("eeeeeee . a", Jsonb), // D
(" .a", Bytea), // E
("eeeeeeeeeeeeeee.", Varchar), // F
(". e a ", Boolean), // 0
(" .iiiiii a ", Int16), // 1
("ea.iiiii a ", Int32), // 2
(" aa.iiii a ", Int64), // 3
(" aaa.ii a ", Decimal), // 4
(" aaaa.i a ", Float32), // 5
(" aaaaa. a ", Float64), // 6
(" e. a ", Int256), // 7
(" .ii a ", Date), // 8
(" a.ia a ", Timestamp), // 9
(" aa.a a ", Timestamptz), // A
(" .i a ", Time), // B
(" a. a ", Interval), // C
("eeeeeee . a ", Jsonb), // D
(" .a ", Bytea), // E
("eeeeeeeeeeeeeee. ", Varchar), // F
(" e .", Serial),
];
let mut map = BTreeMap::new();
for (row, source) in CAST_TABLE {
Expand Down

0 comments on commit f0da66f

Please sign in to comment.