CREATE TABLE demo(host string, cpu double, memory double, jsons JSON, ts TIMESTAMP time index); Affected Rows: 0 insert into demo(host, cpu, memory, jsons, ts) values ('host1', 66.6, 1024, '{"foo":"bar"}', 1655276557000), ('host2', 88.8, 333.3, '{"a":null,"foo":"bar"}', 1655276558000); Affected Rows: 2 insert into demo(host, cpu, memory, ts) values ('host3', 99.9, 444.4, 1722077263000); Affected Rows: 1 Copy demo TO '${SQLNESS_HOME}/demo/export/csv/demo.csv' with (format='csv'); Affected Rows: 3 CREATE TABLE with_filename(host string, cpu double, memory double, ts timestamp time index); Affected Rows: 0 Copy with_filename FROM '${SQLNESS_HOME}/demo/export/csv/demo.csv' with (format='csv', start_time='2022-06-15 07:02:37', end_time='2022-06-15 07:02:39'); Affected Rows: 2 select * from with_filename order by ts; +-------+------+--------+---------------------+ | host | cpu | memory | ts | +-------+------+--------+---------------------+ | host1 | 66.6 | 1024.0 | 2022-06-15T07:02:37 | | host2 | 88.8 | 333.3 | 2022-06-15T07:02:38 | +-------+------+--------+---------------------+ CREATE TABLE with_json(host string, cpu double, memory double, jsons JSON, ts timestamp time index); Affected Rows: 0 Copy with_json FROM '${SQLNESS_HOME}/demo/export/csv/demo.csv' with (format='csv'); Affected Rows: 3 select host, cpu, memory, json_to_string(jsons), ts from with_json order by ts; +-------+------+--------+---------------------------------+---------------------+ | host | cpu | memory | json_to_string(with_json.jsons) | ts | +-------+------+--------+---------------------------------+---------------------+ | host1 | 66.6 | 1024.0 | {"foo":"bar"} | 2022-06-15T07:02:37 | | host2 | 88.8 | 333.3 | {"a":null,"foo":"bar"} | 2022-06-15T07:02:38 | | host3 | 99.9 | 444.4 | | 2024-07-27T10:47:43 | +-------+------+--------+---------------------------------+---------------------+ -- SQLNESS PROTOCOL MYSQL select host, cpu, memory, jsons, ts from demo where host != 'host3'; +-------+------+--------+------------------------+---------------------+ | host | cpu | memory | jsons | ts | +-------+------+--------+------------------------+---------------------+ | host1 | 66.6 | 1024 | {"foo":"bar"} | 2022-06-15 07:02:37 | | host2 | 88.8 | 333.3 | {"a":null,"foo":"bar"} | 2022-06-15 07:02:38 | +-------+------+--------+------------------------+---------------------+ -- SQLNESS PROTOCOL POSTGRES select host, cpu, memory, jsons, ts from demo where host != 'host3'; +-------+------+--------+------------------------+----------------------------+ | host | cpu | memory | jsons | ts | +-------+------+--------+------------------------+----------------------------+ | host1 | 66.6 | 1024.0 | {"foo":"bar"} | 2022-06-15 07:02:37.000000 | | host2 | 88.8 | 333.3 | {"a":null,"foo":"bar"} | 2022-06-15 07:02:38.000000 | +-------+------+--------+------------------------+----------------------------+ CREATE TABLE with_path(host string, cpu double, memory double, ts timestamp time index); Affected Rows: 0 Copy with_path FROM '${SQLNESS_HOME}/demo/export/csv/' with (format='csv', start_time='2023-06-15 07:02:37'); Affected Rows: 1 select * from with_path order by ts; +-------+------+--------+---------------------+ | host | cpu | memory | ts | +-------+------+--------+---------------------+ | host3 | 99.9 | 444.4 | 2024-07-27T10:47:43 | +-------+------+--------+---------------------+ CREATE TABLE with_pattern(host string, cpu double, memory double, ts timestamp time index); Affected Rows: 0 Copy with_pattern FROM '${SQLNESS_HOME}/demo/export/csv/' WITH (pattern = 'demo.*', format='csv', end_time='2025-06-15 07:02:39'); Affected Rows: 3 select * from with_pattern order by ts; +-------+------+--------+---------------------+ | host | cpu | memory | ts | +-------+------+--------+---------------------+ | host1 | 66.6 | 1024.0 | 2022-06-15T07:02:37 | | host2 | 88.8 | 333.3 | 2022-06-15T07:02:38 | | host3 | 99.9 | 444.4 | 2024-07-27T10:47:43 | +-------+------+--------+---------------------+ CREATE TABLE demo_with_external_column(host string, cpu double, memory double, ts timestamp time index, external_column string default 'default_value'); Affected Rows: 0 Copy demo_with_external_column FROM '${SQLNESS_HOME}/demo/export/csv/demo.csv' WITH (format='csv'); Affected Rows: 3 select * from demo_with_external_column order by ts; +-------+------+--------+---------------------+-----------------+ | host | cpu | memory | ts | external_column | +-------+------+--------+---------------------+-----------------+ | host1 | 66.6 | 1024.0 | 2022-06-15T07:02:37 | default_value | | host2 | 88.8 | 333.3 | 2022-06-15T07:02:38 | default_value | | host3 | 99.9 | 444.4 | 2024-07-27T10:47:43 | default_value | +-------+------+--------+---------------------+-----------------+ CREATE TABLE demo_with_less_columns(host string, memory double, ts timestamp time index); Affected Rows: 0 Copy demo_with_less_columns FROM '${SQLNESS_HOME}/demo/export/csv/demo.csv' WITH (format='csv'); Affected Rows: 3 select * from demo_with_less_columns order by ts; +-------+--------+---------------------+ | host | memory | ts | +-------+--------+---------------------+ | host1 | 1024.0 | 2022-06-15T07:02:37 | | host2 | 333.3 | 2022-06-15T07:02:38 | | host3 | 444.4 | 2024-07-27T10:47:43 | +-------+--------+---------------------+ CREATE TABLE csv_null_prefix(note string, ts timestamp time index); Affected Rows: 0 insert into csv_null_prefix(note, ts) values (NULL, 1700000000000), (NULL, 1700000001000), (NULL, 1700000002000), ('final', 1700000003000); Affected Rows: 4 Copy csv_null_prefix TO '${SQLNESS_HOME}/demo/export/csv_null_prefix.csv' with (format='csv'); Affected Rows: 4 CREATE TABLE csv_null_prefix_import(note string, ts timestamp time index); Affected Rows: 0 Copy csv_null_prefix_import FROM '${SQLNESS_HOME}/demo/export/csv_null_prefix.csv' with (format='csv', schema_infer_max_record=2); Affected Rows: 4 select * from csv_null_prefix_import; +-------+---------------------+ | note | ts | +-------+---------------------+ | | 2023-11-14T22:13:20 | | | 2023-11-14T22:13:21 | | | 2023-11-14T22:13:22 | | final | 2023-11-14T22:13:23 | +-------+---------------------+ drop table demo; Affected Rows: 0 drop table with_filename; Affected Rows: 0 drop table with_json; Affected Rows: 0 drop table with_path; Affected Rows: 0 drop table with_pattern; Affected Rows: 0 drop table demo_with_external_column; Affected Rows: 0 drop table demo_with_less_columns; Affected Rows: 0 drop table csv_null_prefix; Affected Rows: 0 drop table csv_null_prefix_import; Affected Rows: 0