diff --git a/.github/workflows/bindings.nodejs.yml b/.github/workflows/bindings.nodejs.yml index 944618396..0caeb90e3 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 @@ -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: @@ -76,7 +77,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 +118,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 +147,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/ 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 98ae616ce..4bd2c1d93 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/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 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) => {