-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathpy_scan_config.cpp
More file actions
40 lines (36 loc) · 1.66 KB
/
py_scan_config.cpp
File metadata and controls
40 lines (36 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "py_scan_config.h"
#include "common/constants.h"
#include "common/exception/binder.h"
#include "function/cast/functions/numeric_limits.h"
#include <format>
namespace lbug {
PyScanConfig::PyScanConfig(const common::case_insensitive_map_t<common::Value>& options,
uint64_t numRows) {
skipNum = 0;
limitNum = function::NumericLimits<uint64_t>::maximum();
ignoreErrors = common::CopyConstants::DEFAULT_IGNORE_ERRORS;
for (const auto& i : options) {
if (i.first == "SKIP") {
if (i.second.getDataType().getLogicalTypeID() != common::LogicalTypeID::INT64 ||
i.second.val.int64Val < 0) {
throw common::BinderException("SKIP Option must be a positive integer literal.");
}
skipNum = std::min(numRows, static_cast<uint64_t>(i.second.val.int64Val));
} else if (i.first == "LIMIT") {
if (i.second.getDataType().getLogicalTypeID() != common::LogicalTypeID::INT64 ||
i.second.val.int64Val < 0) {
throw common::BinderException("LIMIT Option must be a positive integer literal.");
}
limitNum = i.second.val.int64Val;
} else if (i.first == common::CopyConstants::IGNORE_ERRORS_OPTION_NAME) {
if (i.second.getDataType().getLogicalTypeID() != common::LogicalTypeID::BOOL) {
throw common::BinderException("IGNORE_ERRORS Option must be a boolean.");
}
ignoreErrors = i.second.val.booleanVal;
} else {
throw common::BinderException(
std::format("{} Option not recognized by pyArrow scanner.", i.first));
}
}
}
} // namespace lbug