| 127 | } |
| 128 | |
| 129 | void CreateTable(const string &table_name, ArrowArrayStream &input_data, string schema = "", bool temporary = false, |
| 130 | string catalog = "") { |
| 131 | REQUIRE(input_data.release); |
| 132 | AdbcStatement adbc_statement; |
| 133 | // Use separate connection for ingest to avoid streaming conflicts. |
| 134 | // Exception: temporary tables are connection-specific, so we must use the main connection |
| 135 | // for them to be visible to Query() calls on the same connection. |
| 136 | auto &conn = temporary ? adbc_connection : adbc_connection_ingest; |
| 137 | REQUIRE(SUCCESS(AdbcStatementNew(&conn, &adbc_statement, &adbc_error))); |
| 138 | if (!catalog.empty()) { |
| 139 | REQUIRE(SUCCESS(AdbcStatementSetOption(&adbc_statement, ADBC_INGEST_OPTION_TARGET_CATALOG, catalog.c_str(), |
| 140 | &adbc_error))); |
| 141 | } |
| 142 | if (!schema.empty()) { |
| 143 | REQUIRE(SUCCESS(AdbcStatementSetOption(&adbc_statement, ADBC_INGEST_OPTION_TARGET_DB_SCHEMA, schema.c_str(), |
| 144 | &adbc_error))); |
| 145 | } |
| 146 | if (temporary) { |
| 147 | REQUIRE(SUCCESS(AdbcStatementSetOption(&adbc_statement, ADBC_INGEST_OPTION_TEMPORARY, |
| 148 | ADBC_OPTION_VALUE_ENABLED, &adbc_error))); |
| 149 | } |
| 150 | REQUIRE(SUCCESS( |
| 151 | AdbcStatementSetOption(&adbc_statement, ADBC_INGEST_OPTION_TARGET_TABLE, table_name.c_str(), &adbc_error))); |
| 152 | |
| 153 | REQUIRE(SUCCESS(AdbcStatementBindStream(&adbc_statement, &input_data, &adbc_error))); |
| 154 | REQUIRE(SUCCESS(AdbcStatementExecuteQuery(&adbc_statement, nullptr, nullptr, &adbc_error))); |
| 155 | // Release the statement |
| 156 | REQUIRE(SUCCESS(AdbcStatementRelease(&adbc_statement, &adbc_error))); |
| 157 | if (input_data.release) { |
| 158 | input_data.release(&input_data); |
| 159 | } |
| 160 | input_data.release = nullptr; |
| 161 | } |
| 162 | |
| 163 | AdbcError adbc_error = {}; |
| 164 | AdbcDatabase adbc_database; |
no test coverage detected