|
| 1 | +--- |
| 2 | +title: 'Uploading files' |
| 3 | +slug: /cloud/migrate/upload-a-csv-file |
| 4 | +description: 'Learn how to upload files to Cloud' |
| 5 | +--- |
| 6 | + |
| 7 | +import Image from '@theme/IdealImage'; |
| 8 | +import csv_01 from '@site/static/images/cloud/migrate/csv_01.png'; |
| 9 | +import csv_02 from '@site/static/images/cloud/migrate/csv_02.png'; |
| 10 | +import csv_03 from '@site/static/images/cloud/migrate/csv_03.png'; |
| 11 | +import csv_04 from '@site/static/images/cloud/migrate/csv_04.png'; |
| 12 | +import csv_05 from '@site/static/images/cloud/migrate/csv_05.png'; |
| 13 | +import csv_06 from '@site/static/images/cloud/migrate/csv_06.png'; |
| 14 | +import csv_07 from '@site/static/images/cloud/migrate/csv_07.png'; |
| 15 | +import csv_08 from '@site/static/images/cloud/migrate/csv_08.png'; |
| 16 | +import csv_09 from '@site/static/images/cloud/migrate/csv_09.png'; |
| 17 | +import csv_10 from '@site/static/images/cloud/migrate/csv_10.png'; |
| 18 | + |
| 19 | +# Upload files to Cloud |
| 20 | + |
| 21 | +ClickHouse Cloud provides an easy way to import your files and supports the |
| 22 | +following formats: |
| 23 | + |
| 24 | +| Format | |
| 25 | +|---------------------------------| |
| 26 | +| `CSV` | |
| 27 | +| `CSVWithNamesAndTypes` | |
| 28 | +| `CSVWithNames` | |
| 29 | +| `JSONEachRow` | |
| 30 | +| `TabSeparated` | |
| 31 | +| `TabSeparatedWithNames` | |
| 32 | +| `TabSeparatedWithNamesAndTypes` | |
| 33 | + |
| 34 | +<VerticalStepper headerLevel="h2"> |
| 35 | + |
| 36 | +## Upload a file {#upload-file} |
| 37 | + |
| 38 | +From the Cloud homepage, select your service as shown below: |
| 39 | + |
| 40 | +<Image img={csv_01} alt="upload_file_02" /> |
| 41 | + |
| 42 | +If your service is idle you will need to wake it. |
| 43 | + |
| 44 | +Select `Data sources` in the left hand tab as shown below: |
| 45 | + |
| 46 | +<Image img={csv_02} alt="upload_file_03" /> |
| 47 | + |
| 48 | +Next select `Upload a file` on the right side of the data sources page: |
| 49 | + |
| 50 | +<Image img={csv_03} alt="upload_file_04" /> |
| 51 | + |
| 52 | +A file dialogue will pop up allowing you to select the file that you wish to |
| 53 | +use to insert data into a table on your Cloud service. |
| 54 | + |
| 55 | +<Image img={csv_04} alt="upload_file_05" /> |
| 56 | + |
| 57 | +## Configure table {#configure-table} |
| 58 | + |
| 59 | +Once the file has uploaded you will be able to configure the table where you want |
| 60 | +to insert the data to. A preview of the table with the first three rows is shown. |
| 61 | + |
| 62 | +<Image img={csv_08} alt="upload_file_08" /> |
| 63 | + |
| 64 | +You can now select a destination table. The options are: |
| 65 | + |
| 66 | +- a new table |
| 67 | +- an existing table |
| 68 | + |
| 69 | +<br/> |
| 70 | +You can specify which database you want to upload the data to, and in the case of |
| 71 | +a new table, the name of the table that will be created. You will also be able to select the sorting key: |
| 72 | + |
| 73 | +<Image img={csv_05} alt="upload_file_05" /> |
| 74 | + |
| 75 | +Columns read from the file are shown as `Source field`s and for each field, you |
| 76 | +can change: |
| 77 | +- the inferred type |
| 78 | +- the default value |
| 79 | +- whether to make the column [Nullable](/sql-reference/data-types/nullable) or not |
| 80 | + |
| 81 | +<Image img={csv_06} alt="upload_file_06" /> |
| 82 | + |
| 83 | +:::note Excluding fields |
| 84 | +You can also remove a field if you don't want to include it in the import |
| 85 | +::: |
| 86 | + |
| 87 | +You can specify the type of table engine that you want to use: |
| 88 | + |
| 89 | +- `MergeTree` |
| 90 | +- `ReplacingMergeTree` |
| 91 | +- `SummingMergeTree` |
| 92 | +- `Null` |
| 93 | +<br/> |
| 94 | +You can specify a partitioning key expression and primary |
| 95 | +key expression. |
| 96 | + |
| 97 | +<Image img={csv_07} alt="upload_file_07" /> |
| 98 | + |
| 99 | +Click `Import to ClickHouse` (shown above) to import the data. The data import will be queued as |
| 100 | +indicated by the `queued` status badge in the `Status` column as shown below. You can also click |
| 101 | +`Open as query` (shown above) to open the insert query in the SQL console. The query will insert |
| 102 | +the file which was uploaded to an S3 bucket using the `URL` table function. |
| 103 | + |
| 104 | +<Image img={csv_09} alt="upload_file_09" /> |
| 105 | + |
| 106 | +If the job fails you will see a `failed` status badge under the `Status` column of |
| 107 | +the `Data upload history` tab. You can click `View Details` for more information |
| 108 | +on why the upload failed. You may need to modify the table configuration or clean |
| 109 | +the data based on the error message for the failed insert. |
| 110 | + |
| 111 | +<Image img={csv_10} alt="upload_file_11" /> |
| 112 | + |
| 113 | +</VerticalStepper> |
0 commit comments