Repository navigation
Expand file tree
/
Copy pathtime_time64.ts
More file actions
73 lines (72 loc) · 1.52 KB
/
Copy pathtime_time64.ts
File metadata and controls
73 lines (72 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// See also:
// - https://clickhouse.com/docs/sql-reference/data-types/time
// - https://clickhouse.com/docs/sql-reference/data-types/time64
import { createClient } from "@clickhouse/client-web";
const tableName = `chjs_time_time64_web`;
const client = createClient({
clickhouse_settings: {
// Since ClickHouse 25.6
enable_time_time64_type: 1,
},
});
await client.command({
query: `
CREATE OR REPLACE TABLE ${tableName}
(
id UInt64,
t Time,
t64_0 Time64(0),
t64_3 Time64(3),
t64_6 Time64(6),
t64_9 Time64(9),
)
ENGINE MergeTree
ORDER BY id
`,
});
// Sample representation in JSONEachRow format
const values = [
{
id: 1,
t: "12:34:56",
t64_0: "12:34:56",
t64_3: "12:34:56.123",
t64_6: "12:34:56.123456",
t64_9: "12:34:56.123456789",
},
{
id: 2,
t: "23:59:59",
t64_0: "23:59:59",
t64_3: "23:59:59.987",
t64_6: "23:59:59.987654",
t64_9: "23:59:59.987654321",
},
{
id: 3,
t: "999:59:59",
t64_0: "999:59:59",
t64_3: "999:59:59.999",
t64_6: "999:59:59.999999",
t64_9: "999:59:59.999999999",
},
{
id: 4,
t: "-999:59:59",
t64_0: "-999:59:59",
t64_3: "-999:59:59.999",
t64_6: "-999:59:59.999999",
t64_9: "-999:59:59.999999999",
},
];
await client.insert({
table: tableName,
format: "JSONEachRow",
values,
});
const rs = await client.query({
query: `SELECT * FROM ${tableName}`,
format: "JSONEachRow",
});
console.log(await rs.json());
await client.close();