Sfoglia il codice sorgente

HPCC-9610 Improve implicit projection of child queries

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday 12 anni fa
parent
commit
cc41614fd6

+ 3 - 0
ecl/hql/hqlutil.cpp

@@ -8197,6 +8197,9 @@ bool userPreventsSort(IHqlExpression * noSortAttr, node_operator side)
 
 IHqlExpression * queryTransformAssign(IHqlExpression * transform, IHqlExpression * searchField)
 {
+    while (transform->getOperator() == no_alias_scope)
+        transform = transform->queryChild(0);
+
     ForEachChild(i, transform)
     {
         IHqlExpression * cur = transform->queryChild(i);

+ 1 - 1
ecl/hqlcpp/hqlcpp.cpp

@@ -1589,7 +1589,7 @@ void HqlCppTranslator::cacheOptions()
         DebugOption(options.finalizeAllRows, "finalizeAllRows", false),
         DebugOption(options.maxLocalRowSize , "maxLocalRowSize", MAX_LOCAL_ROW_SIZE),
         DebugOption(options.optimizeGraph,"optimizeGraph", true),
-        DebugOption(options.optimizeChildGraph,"optimizeChildGraph", false),
+        DebugOption(options.optimizeChildGraph,"optimizeChildGraph", true),
         DebugOption(options.orderDiskFunnel,"orderDiskFunnel", true),
         DebugOption(options.alwaysAllowAllNodes,"alwaysAllowAllNodes", false),
         DebugOption(options.slidingJoins,"slidingJoins", false),

+ 10 - 0
ecl/hqlcpp/hqlcppds.cpp

@@ -1697,6 +1697,16 @@ IHqlExpression * HqlCppTranslator::getResourcedChildGraph(BuildCtx & ctx, IHqlEx
     //Convert queries on preloaded into compound activities - before resourcing so keyed gets done correctly
     // Second attempt to spot compound disk reads - this time of spill files.  Since resourcing has removed
     // any sharing we don't need to bother about sharing.
+    if (options.optimizeResourcedProjects)
+    {
+        cycle_t time = msTick();
+        OwnedHqlExpr optimized = insertImplicitProjects(*this, resourced.get(), options.optimizeSpillProject);
+        DEBUG_TIMER("EclServer: child.implicitprojects", msTick()-time);
+        traceExpression("AfterResourcedImplicit", optimized);
+        checkNormalized(ctx, optimized);
+        resourced.set(optimized);
+    }
+
     {
         unsigned time = msTick();
 

+ 8 - 3
ecl/hqlcpp/hqliproj.cpp

@@ -1610,7 +1610,7 @@ void ImplicitProjectTransformer::analyseExpr(IHqlExpression * expr)
             setOriginal(complexExtra->rightFieldsRequired, expr->queryChild(1));
             break;
         case FixedInputActivity:
-            assertex(child && (child->isDataset() || child->isDatarow() || child->isDictionary()));
+            assertex(child && child->queryRecord());
             setOriginal(complexExtra->leftFieldsRequired, child);
             if (getNumChildTables(expr) >= 2)
                 setOriginal(complexExtra->rightFieldsRequired, expr->queryChild(1));
@@ -2104,6 +2104,7 @@ ProjectExprKind ImplicitProjectTransformer::getProjectExprKind(IHqlExpression *
     case no_graphloop:
     case no_filtergroup:            //anything else would be tricky...
     case no_normalizegroup:
+    case no_getgraphloopresultset:
         return FixedInputActivity;
     case no_aggregate:
         if (expr->hasAttribute(mergeTransformAtom))
@@ -2157,6 +2158,10 @@ ProjectExprKind ImplicitProjectTransformer::getProjectExprKind(IHqlExpression *
         if (getProjectExprKind(expr->queryChild(0)) == CompoundableActivity)
             return CompoundableActivity;
         return PassThroughActivity;
+    case no_serialize:
+    case no_deserialize:
+        //This needs to map fields by name.  Until that is implemented don't project these types.
+        return FixedInputActivity;
     }
 
     ITypeInfo * type = expr->queryType();
@@ -2908,7 +2913,7 @@ IHqlExpression * ImplicitProjectTransformer::createTransformed(IHqlExpression *
                 if (cur->isDataset() || cur->isDatarow())
                 {
                     //Ensure all inputs have same format..
-                    if (cur->queryRecord() != complexExtra->queryOutputRecord())
+                    if (next->queryRecord() != complexExtra->queryOutputRecord())
                         next.setown(complexExtra->createOutputProject(next));
                 }
                 args.append(*next.getClear());
@@ -3026,7 +3031,7 @@ void ImplicitProjectTransformer::finalizeFields(IHqlExpression * expr)
         break;
     case PassThroughActivity:
         {
-            //Banches coming into this IF/MERGE etc. may have different fields (e.g., because of ITERATEs), and
+            //Branches coming into this IF/MERGE etc. may have different fields (e.g., because of ITERATEs), and
             //the output fields may be smaller (e.g., no merge sort conditions, no fields used and inputs filter)
             //So use the intersection of the inputfields as the output record.  90% of the time they will be
             //the same so no projects will be introduced.

+ 1 - 1
ecl/regress/ambignest.ecl

@@ -41,7 +41,7 @@ xnamesRecord t1(xNamesRecord l) := transform
             self := l2;
         end;
     p2 := project(s, t2(LEFT));
-    self.matches := normalize(p2, left.matches, transform(right));
+    self.matches := normalize(NOFOLD(p2), left.matches, transform(right));
     self := l;
     end;