You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@orc.apache.org by do...@apache.org on 2021/01/16 21:26:16 UTC
[orc] branch master updated: ORC-735: ConvertTool should not fail
at a single ORC file. (#628)
This is an automated email from the ASF dual-hosted git repository.
dongjoon pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/orc.git
The following commit(s) were added to refs/heads/master by this push:
new 34a79ce ORC-735: ConvertTool should not fail at a single ORC file. (#628)
34a79ce is described below
commit 34a79ce37b0eaba1531677f7bc65f5486cfd77a9
Author: William Hyun <62...@users.noreply.github.com>
AuthorDate: Sat Jan 16 13:26:05 2021 -0800
ORC-735: ConvertTool should not fail at a single ORC file. (#628)
### What changes were proposed in this pull request?
This PR aims to fix a bug in ConvertTool by using the provided schema in case of a single file.
### Why are the changes needed?
**BEFORE**
```
% java -jar tools/target/orc-tools-1.7.0-SNAPSHOT-uber.jar convert ../examples/TestOrcFile.test1.orc
Merging schema from ../examples/TestOrcFile.test1.orc
Exception in thread "main" java.lang.IllegalArgumentException: Unhandled type map<string,struct<int1:int,string1:string>>
at org.apache.orc.tools.json.JsonSchemaFinder.makeHiveType(JsonSchemaFinder.java:314)
at org.apache.orc.tools.json.JsonSchemaFinder.makeHiveType(JsonSchemaFinder.java:301)
at org.apache.orc.tools.json.JsonSchemaFinder.addSchema(JsonSchemaFinder.java:319)
at org.apache.orc.tools.convert.ConvertTool.buildSchema(ConvertTool.java:81)
at org.apache.orc.tools.convert.ConvertTool.<init>(ConvertTool.java:188)
at org.apache.orc.tools.convert.ConvertTool.main(ConvertTool.java:168)
at org.apache.orc.tools.Driver.main(Driver.java:108)
```
**AFTER**
```
% java -jar tools/target/orc-tools-1.7.0-SNAPSHOT-uber.jar convert ../examples/TestOrcFile.test1.orc
Merging schema from ../examples/TestOrcFile.test1.orc
Processing ../examples/TestOrcFile.test1.orc
```
### How was this patch tested?
Manually do the above procedure.
---
java/tools/src/java/org/apache/orc/tools/convert/ConvertTool.java | 3 +++
1 file changed, 3 insertions(+)
diff --git a/java/tools/src/java/org/apache/orc/tools/convert/ConvertTool.java b/java/tools/src/java/org/apache/orc/tools/convert/ConvertTool.java
index 2e6ba10..26589df 100644
--- a/java/tools/src/java/org/apache/orc/tools/convert/ConvertTool.java
+++ b/java/tools/src/java/org/apache/orc/tools/convert/ConvertTool.java
@@ -75,6 +75,9 @@ public class ConvertTool {
Reader reader = OrcFile.createReader(file.path,
OrcFile.readerOptions(conf)
.filesystem(file.filesystem));
+ if (files.size() == 1) {
+ return reader.getSchema();
+ }
schemaFinder.addSchema(reader.getSchema());
}
}