-
Notifications
You must be signed in to change notification settings - Fork 979
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DRILL-3333: Parquet writer auto-partitioning and partition pruning
- Loading branch information
1 parent
3aa82bc
commit 5a34d81
Showing
17 changed files
with
1,237 additions
and
274 deletions.
There are no files selected for viewing
This file contains 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 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
103 changes: 103 additions & 0 deletions
103
exec/java-exec/src/main/codegen/templates/NewValueFunctions.java
This file contains 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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,103 @@ | |||
/** | |||
* 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. | |||
*/ | |||
<@pp.dropOutputFile /> | |||
|
|||
|
|||
<@pp.changeOutputFile name="/org/apache/drill/exec/expr/fn/impl/GNewValueFunctions.java" /> | |||
<#include "/@includes/license.ftl" /> | |||
|
|||
package org.apache.drill.exec.expr.fn.impl; | |||
|
|||
import org.apache.drill.exec.expr.DrillSimpleFunc; | |||
import org.apache.drill.exec.expr.annotations.FunctionTemplate; | |||
import org.apache.drill.exec.expr.annotations.FunctionTemplate.NullHandling; | |||
import org.apache.drill.exec.expr.annotations.Output; | |||
import org.apache.drill.exec.expr.annotations.Param; | |||
import org.apache.drill.exec.expr.annotations.Workspace; | |||
import org.apache.drill.exec.expr.holders.*; | |||
import javax.inject.Inject; | |||
import io.netty.buffer.DrillBuf; | |||
import org.apache.drill.exec.record.RecordBatch; | |||
|
|||
public class GNewValueFunctions { | |||
<#list vv.types as type> | |||
<#if type.major == "Fixed"> | |||
<#list type.minor as minor> | |||
<#list vv.modes as mode> | |||
<#if mode.name != "Repeated"> | |||
<#if !minor.class.startsWith("Decimal28") && !minor.class.startsWith("Decimal38") && !minor.class.startsWith("Interval")> | |||
@SuppressWarnings("unused") | |||
@FunctionTemplate(name = "newPartitionValue", scope = FunctionTemplate.FunctionScope.SIMPLE, nulls=NullHandling.INTERNAL) | |||
public static class NewValue${minor.class}${mode.prefix} implements DrillSimpleFunc{ | |||
@Param ${mode.prefix}${minor.class}Holder in; | |||
@Workspace ${mode.prefix}${minor.class}Holder previous; | |||
@Workspace Boolean initialized; | |||
@Output BitHolder out; | |||
public void setup() { | |||
initialized = false; | |||
} | |||
<#if mode.name == "Required"> | |||
public void eval() { | |||
if (initialized) { | |||
if (in.value == previous.value) { | |||
out.value = 0; | |||
} else { | |||
previous.value = in.value; | |||
out.value = 1; | |||
} | |||
} else { | |||
previous.value = in.value; | |||
out.value = 1; | |||
initialized = true; | |||
} | |||
} | |||
</#if> | |||
<#if mode.name == "Optional"> | |||
public void eval() { | |||
if (initialized) { | |||
if (in.isSet == 0 && previous.isSet == 0) { | |||
out.value = 0; | |||
} else if (in.value == previous.value) { | |||
out.value = 0; | |||
} else { | |||
previous.value = in.value; | |||
previous.isSet = in.isSet; | |||
out.value = 1; | |||
} | |||
} else { | |||
previous.value = in.value; | |||
previous.isSet = in.isSet; | |||
out.value = 1; | |||
initialized = true; | |||
} | |||
} | |||
</#if> | |||
} | |||
</#if> <#-- minor.class.startWith --> | |||
|
|||
</#if> <#-- mode.name --> | |||
</#list> | |||
</#list> | |||
</#if> <#-- type.major --> | |||
</#list> | |||
} |
This file contains 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 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 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 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 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
62 changes: 62 additions & 0 deletions
62
exec/java-exec/src/main/java/org/apache/drill/exec/planner/ParquetPartitionDescriptor.java
This file contains 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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,62 @@ | |||
/** | |||
* 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.drill.exec.planner; | |||
|
|||
import com.google.common.collect.Maps; | |||
import org.apache.drill.common.expression.SchemaPath; | |||
|
|||
import java.util.List; | |||
import java.util.Map; | |||
|
|||
|
|||
/** | |||
* PartitionDescriptor that describes partitions based on column names instead of directory structure | |||
*/ | |||
public class ParquetPartitionDescriptor implements PartitionDescriptor { | |||
|
|||
private final List<SchemaPath> partitionColumns; | |||
|
|||
public ParquetPartitionDescriptor(List<SchemaPath> partitionColumns) { | |||
this.partitionColumns = partitionColumns; | |||
} | |||
|
|||
@Override | |||
public int getPartitionHierarchyIndex(String partitionName) { | |||
throw new UnsupportedOperationException(); | |||
} | |||
|
|||
@Override | |||
public boolean isPartitionName(String name) { | |||
return partitionColumns.contains(name); | |||
} | |||
|
|||
@Override | |||
public Integer getIdIfValid(String name) { | |||
SchemaPath schemaPath = SchemaPath.getSimplePath(name); | |||
int id = partitionColumns.indexOf(schemaPath); | |||
if (id == -1) { | |||
return null; | |||
} | |||
return id; | |||
} | |||
|
|||
@Override | |||
public int getMaxHierarchyLevel() { | |||
return partitionColumns.size(); | |||
} | |||
} |
This file contains 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.