-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Add window-focused tests from Drill #13773
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
f44f351
Add window-focused tests from Drill
imply-cheddar d29ce43
Static checks ftw!
imply-cheddar 50c8f7b
Some review comments and merge conflicts
imply-cheddar 247a382
Fix!
imply-cheddar 0fe04e0
Improve test coverage
imply-cheddar d539712
Checkstyle and codeQL
imply-cheddar a53b083
Test fixes
imply-cheddar 73b0f65
Mo4r Test fixes
imply-cheddar fbfa539
Coverage good now?
imply-cheddar 88ca894
More coverage
imply-cheddar 9482f40
Will CI start?
imply-cheddar 569053e
checkstyle
imply-cheddar 9ab775d
Remove dependency that's not needed in processing pom
imply-cheddar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
...e/parquet-extensions/src/main/java/org/apache/druid/data/input/parquet/ParquetToJson.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you 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. | ||
| */ | ||
|
|
||
| package org.apache.druid.data.input.parquet; | ||
|
|
||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||
| import com.fasterxml.jackson.databind.SequenceWriter; | ||
| import org.apache.druid.data.input.parquet.simple.ParquetGroupConverter; | ||
| import org.apache.druid.jackson.DefaultObjectMapper; | ||
| import org.apache.druid.java.util.common.IAE; | ||
| import org.apache.hadoop.fs.Path; | ||
| import org.apache.parquet.example.data.Group; | ||
| import org.apache.parquet.hadoop.example.GroupReadSupport; | ||
|
|
||
| import java.io.File; | ||
|
|
||
| /** | ||
| * Converts parquet files into new-deliminated JSON object files. Takes a single argument (an input directory) | ||
| * and processes all files that end with a ".parquet" extension. Writes out a new file in the same directory named | ||
| * by appending ".json" to the old file name. Will overwrite any output file that already exists. | ||
| */ | ||
| public class ParquetToJson | ||
| { | ||
|
|
||
| public static void main(String[] args) throws Exception | ||
| { | ||
| if (args.length != 1) { | ||
| throw new IAE("Usage: directory"); | ||
| } | ||
|
|
||
| ParquetGroupConverter converter = new ParquetGroupConverter(true); | ||
| ObjectMapper mapper = new DefaultObjectMapper(); | ||
|
|
||
| File[] inputFiles = new File(args[0]).listFiles( | ||
| pathname -> pathname.getName().endsWith(".parquet") | ||
| ); | ||
| for (File inputFile : inputFiles) { | ||
| File outputFile = new File(inputFile.getAbsolutePath() + ".json"); | ||
|
|
||
| try ( | ||
| final org.apache.parquet.hadoop.ParquetReader<Group> reader = org.apache.parquet.hadoop.ParquetReader | ||
| .builder(new GroupReadSupport(), new Path(inputFile.toURI())) | ||
| .build(); | ||
| final SequenceWriter writer = mapper.writer().withRootValueSeparator("\n").writeValues(outputFile) | ||
| ) { | ||
| Group group; | ||
| while ((group = reader.read()) != null) { | ||
| writer.write(converter.convertGroup(group)); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
...rquet-extensions/src/test/java/org/apache/druid/data/input/parquet/ParquetToJsonTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you 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. | ||
| */ | ||
|
|
||
| package org.apache.druid.data.input.parquet; | ||
|
|
||
| import com.google.common.collect.ImmutableMap; | ||
| import org.apache.druid.jackson.DefaultObjectMapper; | ||
| import org.apache.druid.java.util.common.IAE; | ||
| import org.junit.Assert; | ||
| import org.junit.ClassRule; | ||
| import org.junit.Test; | ||
| import org.junit.rules.TemporaryFolder; | ||
|
|
||
| import java.io.BufferedInputStream; | ||
| import java.io.File; | ||
| import java.io.InputStream; | ||
| import java.nio.file.Files; | ||
| import java.util.List; | ||
|
|
||
| @SuppressWarnings("ALL") | ||
| public class ParquetToJsonTest | ||
| { | ||
| @ClassRule | ||
| public static TemporaryFolder tmp = new TemporaryFolder(); | ||
|
|
||
| @Test | ||
| public void testSanity() throws Exception | ||
| { | ||
| final File tmpDir = tmp.newFolder(); | ||
| try (InputStream in = new BufferedInputStream(ClassLoader.getSystemResourceAsStream("smlTbl.parquet"))) { | ||
| Files.copy(in, tmpDir.toPath().resolve("smlTbl.parquet")); | ||
| } | ||
|
|
||
| ParquetToJson.main(new String[]{tmpDir.toString()}); | ||
|
|
||
| DefaultObjectMapper mapper = DefaultObjectMapper.INSTANCE; | ||
| List<Object> objs = mapper.readerFor(Object.class).readValues(new File(tmpDir, "smlTbl.parquet.json")).readAll(); | ||
|
|
||
| Assert.assertEquals(56, objs.size()); | ||
| Assert.assertEquals( | ||
| ImmutableMap | ||
| .builder() | ||
| .put("col_int", 8122) | ||
| .put("col_bgint", 817200) | ||
| .put("col_char_2", "IN") | ||
| .put("col_vchar_52", "AXXXXXXXXXXXXXXXXXXXXXXXXXCXXXXXXXXXXXXXXXXXXXXXXXXB") | ||
| .put("col_tmstmp", 1409617682418L) | ||
| .put("col_dt", 422717616000000L) | ||
| .put("col_booln", false) | ||
| .put("col_dbl", 12900.48) | ||
| .put("col_tm", 33109170) | ||
| .build(), | ||
| objs.get(0) | ||
| ); | ||
| } | ||
|
|
||
| @Test | ||
| public void testInputValidation() | ||
| { | ||
| Assert.assertThrows(IAE.class, () -> ParquetToJson.main(new String[]{})); | ||
| Assert.assertThrows(IAE.class, () -> ParquetToJson.main(new String[]{"a", "b"})); | ||
| } | ||
| } |
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.