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

[Enhancement] files() csv.trim_space error report #44740

Merged
merged 3 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
tablefunction: csv.trim_space error report
Signed-off-by: ricky <[email protected]>
  • Loading branch information
rickif committed May 28, 2024
commit f9b589a638d6fd3a32a6afd2079924d5d6dbc97e
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,14 @@ private void parseProperties() throws DdlException {
}

if (properties.containsKey(PROPERTY_CSV_TRIM_SPACE)) {
csvTrimSpace = Boolean.parseBoolean(properties.get(PROPERTY_CSV_TRIM_SPACE));
String property = properties.get(PROPERTY_CSV_TRIM_SPACE);
if (property.equalsIgnoreCase("true")) {
csvTrimSpace = true;
} else if (property.equalsIgnoreCase("false")) {
csvTrimSpace = false;
} else {
throw new DdlException("illegal value of csv.skip_header: " + property + ", only true/false allowed");
rickif marked this conversation as resolved.
Show resolved Hide resolved
rickif marked this conversation as resolved.
Show resolved Hide resolved
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,24 @@ public void testIllegalDelimiter() throws DdlException {
() -> new TableFunctionTable(properties));
}
}

@Test
public void testIllegalCSVTrimSpace() throws DdlException {
new MockUp<HdfsUtil>() {
@Mock
public void parseFile(String path, BrokerDesc brokerDesc, List<TBrokerFileStatus> fileStatuses) throws UserException {
}
};

Map<String, String> properties = newProperties();
properties.put("csv.trim_space", "FALSE");

ExceptionChecker.expectThrowsNoException(() -> new TableFunctionTable(properties));

properties.put("csv.trim_space", "FALS");

ExceptionChecker.expectThrowsWithMsg(DdlException.class,
"illegal value of csv.skip_header: FALS, only true/false allowed",
rickif marked this conversation as resolved.
Show resolved Hide resolved
rickif marked this conversation as resolved.
Show resolved Hide resolved
() -> new TableFunctionTable(properties));
}
}
Loading