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

HPCC-31860 Test suite for the Parquet plugin #18980

Merged
Show file tree
Hide file tree
Changes from all commits
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
Binary file added testing/regress/download/corrupt.parquet
Binary file not shown.
Binary file added testing/regress/download/multi_1_of_3.parquet
Binary file not shown.
Binary file added testing/regress/download/multi_2_of_3.parquet
Binary file not shown.
Binary file added testing/regress/download/multi_3_of_3.parquet
Binary file not shown.
Binary file added testing/regress/download/single.parquet
Binary file not shown.
1 change: 1 addition & 0 deletions testing/regress/ecl/key/parqueCorrupt.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<Exception><Source>eclagent</Source><Message>Error: 0: parquet: Invalid: Parquet magic bytes not found in footer. Either the file is corrupted or this is not a parquet file..</Message></Exception>
2 changes: 2 additions & 0 deletions testing/regress/ecl/key/parquetEmpty.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<Dataset name='Result 1'>
</Dataset>
2 changes: 2 additions & 0 deletions testing/regress/ecl/key/parquetOverwrite.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<Exception><Source>eclagent</Source><Message>Error: 0: parquet: The target file /var/lib/HPCCSystems/mydropzone/SingleRowTest.parquet already exists. To delete the file set the overwrite option to true.</Message></Exception>

10 changes: 10 additions & 0 deletions testing/regress/ecl/key/parquetPartition.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Dataset name='HivePartitionedSampleData'>
<Row><id>1</id><name>Alice </name><age>30</age><city>New York </city></Row>
<Row><id>2</id><name>Bob </name><age>25</age><city>Los Angeles </city></Row>
<Row><id>3</id><name>Charlie </name><age>40</age><city>Chicago </city></Row>
</Dataset>
<Dataset name='DirPartitionedSampleData'>
<Row><id>1</id><name>Alice </name><age>30</age><city>New York </city></Row>
<Row><id>2</id><name>Bob </name><age>25</age><city>Los Angeles </city></Row>
<Row><id>3</id><name>Charlie </name><age>40</age><city>Chicago </city></Row>
</Dataset>
4 changes: 4 additions & 0 deletions testing/regress/ecl/key/parquetSchema.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<Dataset name='ReadData'>
<Row><name>Alice</name><salary>50000.5</salary><id>1</id></Row>
<Row><name>Bob</name><salary>60000.75</salary><id>2</id></Row>
</Dataset>
13 changes: 13 additions & 0 deletions testing/regress/ecl/key/parquetSize.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Dataset name='singleDataset'>
<Row><id>1</id><name>Alice</name><price>10.5</price><isactive>yes</isactive></Row>
<Row><id>2</id><name>Bob</name><price>20.75</price><isactive>no</isactive></Row>
<Row><id>3</id><name>Charlie</name><price>15.25</price><isactive>yes</isactive></Row>
<Row><id>1</id><name>A</name><price>10.0</price><isactive>1</isactive></Row>
</Dataset>
<Dataset name='multiDataset'>
<Row><id>1</id><name>A</name><price>10.0</price><isactive>1</isactive></Row>
<Row><id>3</id><name>Charlie</name><price>15.25</price><isactive>yes</isactive></Row>
<Row><id>2</id><name>Bob</name><price>20.75</price><isactive>no</isactive></Row>
<Row><id>1</id><name>A</name><price>10.0</price><isactive>1</isactive></Row>
<Row><id>1</id><name>Alice</name><price>10.5</price><isactive>yes</isactive></Row>
</Dataset>
8 changes: 8 additions & 0 deletions testing/regress/ecl/key/parquetString.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Dataset name='ComparisonResult'>
<Row><s1>Hello </s1><s2>World </s2><s3>Test Data 1 </s3></Row>
<Row><s1>HPCC </s1><s2>Systems </s2><s3>Test Data 2 </s3></Row>
<Row><s1>Parquet </s1><s2>I/O </s2><s3>Test Data 3 </s3></Row>
</Dataset>
<Dataset name='TestResult'>
<Row><TestResult>All records match</TestResult></Row>
</Dataset>
33 changes: 33 additions & 0 deletions testing/regress/ecl/key/parquetTypes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<Dataset name='BooleanTest'>
<Row><BooleanTest>Pass</BooleanTest></Row>
</Dataset>
<Dataset name='IntegerTest'>
<Row><IntegerTest>Pass</IntegerTest></Row>
</Dataset>
<Dataset name='UnsignedTest'>
<Row><UnsignedTest>Pass</UnsignedTest></Row>
</Dataset>
<Dataset name='RealTest'>
<Row><RealTest>Pass</RealTest></Row>
</Dataset>
<Dataset name='DecimalTest'>
<Row><DecimalTest>Pass</DecimalTest></Row>
</Dataset>
<Dataset name='StringTest'>
<Row><StringTest>Pass</StringTest></Row>
</Dataset>
<Dataset name='DataAsStringTest'>
<Row><DataAsStringTest>Pass</DataAsStringTest></Row>
</Dataset>
<Dataset name='VarStringTest'>
<Row><VarStringTest>Pass</VarStringTest></Row>
</Dataset>
<Dataset name='QStringTest'>
<Row><QStringTest>Pass</QStringTest></Row>
</Dataset>
<Dataset name='UTF8Test'>
<Row><UTF8Test>Pass</UTF8Test></Row>
</Dataset>
<Dataset name='UnicodeTest'>
<Row><UnicodeTest>Pass</UnicodeTest></Row>
</Dataset>
39 changes: 39 additions & 0 deletions testing/regress/ecl/parquetCorrupt.ecl
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*##############################################################################
HPCC SYSTEMS software Copyright (C) 2024 HPCC Systems®.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
############################################################################## */

//class=parquet
//fail
//nothor
//noroxe

//This ECL code reads a potentially corrupt Parquet file, handling the case where it might be corrupt
//by outputting either the file contents or a single informative record if the file can't be read.

IMPORT Std;
IMPORT Parquet;

RECORDDEF := RECORD
UNSIGNED4 index;
STRING name;
STRING director;
END;

filePath2 := Std.File.GetDefaultDropZone() + '/corrupt.parquet';

CORRUPT_PARQUET := ParquetIO.Read(RECORDDEF, filePath2);

CORRUPT_RESULT := IF(COUNT(CORRUPT_PARQUET) = 0,
DATASET([{0, 'Corrupt Parquet File', ''}], RECORDDEF),
CORRUPT_PARQUET);

OUTPUT(CORRUPT_RESULT);
36 changes: 36 additions & 0 deletions testing/regress/ecl/parquetEmpty.ecl
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*##############################################################################
HPCC SYSTEMS software Copyright (C) 2024 HPCC Systems®.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
############################################################################## */

//class=parquet
//nothor
//noroxie

IMPORT Std;
IMPORT Parquet;

RECORDDEF := RECORD
UNSIGNED4 index;
STRING director;
END;

basePath := Std.File.GetDefaultDropZone() + '/regress/parquet/';
filePath := basePath + 'empty_test.parquet';

EMPTY_PARQUET := DATASET([], RECORDDEF);
jackdelv marked this conversation as resolved.
Show resolved Hide resolved

ParquetIO.Write(EMPTY_PARQUET, filePath, TRUE);

read_data := ParquetIO.Read(RECORDDEF, filePath);

OUTPUT(read_data);

29 changes: 29 additions & 0 deletions testing/regress/ecl/parquetOverwrite.ecl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*##############################################################################
HPCC SYSTEMS software Copyright (C) 2024 HPCC Systems®.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
############################################################################## */

//class=parquet
//fail
//nothor
//noroxie

IMPORT Std;
IMPORT Parquet;

SingleRowDataset := DATASET([{1, 'SingleRow', TRUE}], {UNSIGNED id, STRING name, BOOLEAN flag});

basePath := Std.File.GetDefaultDropZone() + '/regress/parquet/';
FilePath := basePath + 'SingleRowTest.parquet';

writeParquetFile := ParquetIO.write(SingleRowDataset, FilePath);

SEQUENTIAL(writeParquetFile, writeParquetFile);
74 changes: 74 additions & 0 deletions testing/regress/ecl/parquetPartition.ecl
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*##############################################################################
HPCC SYSTEMS software Copyright (C) 2024 HPCC Systems®.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
############################################################################## */
//class=parquet
//nothor
//noroxie

IMPORT Std;
IMPORT Parquet;

// Define the record layout with explicit field lengths
datasetRecordLayout := RECORD
UNSIGNED4 id;
STRING25 name;
UNSIGNED4 age;
STRING50 city;
END;

// Create a small dataset - ensure all records have valid data
smallData := DATASET([
{1, 'Alice', 30, 'New York'},
{2, 'Bob', 25, 'Los Angeles'},
{3, 'Charlie', 40, 'Chicago'}
], datasetRecordLayout);

// Set options
overwriteOption := TRUE;
rowSize := 1024; // Increased buffer size

// Define base path (without 'file://' prefix)
basePath := Std.File.GetDefaultDropZone() + '/regress/parquet/';

// Define partition keys as a semicolon-separated string with all keys
partitionKeys := 'id';

// Write out the dataset with Hive partitioning on all keys
ParquetIO.HivePartition.Write(
smallData,
rowSize,
basePath + 'hive_partitioned/',
overwriteOption,
partitionKeys
);

// Write out the dataset with Directory partitioning on all keys
ParquetIO.DirectoryPartition.Write(
smallData,
rowSize,
basePath + 'dir_partitioned/',
overwriteOption,
partitionKeys
);

// Define file paths for partitioned datasets
hiveFilePath := basePath + 'hive_partitioned/';
dirFilePath := basePath + 'dir_partitioned/';

// Read back the partitioned data
readBackHiveData := ParquetIO.HivePartition.Read(datasetRecordLayout, hiveFilePath);
readBackDirData := ParquetIO.DirectoryPartition.Read(datasetRecordLayout, dirFilePath, partitionKeys);

// Output the entire dataset for verification
OUTPUT(readBackHiveData, NAMED('HivePartitionedSampleData'));
OUTPUT(readBackDirData, NAMED('DirPartitionedSampleData'));

46 changes: 46 additions & 0 deletions testing/regress/ecl/parquetSchema.ecl
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*##############################################################################
HPCC SYSTEMS software Copyright (C) 2024 HPCC Systems®.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
############################################################################## */

//class=parquet
//nothor
//noroxie
//fail

IMPORT Std;
IMPORT Parquet;

Layout1 := RECORD
INTEGER id;
STRING name;
REAL salary;
END;

Layout2 := RECORD
STRING name;
REAL salary;
INTEGER id;
END;

testData := DATASET([
{ 1, 'Alice', 50000.50 },
{ 2, 'Bob', 60000.75 }
], Layout1);

basePath := Std.File.GetDefaultDropZone() + '/regress/parquet/';
FilePath := basePath + 'reorder_test.parquet';

ParquetIO.Write(testData, filePath, TRUE);

readData := ParquetIO.Read(Layout2, filePath);

OUTPUT(readData, NAMED('ReadData'));
45 changes: 45 additions & 0 deletions testing/regress/ecl/parquetSize.ecl
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*##############################################################################
HPCC SYSTEMS software Copyright (C) 2024 HPCC Systems®.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
##############################################################################*/

//class=parquet
//nothor
//noroxie
//nohthor

IMPORT Std;
IMPORT Parquet;

recordLayout := RECORD
UNSIGNED4 id;
STRING name;
REAL8 price;
STRING isactive;
END;

basePath := Std.File.GetDefaultDropZone() + '/regress/parquet/';

singleFilePath := basePath + 'single.parquet';
multiFilePath := basePath + 'multi.parquet';

// Reading the single and multi-part files
singleDataset := ParquetIO.Read(recordLayout, singleFilePath);
multiDataset := ParquetIO.Read(recordLayout, multiFilePath);

// Output the datasets
SEQUENTIAL(
OUTPUT(singleDataset, NAMED('singleDataset')), // Output for the single file
OUTPUT(multiDataset, NAMED('multiDataset')) // Output for the combined multi-part files
);
Loading
Loading