Skip to content

Error: NOT NULL constraint failed: datatable.value - Storing large (~1.1GB) dataframe in SQLite cache #120

@strazto

Description

@strazto

Originally posted here: ropensci/drake#1201

Overview

Within my drake workflow, when trying to store a particular dataframe, I keep getting the same error:

Error: NOT NULL constraint failed: datatable.value

This always occurs at the stage of attempting to store my dataframe

With some digging, I am able to find the name "datatable" wrt my cache:

cache$driver$tbl_data
#> [1] "datatable"

After reviewing source for driver_dbi, I notice where this NOT NULL constraint is set.
I also notice the definitions for set_object.

I wonder if anyone has any idea how this datatable.value might be taken as NULL?

Lines

NOT NULL constraint set here:

storr/R/driver_dbi.R

Lines 171 to 173 in 0c64f1e

sql <- c(sprintf("CREATE TABLE %s", dquote(tbl_data)),
"(hash TEXT PRIMARY KEY NOT NULL,",
sprintf("value %s NOT NULL)", data_type))

Defining set_object SQL Call:

storr/R/driver_dbi.R

Lines 514 to 515 in 0c64f1e

set_object = j("INSERT OR REPLACE INTO", tbl_data,
"(hash, value) VALUES (?, ?)"),

Defining set_object method for driver_dbi:

storr/R/driver_dbi.R

Lines 305 to 312 in 0c64f1e

set_object = function(hash, value) {
## TODO: Could tidy up the serialization inteface (I'm sure I
## have helpers for that somewhere). Though OTOH if we accept
## binary we can skip the serialisation here anyway with
## appropriate setting of traits.
dat <- list(hash, if (self$binary) list(value) else value)
DBI::dbExecute(self$con, self$sql$set_object, dat)
},

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions