Importing and Querying DWS Data
This section describes how to import, export, and query DWS data, including Importing Data to a Common Table, Importing/Exporting SQL Statements on the Panel, Viewing Data of a View, Viewing Data in a Common Table, Viewing Statistics About Databases, Schemas, and Tables, and Exporting Execution Results.
Importing Data to a Common Table
- Log in to the DWS console.
- In the navigation pane on the left, choose Data > SQL Editor.
- Click Data Source and right-click the name of a common table. Click Import Data to import data from a local Excel file or OBS bucket file to the common table.
- Local import: When uploading an Excel file, ensure it is under 30 MB. For CSV files, select separators to divide data in each row and indicate if there is a table header. If there is no header, input data in each row according to the chosen table fields. Figure 1 Importing data from a local Excel file to a common table
- obs import: Choose a file from the OBS bucket or directory. Supported file types include CSV and TEXT. Set the parameters of the foreign table to be created for importing data to the OBS bucket. Use the OBS foreign table to write the OBS bucket file to the selected common table.
Table 1 OBS import parameters Parameter
Description
Example Value
storage location
Select a file or directory from the OBS bucket as the data source.
-
file format
Select a file format from the drop-down list. Supported formats include CSV and TEXT.
CSV
file encoding
Select a file encoding mode from the drop-down list. UTF-8 is recommended.
UTF8
delimiter
Commas (,) are the default separators for CSV files, while tab characters are the default separators for TXT files.
,
quote (CSV format)
Quote character used to reference fields. This parameter is used only for CSV files. The value must be a single-byte character and cannot be the same as the value of Separator or Null value.
#
newline character (TEXT format)
When importing text data, you can specify the newline character style. The maximum length of the newline character is 10 bytes, and you can use multi-character newline characters. The supported newline characters include common ones like \r, \n, and \r\n, as well as other characters or strings like $ and #.
\r
Whether not to escape (TEXT format)
Whether to escape the backslash (\) and its following characters in the TEXT format
Yes
Null value
A string that represents a null value in a data file. This string will be processed as a NULL value during import.
$
Number of data format errors
Maximum number of data format errors allowed during import. The value -1 indicates that the number of errors is not limited.
-1
Does it contain a header (CSV format)
Whether the imported CSV file contains a header row that describes each column in the table. This parameter only applies to CSV files.
Yes
Whether to ignore missing fields
Enabling this function sets the last column of a row in a data source file to NULL if it is missing, without reporting an error message.
Yes
ignore extra data
Whether to ignore excessive columns when the number of columns in a source data file exceeds that defined in the foreign table
Yes
compatible illegal chars
Enabling this function allows for invalid characters during data import. They will be replaced with question marks (?).
Yes
Figure 2 Importing OBS bucket file data to a common table
- Local import: When uploading an Excel file, ensure it is under 30 MB. For CSV files, select separators to divide data in each row and indicate if there is a table header. If there is no header, input data in each row according to the chosen table fields.
- Confirm the information and click OK.
- In the upper right corner of the page, choose Common Functions > Import data list and check whether the import is successful.
Importing/Exporting SQL Statements on the Panel
- Log in to the DWS console.
- In the navigation pane on the left, choose Data > SQL Editor.
- On the Data Source page, connect to a data source and select a database and a schema.
- Click Import.
- In the displayed dialog box, click Add and select a SQL file. (Only a SQL file no larger than 10 MB can be imported.)
- Confirm the information and click OK. After the import is successful, the SQL statements are synchronized to the panel.
- (Optional) To export the SQL statements on the panel, click Export. The system will automatically export the SQL file to a local path.
Viewing Data of a View
- Log in to the DWS console.
- In the navigation pane on the left, choose Data > SQL Editor.
- Click Data Source, right-click the name of a view, and select View data. Figure 3 Viewing data of a view
Viewing Data in a Common Table
- Log in to the DWS console.
- In the navigation pane on the left, choose Data > SQL Editor.
- Click Data Source and right-click the data table name.
- Select View Data to add, filter, edit, and delete data in a common table.
Right-click the name of a partition and select View Data to add, filter, edit, or delete partition data.
Figure 4 Viewing data in a common table
Viewing Statistics About Databases, Schemas, and Tables
- Log in to the DWS console.
- In the navigation pane on the left, choose Data > SQL Editor.
- Click Data Source and double-click Databases. On the database list page that is displayed, you can search and check the detailed information about a database. Figure 5 Viewing database details
- Click a database name in the database list to go to the schema list and view the total number of tables, total table size, and index size. Figure 6 Viewing schema information
- Click a schema name in the schema list to go to the common table list. You can view the number of rows in the table, table size, and index size. Figure 7 Viewing common table information
Exporting Execution Results
- Log in to the DWS console.
- In the navigation pane on the left, choose Data > SQL Editor.
- Click Data Sources, log in to the data source whose data needs to be exported, and select the corresponding database and schema.
- Enter the query SQL statement in the editor box and click Running.
- Click Export under the query result.
- Local export: Export all SQL query results to an XLSX or CSV file. You can open the file on your local PC. A maximum of 20,000 records can be exported.
- Full export: Export all query SQL results to a specified path in an OBS bucket. By default, the results are exported to a CSV file. Figure 8 Full data export
- DDL structure export: Right-click a user schema name, click Dump SQL File, and select Yes for Whether to export data to export the DDL statements of metadata such as tables, views, functions, triggers, sequences, and synonyms, and table insertion statements to a specified path in an OBS bucket. By default, the statements are exported to an SQL file. Figure 9 Dumping the schema structure
- Confirm the information and click OK.
- Choose Common Functions > Export data list in the upper right corner of the page and view the exported task in the data export list.
- Click the path in the File address column to go to the OBS console to download the exported CSV or SQL file. Figure 10 Exporting the task list
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot