-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support skip/limit options for pandas scan (#4662)
- Loading branch information
Showing
9 changed files
with
177 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#pragma once | ||
|
||
#include "common/case_insensitive_map.h" | ||
#include "common/types/value/value.h" | ||
|
||
namespace kuzu { | ||
|
||
struct PyScanConfig { | ||
uint64_t skipNum; | ||
uint64_t limitNum; | ||
bool ignoreErrors; | ||
explicit PyScanConfig(const common::case_insensitive_map_t<common::Value>& options, | ||
uint64_t numRows); | ||
}; | ||
|
||
} // namespace kuzu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#include "py_scan_config.h" | ||
|
||
#include "common/constants.h" | ||
#include "common/exception/binder.h" | ||
#include "function/cast/functions/numeric_limits.h" | ||
|
||
namespace kuzu { | ||
|
||
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( | ||
common::stringFormat("{} Option not recognized by pyArrow scanner.", i.first)); | ||
} | ||
} | ||
} | ||
|
||
} // namespace kuzu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters