Components

Editor

Select a part of the script, and press Ctrl+E to execute the selected script. To execute the entire script in the editor, press Ctrl+A to select the full script and then execute.

Note: A string exceeding 65,536 bytes cannot be printed here. For example, executing the script below will cause the web interface to be disconnected. You need to refresh the web page to re-establish the connection.

a = array(STRING,10).append!(string(concat(take(`abcd中文123,100005))))
print a

Log Browser

When the execution result is a scalar, it will be displayed in the log browser. All other forms of results are displayed in the data browser.

In the following example, we first execute 2+3 in the editor, and the result is shown in the log browser. Then we execute 2 + [1, 2, 3], and the result is displayed in the data browser.

Note:

  • Currently messages in the log browser cannot be cleared.

  • The Log Browser can output up to 100,000 logs.

Data Browser

The data browser window in the notebook is very similar to that in DolphinDB GUI. However, they have the a few differences:

  • In GUI, you can right click on the data browser to conduct operations such as copy, sort, export, etc. In the notebook, you can only select part of a script with cursor. The output cannot be sorted, but you can open it in a new window by clicking on the button at bottom left corner.

  • In the notebook, you can set the decimal places.

Example: execute the following script in the editor window

sym = `C`MS`BAC`BK`WFC
price= 75.67 53.24 29.48 54.42 60.92
qty = 2200 1900 2100 3200 1800
t = table(sym, qty, price)
select *, price*qty as volume from t

The result will be displayed in the data browser.

You can click on the Setting button to set decimal places:

Database Explorer

The database explorer

  • provides the interface or creating tables and databases;

  • displays all databases and tables.

  1. Create databases using the interface

Click the button next to digit 1 to open the Create Database page:

Click “Clear” to clear the filled content or “Cancel” to cancel the creation. Click “Preview” to view the creating script:

Click “Cancel” to cancel the creation or “Go Back” to return to the Create Database page. Click “Execute” and the database is shown in the Database Explorer if the script is correct, otherwise an error message is returned.

  1. Create tables using the interface

Hover over the database name in the explorer, a button of creating table is displayed on the right:

Click the button to open the Create Table page:

Then click “Next” to view the creating script:

Click the copy icon in the upper right corner to copy all scripts.

Click “Go Back” to return to the Create Table page or “Execute” to create the table. If the table is created succussfully, the following message is shown:

Otherwise, the failure error is displayed:

  1. Create databases and tables using scripts

You can also create databases and tables by entering the script directly to the Editor. After successful creation, click the button in the upper left corner of Database Browser to view the 🔄 database/table.

Example: execute the following script in the editor window to create a DFS table pt

$ dbName="dfs://test_topic_partition"
$ if(existsDatabase(dbName)){
$     dropDatabase(dbName)
$ }
$ db=database(dbName,VALUE,2012.01.01..2012.01.10)
$ n=20
$ date=rand(2012.01.01..2012.01.10, n)
$ sym=rand("A"+string(1..30), n)
$ qty=rand(100, n)
$ t=table(date, sym, qty)
$ pt=db.createPartitionedTable(t, `pt, `date).append!(t)

As shown below, the Database Explorer displays all databases and tables. Click the ➕ icon before the variable to show the table schema, column names and types, and partitions. Click the ➖ icon to collapse the displayed information.

Click table pt and the table is displayed in the Data Browser:

Hover over the “columns” and an icon of “add column” is displayed to add a new column:

Hover over a column of the table and an icon of “set comment” is displayed to set comment to the column:

Click the schema of pt and the table schema is displayed in the Data Browser:

Click “partitions” and data of the parition is displayed in the Data Browser:

Variable Explorer

The variable explorer in the notebook is very similar to that in GUI. Their only difference is that we can right click on items in the variable explorer in Java IDE to conduct operations such as undefine, check schema, etc, while the notebook doesn’t offer these functionalities.

Click on the vector/matrix/in-memory table in the variable explorer to view the data. For a DFS table, you can check the data in the database explorer.