55#include " common/arrow/arrow_converter.h"
66#include " function/cast/functions/numeric_limits.h"
77#include " function/table/bind_input.h"
8+ #include " processor/execution_context.h"
89#include " py_connection.h"
910#include " pyarrow/pyarrow_bind.h"
1011#include " pybind11/pytypes.h"
@@ -18,6 +19,7 @@ namespace kuzu {
1819PyArrowScanConfig::PyArrowScanConfig (const case_insensitive_map_t <Value>& options) {
1920 skipNum = 0 ;
2021 limitNum = NumericLimits<uint64_t >::maximum ();
22+ ignoreErrors = CopyConstants::DEFAULT_IGNORE_ERRORS ;
2123 for (const auto & i : options) {
2224 if (i.first == " SKIP" ) {
2325 if (i.second .getDataType ().getLogicalTypeID () != LogicalTypeID::INT64 ||
@@ -31,8 +33,14 @@ PyArrowScanConfig::PyArrowScanConfig(const case_insensitive_map_t<Value>& option
3133 throw BinderException (" LIMIT Option must be a positive integer literal." );
3234 }
3335 limitNum = i.second .val .int64Val ;
36+ } else if (i.first == CopyConstants::IGNORE_ERRORS_OPTION_NAME ) {
37+ if (i.second .getDataType ().getLogicalTypeID () != LogicalTypeID::BOOL ) {
38+ throw BinderException (" IGNORE_ERRORS Option must be a boolean." );
39+ }
40+ ignoreErrors = i.second .val .booleanVal ;
3441 } else {
35- throw BinderException (stringFormat (" {} Option not recognized by pyArrow scanner." ));
42+ throw BinderException (
43+ stringFormat (" {} Option not recognized by pyArrow scanner." , i.first ));
3644 }
3745 }
3846}
@@ -82,7 +90,7 @@ static std::unique_ptr<TableFuncBindData> bindFunc(ClientContext*,
8290
8391 auto columns = input->binder ->createVariables (names, returnTypes);
8492 return std::make_unique<PyArrowTableScanFunctionData>(std::move (columns), std::move (schema),
85- arrowArrayBatches, numRows);
93+ arrowArrayBatches, numRows, config. ignoreErrors );
8694}
8795
8896ArrowArrayWrapper* PyArrowTableScanSharedState::getNextChunk () {
@@ -143,13 +151,18 @@ function_set PyArrowTableScanFunction::getFunctionSet() {
143151 return functionSet;
144152}
145153
154+ static void finalizeFunc (const processor::ExecutionContext* ctx, TableFuncSharedState*) {
155+ ctx->clientContext ->getWarningContextUnsafe ().defaultPopulateAllWarnings (ctx->queryID );
156+ }
157+
146158TableFunction PyArrowTableScanFunction::getFunction () {
147159 auto function = TableFunction (name, std::vector{LogicalTypeID::POINTER });
148160 function.tableFunc = tableFunc;
149161 function.bindFunc = bindFunc;
150162 function.initSharedStateFunc = initSharedState;
151163 function.initLocalStateFunc = initLocalState;
152164 function.progressFunc = progressFunc;
165+ function.finalizeFunc = finalizeFunc;
153166 return function;
154167}
155168
0 commit comments