Upload$insert_rows
Upload$insert_rows(rows, update_schema=FALSE) → list<insertRows response>
Parameters:
Returns:
Examples
library(redivis)
dataset <- redivis$user("user_name")$dataset("dataset_name", version="next")
table <- dataset$table("table_name")
# schema is optional if update_schema is set to True on the insert_rows request
schema <- list(
list(name="var1", type="string"),
list(name="var2", type="integer"),
list(name="var3", type="dateTime"),
)
# Construct a data.frame to send (or alternatively, a stringified json array of objects)
var1 <- c("hello", "world")
var2 <- c(1,2)
var3 <- c(NULL, "2020-01-01T00:00:00.123")
rows <- data.frame(var1, var2, var3)
# Reference each upload with its name, which must be unique amongst other uploads
# for the current version of this table.
upload <- table$upload(name="some_streamed_data")
# Only call create if the upload doesn't already exist
upload$create(
type="stream",
# schema is optional if update_schema is set to True on insert_rows
schema=schema,
# If True, will only create the upload if an upload with this name doesn't already exist
# Otherwise, a counter will be added to the name to preserve name uniqueness
if_not_exists=FALSE,
# If skip_bad_records is True, ignore records that are incompatible with the existing schema.
# This has no effect when update_schema is set to True on the insert_rows request.
skip_bad_records=FALSE # Optional, default is False
)
insert_response <- upload$insert_rows(
rows,
# If update_schema is set to True, variables can be added by subsequent streams,
# and variable types will be relaxed if new values are incompatible with the previous type.
# If False, an error will be thrown if a row would cause a schema update,
# unless skip_bad_records is set to True on the upload (in which case they'll be ignored)
update_schema=FALSE
)
# See REST API / uploads / insertRows
print(insert_response)Was this helpful?

