Skip to content

Make use of SAS catalog files *.sas7bcat #5

@krlmlr

Description

@krlmlr

Thank you for the wonderful addition to the ecosystem!

I've tried to run the extension with the duckdb R package using the example files that come with the haven R package. All but three files could be read out of the box. Can we make the rest work too? Also, should the table function return an error instead of a zero-column table?

options(conflicts.policy = list(warn = FALSE))
library(duckdb)
#> Loading required package: DBI

curl::curl_download("https://github.com/tidyverse/haven/archive/refs/heads/main.zip", "haven.zip")
unzip("haven.zip")

con <- dbConnect(duckdb())

dbExecute(con, "INSTALL read_stat FROM community")
#> [1] 0
dbExecute(con, "LOAD read_stat")
#> [1] 0

# Works
dbGetQuery(con, "FROM read_stat('haven-main/tests/testthat/sas/datetime.sas7bdat')")
#>                  VAR1       VAR2       VAR3       VAR4       VAR5
#> 1 2015-02-02 14:42:12 2015-02-02 2015-02-02 2015-02-02 52932 secs
#> 2 2014-01-01 10:14:23 2014-01-01 2014-01-01 2014-01-01 36863 secs
#> 3 2015-01-15 06:15:22 2015-06-15 2015-06-15 2015-06-15 22522 secs
#> 4 1948-09-09 21:32:00 1948-09-16 1948-09-16 1948-09-16 77520 secs
dbGetQuery(con, "FROM read_stat('haven-main/tests/testthat/sas/hadley.sas7bdat')")
#>   id workshop gender q1 q2 q3 q4
#> 1  1        1      f  1  1  5  1
#> 2  2        2      f  2  1  4  1
#> 3  3        1      f  2  2  4  3
#> 4  4        2         3  1 NA  3
#> 5  5        1      m  4  5  2  4
#> 6  6        2      m  5  4  5  5
#> 7  7        1      m  5  3  4  4
#> 8  8        2      m  4  5  5  5
dbGetQuery(con, "FROM read_stat('haven-main/tests/testthat/sas/tagged-na.sas7bdat')")
#>    x
#> 1  1
#> 2  2
#> 3  3
#> 4  4
#> 5  5
#> 6 NA
#> 7 NA
#> 8 NA
dbGetQuery(con, "FROM read_stat('haven-main/tests/testthat/spss/datetime.sav')")
#>         date            date.posix       time
#> 1 2014-09-22 201416-09-22 00:00:00 43870 secs
#> 2 2014-09-23   2014-09-23 15:59:20 57560 secs
dbGetQuery(con, "FROM read_stat('haven-main/tests/testthat/spss/labelled-num-na.sav')")
#>   VAR00002
#> 1        1
#> 2       NA
dbGetQuery(con, "FROM read_stat('haven-main/tests/testthat/spss/labelled-num.sav')")
#>   VAR00002
#> 1        1
dbGetQuery(con, "FROM read_stat('haven-main/tests/testthat/spss/labelled-str.sav')")
#>   gender
#> 1      M
#> 2      F
dbGetQuery(con, "FROM read_stat('haven-main/tests/testthat/spss/umlauts.sav')")
#>   var1
#> 1    1
#> 2    2
#> 3    1
#> 4    3
dbGetQuery(con, "FROM read_stat('haven-main/tests/testthat/spss/variable-label.sav')")
#>   sex
#> 1   1
dbGetQuery(con, "FROM read_stat('haven-main/tests/testthat/stata/datetime-d.dta')")
#>    date
#> 1 20394
dbGetQuery(con, "FROM read_stat('haven-main/tests/testthat/stata/notes.dta')")
#>   id female treatment outcome
#> 1  1      0         0       2
#> 2  2      1         0       2
#> 3  3      1         1       4
#> 4  4      1         0       2
#> 5  5      1         0       1
dbGetQuery(con, "FROM read_stat('haven-main/tests/testthat/stata/tagged-na-double.dta')")
#>    x
#> 1  1
#> 2  2
#> 3  3
#> 4  4
#> 5  5
#> 6 NA
#> 7 NA
#> 8 NA
dbGetQuery(con, "FROM read_stat('haven-main/tests/testthat/stata/tagged-na-int.dta')")
#>    x
#> 1  1
#> 2  2
#> 3  3
#> 4  4
#> 5  5
#> 6 NA
#> 7 NA
#> 8 NA
dbGetQuery(con, "FROM read_stat('haven-main/tests/testthat/stata/types.dta')")
#>   vfloat vdouble vlong vint vbyte          vstr vdate           vdatetime
#> 1   3.14    3.14     2    2     2             2     0 2015-12-01 03:14:15
#> 2   7.00    7.00     7    7     7 Hello, World! 20423 1960-01-01 00:00:00

