[
https://issues.apache.org/jira/browse/DRILL-3964?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16492149#comment-16492149
]
ASF GitHub Bot commented on DRILL-3964:
---------------------------------------
Ben-Zvi closed pull request #1290: DRILL-3964 : Fix NPE in WriterRecordBatch
when 0 rows
URL: https://github.com/apache/drill/pull/1290
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/WriterRecordBatch.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/WriterRecordBatch.java
index b58cb55552..65d0c54d1c 100644
---
a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/WriterRecordBatch.java
+++
b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/WriterRecordBatch.java
@@ -95,8 +95,14 @@ public IterOutcome innerNext() {
return upstream;
case NOT_YET:
- case NONE:
break;
+ case NONE:
+ if (schema != null) {
+ // Schema is for the output batch schema which is setup in
setupNewSchema(). Since the output
+ // schema is fixed ((Fragment(VARCHAR), Number of records
written (BIGINT)) we should set it
+ // up even with 0 records for it to be reported back to the
client.
+ break;
+ }
case OK_NEW_SCHEMA:
setupNewSchema();
diff --git
a/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetRecordWriter.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetRecordWriter.java
index 114bae4981..0e40c9e360 100644
---
a/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetRecordWriter.java
+++
b/exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/ParquetRecordWriter.java
@@ -230,7 +230,8 @@ private void newSchema() throws IOException {
// Its value is likely below Integer.MAX_VALUE (2GB), although
rowGroupSize is a long type.
// Therefore this size is cast to int, since allocating byte array in
under layer needs to
// limit the array size in an int scope.
- int initialBlockBufferSize = max(MINIMUM_BUFFER_SIZE, blockSize /
this.schema.getColumns().size() / 5);
+ int initialBlockBufferSize = this.schema.getColumns().size() > 0 ?
+ max(MINIMUM_BUFFER_SIZE, blockSize / this.schema.getColumns().size() /
5) : MINIMUM_BUFFER_SIZE;
// We don't want this number to be too small either. Ideally, slightly
bigger than the page size,
// but not bigger than the block buffer
int initialPageBufferSize = max(MINIMUM_BUFFER_SIZE, min(pageSize +
pageSize / 10, initialBlockBufferSize));
diff --git
a/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestCTAS.java
b/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestCTAS.java
index 2315a0321a..2e7c052fce 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestCTAS.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestCTAS.java
@@ -315,6 +315,16 @@ public void
testCreateTableIfNotExistsWhenTableWithSameNameDoesNotExist() throws
}
}
+ @Test
+ public void testCTASWithEmptyJson() throws Exception {
+ final String newTblName = "tbl4444";
+ try {
+ test(String.format("CREATE TABLE %s.%s AS SELECT * FROM
cp.`project/pushdown/empty.json`", DFS_TMP_SCHEMA, newTblName));
+ } finally {
+ test("DROP TABLE IF EXISTS %s.%s", DFS_TMP_SCHEMA, newTblName);
+ }
+ }
+
private static void ctasErrorTestHelper(final String ctasSql, final String
expErrorMsg) throws Exception {
final String createTableSql = String.format(ctasSql, "testTableName");
errorMsgTestHelper(createTableSql, expErrorMsg);
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> CTAS fails with NPE when source JSON file is empty
> --------------------------------------------------
>
> Key: DRILL-3964
> URL: https://issues.apache.org/jira/browse/DRILL-3964
> Project: Apache Drill
> Issue Type: Bug
> Components: Storage - Parquet
> Affects Versions: 1.2.0
> Reporter: Abhishek Girish
> Assignee: Gautam Kumar Parai
> Priority: Major
> Labels: ready-to-commit
>
> {code:sql}
> CREATE TABLE `complex.json` AS
> SELECT id,
> gbyi,
> gbyt,
> fl,
> nul,
> bool,
> str,
> sia,
> sfa,
> soa,
> ooa,
> oooi,
> ooof,
> ooos,
> oooa
> FROM dfs.`/drill/testdata/complex/json/complex.json`;
> Error: SYSTEM ERROR: NullPointerException
> Fragment 0:0
> [Error Id: 97679667-412a-475f-aebf-e935405c7330 on drill-democ1:31010]
> (state=,code=0)
> {code}
> {code:sql}
> > select * from dfs.`/drill/testdata/complex/json/complex.json` limit 1;
> +--+
> | |
> +--+
> +--+
> No rows selected (0.295 seconds)
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)