Преглед на файлове

Merge pull request #6733 from ghalliday/issue12714

HPCC-12714 Support EMBEDDED DATASET syntax (currently ignored)

Reviewed-By: Jamie Noss <james.noss@lexisnexis.com>
Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman преди 10 години
родител
ревизия
8cfff07890
променени са 5 файла, в които са добавени 61 реда и са изтрити 2 реда
  1. 16 0
      ecl/hql/hqlthql.cpp
  2. 2 0
      ecl/hqlcpp/hqlcerrors.hpp
  3. 7 1
      ecl/hqlcpp/hqlttcpp.cpp
  4. 1 1
      ecl/regress/aggregate6b.ecl
  5. 35 0
      ecl/regress/issue12714err.ecl

+ 16 - 0
ecl/hql/hqlthql.cpp

@@ -2760,6 +2760,22 @@ void HqltHql::sortlistToEcl(IHqlExpression *expr, StringBuffer &s, bool addCurle
 StringBuffer &HqltHql::getFieldTypeString(IHqlExpression * e, StringBuffer &s)
 {
     ITypeInfo * type = e->queryType();
+    ITypeInfo * cur = type;
+    for(;;)
+    {
+        typemod_t mod = cur->queryModifier();
+        if (mod == typemod_none)
+            break;
+        if (mod == typemod_attr)
+        {
+            IHqlExpression * attr = (IHqlExpression *)cur->queryModifierExtra();
+            if (!isInternalAttribute(attr))
+                s.append(attr->queryName()).append(" ");
+        }
+
+        cur = cur->queryTypeBase();
+    }
+
     switch (type->getTypeCode())
     {
     case type_groupedtable:

+ 2 - 0
ecl/hqlcpp/hqlcerrors.hpp

@@ -214,6 +214,7 @@
 #define HQLERR_CouldNotGenerateDefault          4194
 #define HQLERR_DistributionVariableLengthX      4195
 #define HQLERR_DistributionUnsupportedTypeXX    4196
+#define HQLERR_InconsistentEmbedded             4197
 
 //Warnings....
 #define HQLWRN_PersistDataNotLikely             4500
@@ -539,6 +540,7 @@
 
 #define HQLERR_DistributionVariableLengthX_Text "DISTRIBUTION does not support variable length field '%s'"
 #define HQLERR_DistributionUnsupportedTypeXX_Text "DISTRIBUTION does not support field '%s' with type %s"
+#define HQLERR_InconsistentEmbedded_Text        "Field '%s' is specified as embedded but child record requires link counting"
 
 #define HQLERR_OrderOnVarlengthStrings_Text     "Rank/Ranked not supported on variable length strings"
 #define HQLERR_DistributionNoSequence_Text      "DISTRIBUTION() only supported at the outer level"

+ 7 - 1
ecl/hqlcpp/hqlttcpp.cpp

@@ -8946,12 +8946,18 @@ IHqlExpression * HqlLinkedChildRowTransformer::createTransformedBody(IHqlExpress
             case type_dictionary:
             case type_table:
             case type_groupedtable:
+                OwnedHqlExpr transformedRecord = transform(expr->queryRecord());
+                if (recordRequiresLinkCount(transformedRecord))
+                {
+                    if (expr->hasAttribute(embeddedAtom) || queryAttribute(type, embeddedAtom) || expr->hasAttribute(countAtom) || expr->hasAttribute(sizeofAtom))
+                        throwError1(HQLERR_InconsistentEmbedded, expr->queryId()->str());
+                }
                 if (expr->hasAttribute(embeddedAtom))
                 {
                     OwnedHqlExpr transformed = QuickHqlTransformer::createTransformedBody(expr);
                     return removeAttribute(transformed, embeddedAtom);
                 }
-                if (implicitLinkedChildRows && !expr->hasAttribute(_linkCounted_Atom))
+                if (implicitLinkedChildRows && !expr->hasAttribute(_linkCounted_Atom) && !queryAttribute(type, embeddedAtom))
                 {
                     //Don't use link counted rows for weird HOLe style dataset attributes
                     if (expr->hasAttribute(countAtom) || expr->hasAttribute(sizeofAtom))

+ 1 - 1
ecl/regress/aggregate6b.ecl

@@ -40,7 +40,7 @@ string          text{maxlength(10)};
 
 outRecord := RECORD
 unsigned        box;
-dataset(itemRecord) items{embedded};
+embedded dataset(itemRecord) items;
              END;
 
 outRecord t1(inRecord l, outRecord r) := TRANSFORM

+ 35 - 0
ecl/regress/issue12714err.ecl

@@ -0,0 +1,35 @@
+/*##############################################################################
+
+    HPCC SYSTEMS software Copyright (C) 2014 HPCC Systems.
+
+    Licensed 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.
+############################################################################## */
+
+
+itemRecord := RECORD
+string          text{maxlength(10)};
+            END;
+
+boxRecord := RECORD
+    unsigned        box;
+    dataset(itemRecord) items;
+END;
+
+storeRecord := RECORD
+    unsigned        id;
+    embedded dataset(boxRecord) boxes;
+END;
+
+
+dataset(storeRecord) stores := DATASET([], storeRecord) : STORED('stores');
+output(stores);