Skip to content

Commit

Permalink
DRILL-6381: (Part 2) MapRDB plugin update to 6.0.1
Browse files Browse the repository at this point in the history
  1. MD-3960: Update Drill to build with MapR-6.0.1 libraries
  2. MD-3995: Do not pushdown limit 0 past project with CONVERT_FROMJSON
  3. MD-4054: Restricted scan limit is changed to dynamically read rows using the rowcount of the rightside instead of 4096.
  4. MD-3688: Impersonating a view owner doesn't work with security disabled in 6.0
  5. MD-4492: Missing limit pushdown changes in JsonTableGroupScan

Co-authored-by: chunhui-shi <cshi@maprtech.com>
Co-authored-by: Gautam Parai <gparai@maprtech.com>
Co-authored-by: Vlad Rozov <vrozov@mapr.com>

Conflicts:
	contrib/format-maprdb/src/main/java/org/apache/drill/exec/store/mapr/db/MapRDBFormatPlugin.java
	contrib/format-maprdb/src/main/java/org/apache/drill/exec/store/mapr/db/MapRDBSubScan.java
	contrib/format-maprdb/src/main/java/org/apache/drill/exec/store/mapr/db/binary/BinaryTableGroupScan.java
	contrib/format-maprdb/src/main/java/org/apache/drill/exec/store/mapr/db/json/CompareFunctionsProcessor.java
	contrib/format-maprdb/src/main/java/org/apache/drill/exec/store/mapr/db/json/JsonConditionBuilder.java
	contrib/format-maprdb/src/main/java/org/apache/drill/exec/store/mapr/db/json/JsonTableGroupScan.java
	contrib/format-maprdb/src/main/java/org/apache/drill/exec/store/mapr/db/json/MaprDBJsonRecordReader.java
	exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/PrelUtil.java
	pom.xml
  • Loading branch information
rebase authored and Aman Sinha committed Oct 25, 2018
1 parent 0abcbe3 commit a4f62e9
Show file tree
Hide file tree
Showing 61 changed files with 5,079 additions and 665 deletions.
89 changes: 89 additions & 0 deletions contrib/format-maprdb/pom.xml
Expand Up @@ -83,6 +83,41 @@
</systemProperties>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<excludes>
<!-- do not package test configurations in the jar files as it can override
the installed one -->
<exclude>**/core-site.xml</exclude>
<exclude>**/logback.xml</exclude>
</excludes>
</configuration>
</plugin>

<!-- we need the source plugin for the UDFs -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.9.1</version>
<executions>
<execution>
<id>add-sources-as-resources</id>
<phase>process-sources</phase>
<goals>
<goal>add-resource</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>src/main/java</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down Expand Up @@ -132,13 +167,39 @@
<artifactId>log4j-over-slf4j</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty</artifactId>
</exclusion>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.tdunning</groupId>
<artifactId>json</artifactId>
</dependency>
<!-- Test dependencies -->
<dependency>
<groupId>com.mapr.db</groupId>
<artifactId>maprdb</artifactId>
<version>${mapr.release.version}</version>
<classifier>tests</classifier>
</dependency>
<dependency>
<groupId>com.mapr.hadoop</groupId>
<artifactId>maprfs</artifactId>
<version>${mapr.release.version}</version>
<classifier>tests</classifier>
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.54</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.mapr</groupId>
<artifactId>mapr-java-utils</artifactId>
Expand All @@ -157,6 +218,16 @@
<version>${project.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty</artifactId>
</exclusion>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.drill</groupId>
Expand All @@ -169,6 +240,14 @@
<artifactId>log4j-over-slf4j</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty</artifactId>
</exclusion>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
Expand All @@ -177,6 +256,16 @@
<version>${project.version}</version>
<classifier>tests</classifier>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty</artifactId>
</exclusion>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
</exclusion>
</exclusions>
</dependency>

</dependencies>
Expand Down
@@ -0,0 +1,163 @@
/*
* 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.index;

import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import org.apache.drill.common.expression.CastExpression;
import org.apache.drill.common.expression.LogicalExpression;
import org.apache.drill.common.expression.SchemaPath;

import java.util.Map;
import java.util.Set;

public class MapRDBFunctionalIndexInfo implements FunctionalIndexInfo {

final private IndexDescriptor indexDesc;

private boolean hasFunctionalField = false;

//when we scan schemaPath in groupscan's columns, we check if this column(schemaPath) should be rewritten to '$N',
//When there are more than two functions on the same column in index, CAST(a.b as INT), CAST(a.b as VARCHAR),
// then we should map SchemaPath a.b to a set of SchemaPath, e.g. $1, $2
private Map<SchemaPath, Set<SchemaPath>> columnToConvert;

// map of functional index expression to destination SchemaPath e.g. $N
private Map<LogicalExpression, LogicalExpression> exprToConvert;

//map of SchemaPath involved in a functional field
private Map<LogicalExpression, Set<SchemaPath>> pathsInExpr;

private Set<SchemaPath> newPathsForIndexedFunction;

private Set<SchemaPath> allPathsInFunction;

public MapRDBFunctionalIndexInfo(IndexDescriptor indexDesc) {
this.indexDesc = indexDesc;
columnToConvert = Maps.newHashMap();
exprToConvert = Maps.newHashMap();
pathsInExpr = Maps.newHashMap();
//keep the order of new paths, it may be related to the naming policy
newPathsForIndexedFunction = Sets.newLinkedHashSet();
allPathsInFunction = Sets.newHashSet();
init();
}

private void init() {
int count = 0;
for(LogicalExpression indexedExpr : indexDesc.getIndexColumns()) {
if( !(indexedExpr instanceof SchemaPath) ) {
hasFunctionalField = true;
SchemaPath functionalFieldPath = SchemaPath.getSimplePath("$"+count);
newPathsForIndexedFunction.add(functionalFieldPath);

//now we handle only cast expression
if(indexedExpr instanceof CastExpression) {
//We handle only CAST directly on SchemaPath for now.
SchemaPath pathBeingCasted = (SchemaPath)((CastExpression) indexedExpr).getInput();
addTargetPathForOriginalPath(pathBeingCasted, functionalFieldPath);
addPathInExpr(indexedExpr, pathBeingCasted);
exprToConvert.put(indexedExpr, functionalFieldPath);
allPathsInFunction.add(pathBeingCasted);
}

count++;
}
}
}

private void addPathInExpr(LogicalExpression expr, SchemaPath path) {
if (!pathsInExpr.containsKey(expr)) {
Set<SchemaPath> newSet = Sets.newHashSet();
newSet.add(path);
pathsInExpr.put(expr, newSet);
}
else {
pathsInExpr.get(expr).add(path);
}
}

private void addTargetPathForOriginalPath(SchemaPath origPath, SchemaPath newPath) {
if (!columnToConvert.containsKey(origPath)) {
Set<SchemaPath> newSet = Sets.newHashSet();
newSet.add(newPath);
columnToConvert.put(origPath, newSet);
}
else {
columnToConvert.get(origPath).add(newPath);
}
}


public boolean hasFunctional() {
return hasFunctionalField;
}

public IndexDescriptor getIndexDesc() {
return indexDesc;
}

/**
* getNewPath: for an original path, return new rename '$N' path, notice there could be multiple renamed paths
* if the there are multiple functional indexes refer original path.
* @param path
* @return
*/
public SchemaPath getNewPath(SchemaPath path) {
if(columnToConvert.containsKey(path)) {
return columnToConvert.get(path).iterator().next();
}
return null;
}

/**
* return a plain field path if the incoming index expression 'expr' is replaced to be a plain field
* @param expr suppose to be an indexed expression
* @return the renamed schemapath in index table for the indexed expression
*/
public SchemaPath getNewPathFromExpr(LogicalExpression expr) {
if(exprToConvert.containsKey(expr)) {
return (SchemaPath)exprToConvert.get(expr);
}
return null;
}

/**
* @return the map of indexed expression --> the involved schema paths in a indexed expression
*/
public Map<LogicalExpression, Set<SchemaPath>> getPathsInFunctionExpr() {
return pathsInExpr;
}


public Map<LogicalExpression, LogicalExpression> getExprMap() {
return exprToConvert;
}

public Set<SchemaPath> allNewSchemaPaths() {
return newPathsForIndexedFunction;
}

public Set<SchemaPath> allPathsInFunction() {
return allPathsInFunction;
}

public boolean supportEqualCharConvertToLike() {
return true;
}
}

0 comments on commit a4f62e9

Please sign in to comment.