# Fails
dbGetQuery(con, "FROM read_stat('haven-main/tests/testthat/sas/formats.sas7bcat')")
#> Error in `dbSendQuery()` at DBI/R/dbGetQuery_DBIConnection_character.R:5:3:
#> ! rapi_prepare: Failed to prepare query FROM read_stat('haven-main/tests/testthat/sas/formats.sas7bcat')
#> Error: INTERNAL Error: Failed to bind "read_stat": Table function must return at least one column
#> 
#> Stack Trace:
#> 
#> 0        duckdb::Exception::Exception(duckdb::ExceptionType, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) + 64
#> 1        duckdb::InternalException::InternalException(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) + 20
#> 2        duckdb::InternalException::InternalException<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) + 92
#> 3        duckdb::Binder::BindTableFunctionInternal(duckdb::TableFunction&, duckdb::TableFunctionRef const&, duckdb::vector<duckdb::Value, true>, std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, duckdb::Value, duckdb::CaseInsensitiveStringHashFunction, duckdb::CaseInsensitiveStringEquality, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const, duckdb::Value>>>, duckdb::vector<duckdb::LogicalType, true>, duckdb::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, true>) + 2000
#> 4        duckdb::Binder::Bind(duckdb::TableFunctionRef&) + 2648
#> 5        duckdb::Binder::Bind(duckdb::TableRef&) + 328
#> 6        duckdb::Binder::BindNode(duckdb::SelectNode&) + 68
#> 7        duckdb::Binder::BindNode(duckdb::QueryNode&) + 136
#> 8        duckdb::Binder::Bind(duckdb::QueryNode&) + 180
#> 9        duckdb::Planner::CreatePlan(duckdb::SQLStatement&) + 148
#> 10       duckdb::ClientContext::CreatePreparedStatementInternal(duckdb::ClientContextLock&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, duckdb::unique_ptr<duckdb::SQLStatement, std::__1::default_delete<duckdb::SQLStatement>, true>, duckdb::optional_ptr<std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, duckdb::BoundParameterData, duckdb::CaseInsensitiveStringHashFunction, duckdb::CaseInsensitiveStringEquality, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const, duckdb::BoundParameterData>>>, true>) + 504
#> 11       duckdb::ClientContext::CreatePreparedStatement(duckdb::ClientContextLock&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, duckdb::unique_ptr<duckdb::SQLStatement, std::__1::default_delete<duckdb::SQLStatement>, true>, duckdb::optional_ptr<std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, duckdb::BoundParameterData, duckdb::CaseInsensitiveStringHashFunction, duckdb::CaseInsensitiveStringEquality, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const, duckdb::BoundParameterData>>>, true>, duckdb::PreparedStatementMode) + 1032
#> 12       std::__1::__function::__func<duckdb::ClientContext::PrepareInternal(duckdb::ClientContextLock&, duckdb::unique_ptr<duckdb::SQLStatement, std::__1::default_delete<duckdb::SQLStatement>, true>)::$_0, std::__1::allocator<duckdb::ClientContext::PrepareInternal(duckdb::ClientContextLock&, duckdb::unique_ptr<duckdb::SQLStatement, std::__1::default_delete<duckdb::SQLStatement>, true>)::$_0>, void ()>::operator()() + 60
#> 13       duckdb::ClientContext::RunFunctionInTransactionInternal(duckdb::ClientContextLock&, std::__1::function<void ()> const&, bool) + 108
#> 14       duckdb::ClientContext::PrepareInternal(duckdb::ClientContextLock&, duckdb::unique_ptr<duckdb::SQLStatement, std::__1::default_delete<duckdb::SQLStatement>, true>) + 216
#> 15       duckdb::ClientContext::Prepare(duckdb::unique_ptr<duckdb::SQLStatement, std::__1::default_delete<duckdb::SQLStatement>, true>) + 192
#> 16       duckdb::Connection::Prepare(duckdb::unique_ptr<duckdb::SQLStatement, std::__1::default_delete<duckdb::SQLStatement>, true>) + 52
#> 17       rapi_prepare(cpp11::external_pointer<duckdb::ConnWrapper, &duckdb::ConnDeleter(duckdb::ConnWrapper*)>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, cpp11::environment) + 1112
#> 18       _duckdb_rapi_prepare + 272
#> 19       R_doDotCall + 1588
#> 20       do_dotcall + 316
#> 21       Rf_eval + 1612
#> 22       do_begin + 396
#> 23       Rf_eval + 1012
#> 24       R_execClosure + 812
#> 25       applyClosure_core + 164
#> 26       Rf_eval + 1224
#> 27       forcePromise + 232
#> 28       Rf_eval + 660
#> 29       forcePromise + 232
#> 30       bcEval_loop + 19716
#> 31       bcEval + 684
#> 32       Rf_eval + 556
#> 33       R_execClosure + 812
#> 34       applyClosure_core + 164
#> 35       Rf_eval + 1224
#> 36       forcePromise + 232
#> 37       bcEval_loop + 19716
#> 38       bcEval + 684
#> 39       Rf_eval + 556
#> 40       R_execClosure + 812
#> 41       applyClosure_core + 164
#> 42       Rf_eval + 1224
#> 43       ffi_try_fetch + 780
#> 44       do_External + 300
#> 45       bcEval_loop + 40164
#> 46       bcEval + 684
#> 47       Rf_eval + 556
#> 48       R_execClosure + 812
#> 49       applyClosure_core + 164
#> 50       Rf_eval + 1224
#> 51       do_begin + 396
#> 52       Rf_eval + 1012
#> 53       R_execClosure + 812
#> 54       applyClosure_core + 164
#> 55       Rf_eval + 1224
#> 56       do_set + 360
#> 57       Rf_eval + 1012
#> 58       do_begin + 396
#> 59       Rf_eval + 1012
#> 60       R_execClosure + 812
#> 61       applyClosure_core + 164
#> 62       Rf_eval + 1224
#> 63       do_begin + 396
#> 64       Rf_eval + 1012
#> 65       R_execClosure + 812
#> 66       R_execMethod + 668
#> 67       R_dispatchGeneric + 2408
#> 68       do_standardGeneric + 440
#> 69       Rf_eval + 1692
#> 70       do_set + 360
#> 71       Rf_eval + 1012
#> 72       do_begin + 396
#> 73       Rf_eval + 1012
#> 74       R_execClosure + 812
#> 75       applyClosure_core + 164
#> 76       Rf_eval + 1224
#> 77       do_set + 360
#> 78       Rf_eval + 1012
#> 79       do_begin + 396
#> 80       Rf_eval + 1012
#> 81       R_execClosure + 812
#> 82       applyClosure_core + 164
#> 83       Rf_eval + 1224
#> 84       do_begin + 396
#> 85       Rf_eval + 1012
#> 86       R_execClosure + 812
#> 87       R_execMethod + 668
#> 88       R_dispatchGeneric + 2408
#> 89       do_standardGeneric + 440
#> 90       Rf_eval + 1692
#> 91       R_execClosure + 812
#> 92       applyClosure_core + 164
#> 93       Rf_eval + 1224
#> 94       do_eval + 1352
#> 95       bcEval_loop + 40164
#> 96       bcEval + 684
#> 97       Rf_eval + 556
#> 98       forcePromise + 232
#> 99       Rf_eval + 660
#> 100      do_withVisible + 64
#> 101      do_internal + 400
#> 102      bcEval_loop + 40724
#> 103      bcEval + 684
#> 104      Rf_eval + 556
#> 105      forcePromise + 232
#> 106      Rf_eval + 660
#> 107      forcePromise + 232
#> 108      bcEval_loop + 19716
#> 109      bcEval + 684
#> 110      Rf_eval + 556
#> 111      R_execClosure + 812
#> 112      applyClosure_core + 164
#> 113      Rf_eval + 1224
#> 114      do_eval + 1352
#> 115      bcEval_loop + 40164
#> 116      bcEval + 684
#> 117      Rf_eval + 556
#> 
#> This error signals an assertion failure within DuckDB. This usually occurs due to unexpected conditions or errors in the program's logic.
#> For more information, see https://duckdb.org/docs/dev/internal_errors
dbGetQuery(con, "FROM read_stat('haven-main/tests/testthat/sas/hadley.zip')")
#> Error in `dbSendQuery()` at DBI/R/dbGetQuery_DBIConnection_character.R:5:3:
#> ! rapi_prepare: Failed to prepare query FROM read_stat('haven-main/tests/testthat/sas/hadley.zip')
#> Error: INTERNAL Error: Failed to bind "read_stat": Table function must return at least one column
#> 
#> Stack Trace:
#> 
#> 0        duckdb::Exception::Exception(duckdb::ExceptionType, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) + 64
#> 1        duckdb::InternalException::InternalException(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) + 20
#> 2        duckdb::InternalException::InternalException<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) + 92
#> 3        duckdb::Binder::BindTableFunctionInternal(duckdb::TableFunction&, duckdb::TableFunctionRef const&, duckdb::vector<duckdb::Value, true>, std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, duckdb::Value, duckdb::CaseInsensitiveStringHashFunction, duckdb::CaseInsensitiveStringEquality, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const, duckdb::Value>>>, duckdb::vector<duckdb::LogicalType, true>, duckdb::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, true>) + 2000
#> 4        duckdb::Binder::Bind(duckdb::TableFunctionRef&) + 2648
#> 5        duckdb::Binder::Bind(duckdb::TableRef&) + 328
#> 6        duckdb::Binder::BindNode(duckdb::SelectNode&) + 68
#> 7        duckdb::Binder::BindNode(duckdb::QueryNode&) + 136
#> 8        duckdb::Binder::Bind(duckdb::QueryNode&) + 180
#> 9        duckdb::Planner::CreatePlan(duckdb::SQLStatement&) + 148
#> 10       duckdb::ClientContext::CreatePreparedStatementInternal(duckdb::ClientContextLock&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, duckdb::unique_ptr<duckdb::SQLStatement, std::__1::default_delete<duckdb::SQLStatement>, true>, duckdb::optional_ptr<std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, duckdb::BoundParameterData, duckdb::CaseInsensitiveStringHashFunction, duckdb::CaseInsensitiveStringEquality, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const, duckdb::BoundParameterData>>>, true>) + 504
#> 11       duckdb::ClientContext::CreatePreparedStatement(duckdb::ClientContextLock&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, duckdb::unique_ptr<duckdb::SQLStatement, std::__1::default_delete<duckdb::SQLStatement>, true>, duckdb::optional_ptr<std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, duckdb::BoundParameterData, duckdb::CaseInsensitiveStringHashFunction, duckdb::CaseInsensitiveStringEquality, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const, duckdb::BoundParameterData>>>, true>, duckdb::PreparedStatementMode) + 1032
#> 12       std::__1::__function::__func<duckdb::ClientContext::PrepareInternal(duckdb::ClientContextLock&, duckdb::unique_ptr<duckdb::SQLStatement, std::__1::default_delete<duckdb::SQLStatement>, true>)::$_0, std::__1::allocator<duckdb::ClientContext::PrepareInternal(duckdb::ClientContextLock&, duckdb::unique_ptr<duckdb::SQLStatement, std::__1::default_delete<duckdb::SQLStatement>, true>)::$_0>, void ()>::operator()() + 60
#> 13       duckdb::ClientContext::RunFunctionInTransactionInternal(duckdb::ClientContextLock&, std::__1::function<void ()> const&, bool) + 108
#> 14       duckdb::ClientContext::PrepareInternal(duckdb::ClientContextLock&, duckdb::unique_ptr<duckdb::SQLStatement, std::__1::default_delete<duckdb::SQLStatement>, true>) + 216
#> 15       duckdb::ClientContext::Prepare(duckdb::unique_ptr<duckdb::SQLStatement, std::__1::default_delete<duckdb::SQLStatement>, true>) + 192
#> 16       duckdb::Connection::Prepare(duckdb::unique_ptr<duckdb::SQLStatement, std::__1::default_delete<duckdb::SQLStatement>, true>) + 52
#> 17       rapi_prepare(cpp11::external_pointer<duckdb::ConnWrapper, &duckdb::ConnDeleter(duckdb::ConnWrapper*)>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, cpp11::environment) + 1112
#> 18       _duckdb_rapi_prepare + 272
#> 19       R_doDotCall + 1588
#> 20       do_dotcall + 316
#> 21       Rf_eval + 1612
#> 22       do_begin + 396
#> 23       Rf_eval + 1012
#> 24       R_execClosure + 812
#> 25       applyClosure_core + 164
#> 26       Rf_eval + 1224
#> 27       forcePromise + 232
#> 28       Rf_eval + 660
#> 29       forcePromise + 232
#> 30       bcEval_loop + 19716
#> 31       bcEval + 684
#> 32       Rf_eval + 556
#> 33       R_execClosure + 812
#> 34       applyClosure_core + 164
#> 35       Rf_eval + 1224
#> 36       forcePromise + 232
#> 37       bcEval_loop + 19716
#> 38       bcEval + 684
#> 39       Rf_eval + 556
#> 40       R_execClosure + 812
#> 41       applyClosure_core + 164
#> 42       Rf_eval + 1224
#> 43       ffi_try_fetch + 780
#> 44       do_External + 300
#> 45       bcEval_loop + 40164
#> 46       bcEval + 684
#> 47       Rf_eval + 556
#> 48       R_execClosure + 812
#> 49       applyClosure_core + 164
#> 50       Rf_eval + 1224
#> 51       do_begin + 396
#> 52       Rf_eval + 1012
#> 53       R_execClosure + 812
#> 54       applyClosure_core + 164
#> 55       Rf_eval + 1224
#> 56       do_set + 360
#> 57       Rf_eval + 1012
#> 58       do_begin + 396
#> 59       Rf_eval + 1012
#> 60       R_execClosure + 812
#> 61       applyClosure_core + 164
#> 62       Rf_eval + 1224
#> 63       do_begin + 396
#> 64       Rf_eval + 1012
#> 65       R_execClosure + 812
#> 66       R_execMethod + 668
#> 67       R_dispatchGeneric + 2408
#> 68       do_standardGeneric + 440
#> 69       Rf_eval + 1692
#> 70       do_set + 360
#> 71       Rf_eval + 1012
#> 72       do_begin + 396
#> 73       Rf_eval + 1012
#> 74       R_execClosure + 812
#> 75       applyClosure_core + 164
#> 76       Rf_eval + 1224
#> 77       do_set + 360
#> 78       Rf_eval + 1012
#> 79       do_begin + 396
#> 80       Rf_eval + 1012
#> 81       R_execClosure + 812
#> 82       applyClosure_core + 164
#> 83       Rf_eval + 1224
#> 84       do_begin + 396
#> 85       Rf_eval + 1012
#> 86       R_execClosure + 812
#> 87       R_execMethod + 668
#> 88       R_dispatchGeneric + 2408
#> 89       do_standardGeneric + 440
#> 90       Rf_eval + 1692
#> 91       R_execClosure + 812
#> 92       applyClosure_core + 164
#> 93       Rf_eval + 1224
#> 94       do_eval + 1352
#> 95       bcEval_loop + 40164
#> 96       bcEval + 684
#> 97       Rf_eval + 556
#> 98       forcePromise + 232
#> 99       Rf_eval + 660
#> 100      do_withVisible + 64
#> 101      do_internal + 400
#> 102      bcEval_loop + 40724
#> 103      bcEval + 684
#> 104      Rf_eval + 556
#> 105      forcePromise + 232
#> 106      Rf_eval + 660
#> 107      forcePromise + 232
#> 108      bcEval_loop + 19716
#> 109      bcEval + 684
#> 110      Rf_eval + 556
#> 111      R_execClosure + 812
#> 112      applyClosure_core + 164
#> 113      Rf_eval + 1224
#> 114      do_eval + 1352
#> 115      bcEval_loop + 40164
#> 116      bcEval + 684
#> 117      Rf_eval + 556
#> 
#> This error signals an assertion failure within DuckDB. This usually occurs due to unexpected conditions or errors in the program's logic.
#> For more information, see https://duckdb.org/docs/dev/internal_errors
dbGetQuery(con, "FROM read_stat('haven-main/tests/testthat/sas/tagged-na.sas7bcat')")
#> Error in `dbSendQuery()` at DBI/R/dbGetQuery_DBIConnection_character.R:5:3:
#> ! rapi_prepare: Failed to prepare query FROM read_stat('haven-main/tests/testthat/sas/tagged-na.sas7bcat')
#> Error: INTERNAL Error: Failed to bind "read_stat": Table function must return at least one column
#> 
#> Stack Trace:
#> 
#> 0        duckdb::Exception::Exception(duckdb::ExceptionType, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) + 64
#> 1        duckdb::InternalException::InternalException(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) + 20
#> 2        duckdb::InternalException::InternalException<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) + 92
#> 3        duckdb::Binder::BindTableFunctionInternal(duckdb::TableFunction&, duckdb::TableFunctionRef const&, duckdb::vector<duckdb::Value, true>, std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, duckdb::Value, duckdb::CaseInsensitiveStringHashFunction, duckdb::CaseInsensitiveStringEquality, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const, duckdb::Value>>>, duckdb::vector<duckdb::LogicalType, true>, duckdb::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, true>) + 2000
#> 4        duckdb::Binder::Bind(duckdb::TableFunctionRef&) + 2648
#> 5        duckdb::Binder::Bind(duckdb::TableRef&) + 328
#> 6        duckdb::Binder::BindNode(duckdb::SelectNode&) + 68
#> 7        duckdb::Binder::BindNode(duckdb::QueryNode&) + 136
#> 8        duckdb::Binder::Bind(duckdb::QueryNode&) + 180
#> 9        duckdb::Planner::CreatePlan(duckdb::SQLStatement&) + 148
#> 10       duckdb::ClientContext::CreatePreparedStatementInternal(duckdb::ClientContextLock&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, duckdb::unique_ptr<duckdb::SQLStatement, std::__1::default_delete<duckdb::SQLStatement>, true>, duckdb::optional_ptr<std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, duckdb::BoundParameterData, duckdb::CaseInsensitiveStringHashFunction, duckdb::CaseInsensitiveStringEquality, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const, duckdb::BoundParameterData>>>, true>) + 504
#> 11       duckdb::ClientContext::CreatePreparedStatement(duckdb::ClientContextLock&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, duckdb::unique_ptr<duckdb::SQLStatement, std::__1::default_delete<duckdb::SQLStatement>, true>, duckdb::optional_ptr<std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, duckdb::BoundParameterData, duckdb::CaseInsensitiveStringHashFunction, duckdb::CaseInsensitiveStringEquality, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const, duckdb::BoundParameterData>>>, true>, duckdb::PreparedStatementMode) + 1032
#> 12       std::__1::__function::__func<duckdb::ClientContext::PrepareInternal(duckdb::ClientContextLock&, duckdb::unique_ptr<duckdb::SQLStatement, std::__1::default_delete<duckdb::SQLStatement>, true>)::$_0, std::__1::allocator<duckdb::ClientContext::PrepareInternal(duckdb::ClientContextLock&, duckdb::unique_ptr<duckdb::SQLStatement, std::__1::default_delete<duckdb::SQLStatement>, true>)::$_0>, void ()>::operator()() + 60
#> 13       duckdb::ClientContext::RunFunctionInTransactionInternal(duckdb::ClientContextLock&, std::__1::function<void ()> const&, bool) + 108
#> 14       duckdb::ClientContext::PrepareInternal(duckdb::ClientContextLock&, duckdb::unique_ptr<duckdb::SQLStatement, std::__1::default_delete<duckdb::SQLStatement>, true>) + 216
#> 15       duckdb::ClientContext::Prepare(duckdb::unique_ptr<duckdb::SQLStatement, std::__1::default_delete<duckdb::SQLStatement>, true>) + 192
#> 16       duckdb::Connection::Prepare(duckdb::unique_ptr<duckdb::SQLStatement, std::__1::default_delete<duckdb::SQLStatement>, true>) + 52
#> 17       rapi_prepare(cpp11::external_pointer<duckdb::ConnWrapper, &duckdb::ConnDeleter(duckdb::ConnWrapper*)>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, cpp11::environment) + 1112
#> 18       _duckdb_rapi_prepare + 272
#> 19       R_doDotCall + 1588
#> 20       do_dotcall + 316
#> 21       Rf_eval + 1612
#> 22       do_begin + 396
#> 23       Rf_eval + 1012
#> 24       R_execClosure + 812
#> 25       applyClosure_core + 164
#> 26       Rf_eval + 1224
#> 27       forcePromise + 232
#> 28       Rf_eval + 660
#> 29       forcePromise + 232
#> 30       bcEval_loop + 19716
#> 31       bcEval + 684
#> 32       Rf_eval + 556
#> 33       R_execClosure + 812
#> 34       applyClosure_core + 164
#> 35       Rf_eval + 1224
#> 36       forcePromise + 232
#> 37       bcEval_loop + 19716
#> 38       bcEval + 684
#> 39       Rf_eval + 556
#> 40       R_execClosure + 812
#> 41       applyClosure_core + 164
#> 42       Rf_eval + 1224
#> 43       ffi_try_fetch + 780
#> 44       do_External + 300
#> 45       bcEval_loop + 40164
#> 46       bcEval + 684
#> 47       Rf_eval + 556
#> 48       R_execClosure + 812
#> 49       applyClosure_core + 164
#> 50       Rf_eval + 1224
#> 51       do_begin + 396
#> 52       Rf_eval + 1012
#> 53       R_execClosure + 812
#> 54       applyClosure_core + 164
#> 55       Rf_eval + 1224
#> 56       do_set + 360
#> 57       Rf_eval + 1012
#> 58       do_begin + 396
#> 59       Rf_eval + 1012
#> 60       R_execClosure + 812
#> 61       applyClosure_core + 164
#> 62       Rf_eval + 1224
#> 63       do_begin + 396
#> 64       Rf_eval + 1012
#> 65       R_execClosure + 812
#> 66       R_execMethod + 668
#> 67       R_dispatchGeneric + 2408
#> 68       do_standardGeneric + 440
#> 69       Rf_eval + 1692
#> 70       do_set + 360
#> 71       Rf_eval + 1012
#> 72       do_begin + 396
#> 73       Rf_eval + 1012
#> 74       R_execClosure + 812
#> 75       applyClosure_core + 164
#> 76       Rf_eval + 1224
#> 77       do_set + 360
#> 78       Rf_eval + 1012
#> 79       do_begin + 396
#> 80       Rf_eval + 1012
#> 81       R_execClosure + 812
#> 82       applyClosure_core + 164
#> 83       Rf_eval + 1224
#> 84       do_begin + 396
#> 85       Rf_eval + 1012
#> 86       R_execClosure + 812
#> 87       R_execMethod + 668
#> 88       R_dispatchGeneric + 2408
#> 89       do_standardGeneric + 440
#> 90       Rf_eval + 1692
#> 91       R_execClosure + 812
#> 92       applyClosure_core + 164
#> 93       Rf_eval + 1224
#> 94       do_eval + 1352
#> 95       bcEval_loop + 40164
#> 96       bcEval + 684
#> 97       Rf_eval + 556
#> 98       forcePromise + 232
#> 99       Rf_eval + 660
#> 100      do_withVisible + 64
#> 101      do_internal + 400
#> 102      bcEval_loop + 40724
#> 103      bcEval + 684
#> 104      Rf_eval + 556
#> 105      forcePromise + 232
#> 106      Rf_eval + 660
#> 107      forcePromise + 232
#> 108      bcEval_loop + 19716
#> 109      bcEval + 684
#> 110      Rf_eval + 556
#> 111      R_execClosure + 812
#> 112      applyClosure_core + 164
#> 113      Rf_eval + 1224
#> 114      do_eval + 1352
#> 115      bcEval_loop + 40164
#> 116      bcEval + 684
#> 117      Rf_eval + 556
#> 
#> This error signals an assertion failure within DuckDB. This usually occurs due to unexpected conditions or errors in the program's logic.
#> For more information, see https://duckdb.org/docs/dev/internal_errors

Created on 2025-04-28 with reprex v2.1.1

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