Hippo supports copying data in the same cluster or across clusters. The following example assumes that there is a table called book1, which has the same schema as table book, in this cluster.
curl -u shiva:shiva -XPOST 'localhost:8902/hippo/v1/_copy_by_query?pretty' -H 'Content-Type: application/json' -d'{
"source_table" : {
"database_name" : "default",
"table_name" : "book",
"remote_info" : {
"master_group" : "localhost1:8640, localhost2:8640, localhost3:8640", (It is recommended that users can list the IP and port info of at least one active master or the whole master group here)
"username" : "shiva",
"password" : "shiva"
}
},
"dest_table" : {
"database_name" : "default",
"table_name" : "book1"
},
"fields" : ["book_id", "word_count", "book_intro"],
"fields_projection": [
{
"book_id" : "book_id1"
},
{
"word_count" : "word_count1"
},
{
"book_intro" : "book_intro1"
}
],
"expr" : "word_count >= 11000",
"op_type" : "insert",
"wait_for_completion" : true,
"timeout" : "2m"
}';
Result:
{
"job_id" : "519aa728acd94c678a6ba600a62da877",
"job_status" : "SHIVA_JOB_SUCCESS",
"inserted_number" : 90,
"failed_number" : 0,
"task_results" : [
{
"id" : "6f776825ddd449d9b37723bc6aa2abbc",
"status" : "TASK_SUCCESS",
"server" : "172.29.203.203:27861",
"inserted_number" : 90,
"failed_number" : 0,
"execute_time" : 0.032
}
]
}
Parameter description:
Parameters | Description | Required |
---|---|---|
source_table | Source table | Yes |
database_name(source_table) | Source database | No, defaults to "default" database |
table_name(source_table) | Source table | Yes |
remote_info | If source table is in other clusters, remote cluster information is required | Yes |
master_group(remote_info) | Master group of remote cluster | Yes |
username(remote_info) | Username used to access remote cluster | No, defaults to anonymous login |
password(remote_info) | Password used to access remote cluster | No, defaults to anonymous login |
dest_table | Destination table information, which should be created ahead of time if located in the same cluster | Yes |
database_name(dest_table) | Database where the destination table is located | No, defaults to "default" database |
table_name(dest_table) | Destination table name | Yes |
fields | Fields to be copied | No, defaults to all fields |
fields_projection | Field projection. If source table and destination table have different field names, users can specify the mapping relation via field projection | No, uses filed names of source table by default |
expr | Filter condition when scanning data from source table | No, defaults to full table scan |
op_type | Writes data into destination table using "insert" or "upsert" | No, defaults to "insert" |
wait_for_completion | Whether to wait until the job is done | No, defaults to true |
timeout | Operation timeout | No, defaults to 5 mins |