Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Truncate string with size > 4096 for CSV copier #819

Merged
merged 1 commit into from
Oct 11, 2022

Conversation

mewim
Copy link
Collaborator

@mewim mewim commented Oct 10, 2022

This PR truncates the string with length > 4096 and shows a warning in the log for CSV copier (instead of failing with exception) as requested in #504.

@mewim mewim force-pushed the truncate-oversized-string-for-csv-copy branch 2 times, most recently from 9af4e9f to b529067 Compare October 10, 2022 02:09
@@ -2,6 +2,8 @@

#include <fstream>

#include "spdlog/spdlog.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forward declare spglod because it's a very big header. See buffer_manager.h of how to do it.

@@ -54,6 +56,9 @@ class CSVReader {

~CSVReader();

// Pass the optional logger for getting warning messages.
inline void setLogger(shared_ptr<spdlog::logger> logger) { this->logger = logger; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can have CSVReader has its own logger. So you can generate one in the constructor instead of setting it.

@@ -182,7 +182,11 @@ char* CSVReader::getString() {
setNextTokenIsProcessed();
auto strVal = line + linePtrStart;
if (strlen(strVal) > DEFAULT_PAGE_SIZE) {
throw CSVReaderException(StringUtils::getLongStringErrorMessage(strVal, DEFAULT_PAGE_SIZE));
if (this->logger != nullptr) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this if statement if CSVReader always has a logger

@mewim mewim force-pushed the truncate-oversized-string-for-csv-copy branch from b529067 to e3fb699 Compare October 11, 2022 00:35
@mewim mewim merged commit 68b18cb into master Oct 11, 2022
@mewim mewim deleted the truncate-oversized-string-for-csv-copy branch October 11, 2022 00:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants