|
| 1 | +CREATE TABLE demo(host string, cpu double, memory double, ts TIMESTAMP time index); |
| 2 | + |
| 3 | +Affected Rows: 0 |
| 4 | + |
| 5 | +insert into |
| 6 | + demo(host, cpu, memory, ts) |
| 7 | +values |
| 8 | + ('host1', 66.6, 1024, 1655276557000), |
| 9 | + ('host2', 88.8, 333.3, 1655276558000), |
| 10 | + ('host3', 99.9, 444.4, 1722077263000); |
| 11 | + |
| 12 | +Affected Rows: 3 |
| 13 | + |
| 14 | +CREATE TABLE demo_2(host string, cpu double, memory double, ts TIMESTAMP time index); |
| 15 | + |
| 16 | +Affected Rows: 0 |
| 17 | + |
| 18 | +insert into |
| 19 | + demo_2(host, ts) |
| 20 | +values |
| 21 | + ('host4', 1755276557000), |
| 22 | + ('host5', 1755276558000), |
| 23 | + ('host6', 1822077263000); |
| 24 | + |
| 25 | +Affected Rows: 3 |
| 26 | + |
| 27 | +Copy demo TO '${SQLNESS_HOME}/demo/export/csv/demo.csv' with (format='csv'); |
| 28 | + |
| 29 | +Affected Rows: 3 |
| 30 | + |
| 31 | +Copy demo_2 TO '${SQLNESS_HOME}/demo/export/csv/demo_2.csv' with (format='csv'); |
| 32 | + |
| 33 | +Affected Rows: 3 |
| 34 | + |
| 35 | +CREATE TABLE check_header(host string, cpu double, memory double, ts TIMESTAMP time index); |
| 36 | + |
| 37 | +Affected Rows: 0 |
| 38 | + |
| 39 | +Copy check_header FROM '${SQLNESS_HOME}/demo/export/csv/' with (pattern = 'demo*', format='csv'); |
| 40 | + |
| 41 | +Affected Rows: 3 |
| 42 | + |
| 43 | +select * from check_header order by ts; |
| 44 | + |
| 45 | ++-------+------+--------+---------------------+ |
| 46 | +| host | cpu | memory | ts | |
| 47 | ++-------+------+--------+---------------------+ |
| 48 | +| host1 | 66.6 | 1024.0 | 2022-06-15T07:02:37 | |
| 49 | +| host2 | 88.8 | 333.3 | 2022-06-15T07:02:38 | |
| 50 | +| host3 | 99.9 | 444.4 | 2024-07-27T10:47:43 | |
| 51 | ++-------+------+--------+---------------------+ |
| 52 | + |
| 53 | +CREATE TABLE non_check_header(host string, cpu double, memory double, ts TIMESTAMP time index); |
| 54 | + |
| 55 | +Affected Rows: 0 |
| 56 | + |
| 57 | +Copy non_check_header FROM '${SQLNESS_HOME}/demo/export/csv/' with (pattern = 'demo*', format='csv', header='false'); |
| 58 | + |
| 59 | +Affected Rows: 6 |
| 60 | + |
| 61 | +select * from non_check_header order by ts; |
| 62 | + |
| 63 | ++-------+------+--------+---------------------+ |
| 64 | +| host | cpu | memory | ts | |
| 65 | ++-------+------+--------+---------------------+ |
| 66 | +| host1 | 66.6 | 1024.0 | 2022-06-15T07:02:37 | |
| 67 | +| host2 | 88.8 | 333.3 | 2022-06-15T07:02:38 | |
| 68 | +| host3 | 99.9 | 444.4 | 2024-07-27T10:47:43 | |
| 69 | +| host4 | | | 2025-08-15T16:49:17 | |
| 70 | +| host5 | | | 2025-08-15T16:49:18 | |
| 71 | +| host6 | | | 2027-09-27T20:34:23 | |
| 72 | ++-------+------+--------+---------------------+ |
| 73 | + |
| 74 | +CREATE TABLE non_continue_error(host string, cpu double, memory double, ts TIMESTAMP time index); |
| 75 | + |
| 76 | +Affected Rows: 0 |
| 77 | + |
| 78 | +Copy non_check_header FROM '${SQLNESS_HOME}/demo/export/csv/' with (pattern = 'demo*', format='csv', continue_on_error='false'); |
| 79 | + |
| 80 | +Error: 1004(InvalidArguments), Header from CSV file not match, expected table schema: Field { name: "host", data_type: Utf8, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }, Field { name: "cpu", data_type: Float64, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }, Field { name: "memory", data_type: Float64, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }, Field { name: "ts", data_type: Timestamp(Millisecond, None), nullable: false, dict_id: 0, dict_is_ordered: false, metadata: {"greptime:time_index": "true"} }, actual file schema: Field { name: "host", data_type: Utf8, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }, Field { name: "cpu", data_type: Null, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }, Field { name: "memory", data_type: Null, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }, Field { name: "ts", data_type: Timestamp(Second, None), nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} } |
| 81 | + |
| 82 | +insert into |
| 83 | + demo(host, cpu, ts) |
| 84 | +values |
| 85 | + ('host1', 100.6, 2055276557000); |
| 86 | + |
| 87 | +Affected Rows: 1 |
| 88 | + |
| 89 | +CREATE TABLE skip_bad_rows(host string, cpu double, memory double, ts TIMESTAMP time index); |
| 90 | + |
| 91 | +Affected Rows: 0 |
| 92 | + |
| 93 | +Copy skip_bad_rows FROM '${SQLNESS_HOME}/demo/export/csv/' with (pattern = 'demo*', format='csv', skip_bad_records='true'); |
| 94 | + |
| 95 | +Affected Rows: 3 |
| 96 | + |
| 97 | +select * from skip_bad_rows order by ts; |
| 98 | + |
| 99 | ++-------+------+--------+---------------------+ |
| 100 | +| host | cpu | memory | ts | |
| 101 | ++-------+------+--------+---------------------+ |
| 102 | +| host1 | 66.6 | 1024.0 | 2022-06-15T07:02:37 | |
| 103 | +| host2 | 88.8 | 333.3 | 2022-06-15T07:02:38 | |
| 104 | +| host3 | 99.9 | 444.4 | 2024-07-27T10:47:43 | |
| 105 | ++-------+------+--------+---------------------+ |
| 106 | + |
| 107 | +CREATE TABLE non_skip_bad_rows(host string, cpu double, memory double, ts TIMESTAMP time index); |
| 108 | + |
| 109 | +Affected Rows: 0 |
| 110 | + |
| 111 | +Copy non_skip_bad_rows FROM '${SQLNESS_HOME}/demo/export/csv/' with (pattern = 'demo*', format='csv', skip_bad_records='false'); |
| 112 | + |
| 113 | +Affected Rows: 3 |
| 114 | + |
| 115 | +select * from non_skip_bad_rows order by ts; |
| 116 | + |
| 117 | ++-------+------+--------+---------------------+ |
| 118 | +| host | cpu | memory | ts | |
| 119 | ++-------+------+--------+---------------------+ |
| 120 | +| host1 | 66.6 | 1024.0 | 2022-06-15T07:02:37 | |
| 121 | +| host2 | 88.8 | 333.3 | 2022-06-15T07:02:38 | |
| 122 | +| host3 | 99.9 | 444.4 | 2024-07-27T10:47:43 | |
| 123 | ++-------+------+--------+---------------------+ |
| 124 | + |
| 125 | +drop table demo; |
| 126 | + |
| 127 | +Affected Rows: 0 |
| 128 | + |
| 129 | +drop table demo_2; |
| 130 | + |
| 131 | +Affected Rows: 0 |
| 132 | + |
| 133 | +drop table check_header; |
| 134 | + |
| 135 | +Affected Rows: 0 |
| 136 | + |
| 137 | +drop table non_check_header; |
| 138 | + |
| 139 | +Affected Rows: 0 |
| 140 | + |
| 141 | +drop table non_continue_error; |
| 142 | + |
| 143 | +Affected Rows: 0 |
| 144 | + |
| 145 | +drop table skip_bad_rows; |
| 146 | + |
| 147 | +Affected Rows: 0 |
| 148 | + |
| 149 | +drop table non_skip_bad_rows; |
| 150 | + |
| 151 | +Affected Rows: 0 |
| 152 | + |
0 commit comments