Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DRILL-6381: (Part 2) MapRDB plugin update to 6.0.1
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
Showing
61 changed files
with
5,079 additions
and
665 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
163 changes: 163 additions & 0 deletions
163
...t-maprdb/src/main/java/org/apache/drill/exec/planner/index/MapRDBFunctionalIndexInfo.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 | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
Oops, something went wrong.