Allow empty row in parquet file
- Dominant language
- Java
- Stars
- 3.1k
- Forks
- 1.6k
- Avg merge
- 3d 12h
- Merged PRs (30d)
- 33
Description
PARQUET-1851 starts abandon to write parquet files with schema (meta information), but with 0 rows, aka empty files.
In result it prevent to store empty tables in DRILL by using parquet files, for example:
```java
CREATE TABLE dfs.tmp.%s AS SELECT * FROM cp.`employee.json` WHERE 1=0
```
```java
CREATE TABLE dfs.tmp.%s AS select * from dfs.`parquet/alltypes_required.parquet` where `col_int` = 0
```
```java
create table dfs.tmp.%s as select * from dfs.`parquet/empty/complex/empty_complex.parquet`
```
So PARQUET-1851 breaks the following test cases:
```java
TestUntypedNull.testParquetTableCreation TestParquetWriterEmptyFiles.testComplexEmptyFileSchema TestParquetWriterEmptyFiles.testWriteEmptyFile TestParquetWriterEmptyFiles.testWriteEmptyFileWithSchema TestParquetWriterEmptyFiles.testWriteEmptySchemaChange TestMetastoreCommands.testAnalyzeEmptyRequiredParquetTable TestMetastoreCommands.testSelectEmptyRequiredParquetTable
```
I suggest to use warning in the process of creating empty parquet files or create alternative _endBlock_ for backward compatibility with other tools:

**Reporter**: [Vitalii Diravka](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=vitalii) / @vdiravka
#### Related issues:
- [Error: SYSTEM ERROR: RuntimeException: Unknown logical type ](https://issues.apache.org/jira/browse/DRILL-7825) (Is contained by)
- [Replace ParquetFileWriter in Drill with parquet version](https://issues.apache.org/jira/browse/DRILL-7907) (Is contained by)
- [ParquetMetadataConveter throws NPE in an Iceberg unit test](https://github.com/apache/parquet-java/issues/2487) (is broken by)
- [Error: SYSTEM ERROR: RuntimeException: Unknown logical type ](https://issues.apache.org/jira/browse/DRILL-7825) (is required by)
#### Original Issue Attachments:
- [Screenshot from 2021-04-13 08-52-56.png](https://issues.apache.org/jira/secure/attachment/13023747/Screenshot+from+2021-04-13+08-52-56.png)
**Note**: *This issue was originally created as [PARQUET-2026](https://issues.apache.org/jira/browse/PARQUET-2026). Please see the [migration documentation](https://issues.apache.org/jira/browse/PARQUET-2502) for further details.*
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by running the named tests, including TestParquetWriterEmptyFiles.testWriteEmptyFile and testWriteEmptyFileWithSchema, along with the Drill metastore tests. Trace the empty-file writing path and compare the behavior with the listed PARQUET-1851 regression. Done means empty Parquet files retain usable schema metadata and all listed tests pass without breaking compatibility with other tools.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- data-engineering
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100