Copy Table

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:

ParametersDescriptionRequired
source_tableSource tableYes
database_name(source_table)Source databaseNo, defaults to "default" database
table_name(source_table)Source tableYes
remote_infoIf source table is in other clusters, remote cluster information is requiredYes
master_group(remote_info)Master group of remote clusterYes
username(remote_info)Username used to access remote clusterNo, defaults to anonymous login
password(remote_info)Password used to access remote clusterNo, defaults to anonymous login
dest_tableDestination table information, which should be created ahead of time if located in the same clusterYes
database_name(dest_table)Database where the destination table is locatedNo, defaults to "default" database
table_name(dest_table)Destination table nameYes
fieldsFields to be copiedNo, defaults to all fields
fields_projectionField projection. If source table and destination table have different field names, users can specify the mapping relation via field projectionNo, uses filed names of source table by default
exprFilter condition when scanning data from source tableNo, defaults to full table scan
op_typeWrites data into destination table using "insert" or "upsert"No, defaults to "insert"
wait_for_completionWhether to wait until the job is doneNo, defaults to true
timeoutOperation timeoutNo, defaults to 5 mins
Table 20 Copy Table (Restful API