From 38c0f917a669c8aad670581c1aed52c11b3466ec Mon Sep 17 00:00:00 2001 From: sundyli <543950155@qq.com> Date: Thu, 6 Feb 2025 22:03:47 +0800 Subject: [PATCH 1/4] fix: fix time display --- cli/tests/00-base.result | 1 + cli/tests/00-base.sql | 1 + sql/src/value.rs | 16 ++++++++++------ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/cli/tests/00-base.result b/cli/tests/00-base.result index 125d60244..b80de41ea 100644 --- a/cli/tests/00-base.result +++ b/cli/tests/00-base.result @@ -7,6 +7,7 @@ a 1 true [1,2] 1 2 3 +1740-10-08 10:16:40.001000 1740-10-08 10:16:40.000000 1740-10-08 10:16:39.999000 [] {} with comment 1 diff --git a/cli/tests/00-base.sql b/cli/tests/00-base.sql index 7882d3a7b..6a9db5fa5 100644 --- a/cli/tests/00-base.sql +++ b/cli/tests/00-base.sql @@ -9,6 +9,7 @@ insert into test select to_string(number), number, false, number from numbers(10 select min(a), max(b), max(d), count() from test; select '1';select 2; select 1+2; +select TO_TIMESTAMP(-7233803000000+1), TO_TIMESTAMP(-7233803000000), TO_TIMESTAMP(-7233803000000-1); select [], {}; diff --git a/sql/src/value.rs b/sql/src/value.rs index 5a5a0d8d7..c85593b5d 100644 --- a/sql/src/value.rs +++ b/sql/src/value.rs @@ -40,6 +40,7 @@ const DAYS_FROM_CE: i32 = 719_163; const NULL_VALUE: &str = "NULL"; const TRUE_VALUE: &str = "1"; const FALSE_VALUE: &str = "0"; +const TIMESTAMP_FORMAT: &str = "%Y-%m-%d %H:%M:%S%.6f"; #[cfg(feature = "flight-sql")] use { @@ -837,15 +838,18 @@ fn encode_value(f: &mut std::fmt::Formatter<'_>, val: &Value, raw: bool) -> std: write!(f, "'{}'", s) } } - Value::Timestamp(i) => { - let secs = i / 1_000_000; - let nanos = ((i % 1_000_000) * 1000) as u32; - let t = DateTime::from_timestamp(secs, nanos).unwrap_or_default(); + Value::Timestamp(micros) => { + let (mut secs, mut nanos) = (*micros / 1_000_000, (*micros % 1_000_000) * 1_000); + if nanos < 0 { + secs -= 1; + nanos += 1_000_000_000; + } + let t = DateTime::from_timestamp(secs, nanos as _).unwrap_or_default(); let t = t.naive_utc(); if raw { - write!(f, "{}", t) + write!(f, "{}", t.format(TIMESTAMP_FORMAT)) } else { - write!(f, "'{}'", t) + write!(f, "'{}'", t.format(TIMESTAMP_FORMAT)) } } Value::Date(i) => { From 576cdeec1d4ecadcf8477828767b3269894e5868 Mon Sep 17 00:00:00 2001 From: sundyli <543950155@qq.com> Date: Thu, 6 Feb 2025 22:20:02 +0800 Subject: [PATCH 2/4] fix: fix time display --- cli/tests/http/01-load_stdin.result | 6 +++--- cli/tests/http/02-load_file.result | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cli/tests/http/01-load_stdin.result b/cli/tests/http/01-load_stdin.result index 8d160ae80..07ef3ca4d 100644 --- a/cli/tests/http/01-load_stdin.result +++ b/cli/tests/http/01-load_stdin.result @@ -1,3 +1,3 @@ -Transaction Processing Jim Gray 1992 2020-01-01 11:11:11.345 -Readings in Database Systems Michael Stonebraker 2004 2020-01-01 11:11:11 -Three Body NULL-liucixin 2019 2019-07-04 00:00:00 +Transaction Processing Jim Gray 1992 2020-01-01 11:11:11.345000 +Readings in Database Systems Michael Stonebraker 2004 2020-01-01 11:11:11.000000 +Three Body NULL-liucixin 2019 2019-07-04 00:00:00.000000 diff --git a/cli/tests/http/02-load_file.result b/cli/tests/http/02-load_file.result index 8d160ae80..07ef3ca4d 100644 --- a/cli/tests/http/02-load_file.result +++ b/cli/tests/http/02-load_file.result @@ -1,3 +1,3 @@ -Transaction Processing Jim Gray 1992 2020-01-01 11:11:11.345 -Readings in Database Systems Michael Stonebraker 2004 2020-01-01 11:11:11 -Three Body NULL-liucixin 2019 2019-07-04 00:00:00 +Transaction Processing Jim Gray 1992 2020-01-01 11:11:11.345000 +Readings in Database Systems Michael Stonebraker 2004 2020-01-01 11:11:11.000000 +Three Body NULL-liucixin 2019 2019-07-04 00:00:00.000000 From 8a27242411f9da37ca5ed063bad8b5010c99490e Mon Sep 17 00:00:00 2001 From: sundyli <543950155@qq.com> Date: Fri, 7 Feb 2025 08:26:25 +0800 Subject: [PATCH 3/4] fix: fix node version --- .github/workflows/bindings.nodejs.yml | 8 ++++---- .github/workflows/frontend.yml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/bindings.nodejs.yml b/.github/workflows/bindings.nodejs.yml index 944618396..46587e9f0 100644 --- a/.github/workflows/bindings.nodejs.yml +++ b/.github/workflows/bindings.nodejs.yml @@ -35,7 +35,7 @@ jobs: node-version: "22" - name: Corepack working-directory: bindings/nodejs - run: corepack enable + run: npm i -g --force corepack && corepack enable - name: Install dependencies working-directory: bindings/nodejs run: pnpm install @@ -76,7 +76,7 @@ jobs: version: 0.11.0 - name: Corepack working-directory: bindings/nodejs - run: corepack enable + run: npm i -g --force corepack && corepack enable - name: Install dependencies working-directory: bindings/nodejs run: pnpm install @@ -117,7 +117,7 @@ jobs: node-version: ${{ matrix.ver }} - name: Corepack working-directory: bindings/nodejs - run: corepack enable + run: npm i -g --force corepack && corepack enable - name: Install dependencies working-directory: bindings/nodejs run: pnpm install @@ -146,7 +146,7 @@ jobs: node-version: "22" - name: Corepack working-directory: bindings/nodejs - run: corepack enable + run: npm i -g --force corepack && corepack enable - name: Install dependencies working-directory: bindings/nodejs run: pnpm install diff --git a/.github/workflows/frontend.yml b/.github/workflows/frontend.yml index f757592d6..dc5484e33 100644 --- a/.github/workflows/frontend.yml +++ b/.github/workflows/frontend.yml @@ -22,7 +22,7 @@ jobs: with: node-version: "22" - - run: corepack enable + - run: npm i -g --force corepack && corepack enable - name: Install dependencies working-directory: frontend/ From 8565cf1aca585b5319441ec32a6847784fb88ee9 Mon Sep 17 00:00:00 2001 From: sundyli <543950155@qq.com> Date: Fri, 7 Feb 2025 08:39:11 +0800 Subject: [PATCH 4/4] fix: disable windows nodejs check --- .github/workflows/bindings.nodejs.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/bindings.nodejs.yml b/.github/workflows/bindings.nodejs.yml index 46587e9f0..0caeb90e3 100644 --- a/.github/workflows/bindings.nodejs.yml +++ b/.github/workflows/bindings.nodejs.yml @@ -54,8 +54,9 @@ jobs: - { target: aarch64-unknown-linux-gnu, runner: ubuntu-20.04 } - { target: x86_64-unknown-linux-musl, runner: ubuntu-latest } - { target: aarch64-unknown-linux-musl, runner: ubuntu-latest } - - { target: x86_64-pc-windows-msvc, runner: windows-latest } - - { target: aarch64-pc-windows-msvc, runner: windows-latest } + # resolve it after: https://github.com/actions/setup-node/issues/1222 + # - { target: x86_64-pc-windows-msvc, runner: windows-latest } + # - { target: aarch64-pc-windows-msvc, runner: windows-latest } - { target: x86_64-apple-darwin, runner: macos-latest } - { target: aarch64-apple-darwin, runner: macos-latest } steps: