浏览代码

Merge pull request #8376 from shamser/issue14997

HPCC-14997 Error 'First parameter of FETCH should be a disk file'

Reviewed-by: Gavin Halliday <ghalliday@hpccsystems.com>
Gavin Halliday 9 年之前
父节点
当前提交
668d090340

+ 0 - 1
ecl/hql/hqlerrors.hpp

@@ -199,7 +199,6 @@
 #define ERR_ASSERT_WRONGSCOPING     2131 /* Incorrect assertion scoping */
 #define ERR_ASSERT_BOOLEXPECTED     2132 /* Assertion must be boolean */
 #define ERR_SCOPE_USEDATASETINEXPR  2133 /* Use dataset in expression without proper context */
-#define ERR_FETCH_NON_DATASET       2134 /* Parameter to fetch isn't a dataset */
 
 #define ERR_MODIFIER_ILLCOMB        2141 /* Illegal combination of modifiers */
 #define ERR_EXPORTSHARECONFLICT     2142 /* EXPORT and SHARED cannot be specified together */

+ 0 - 12
ecl/hql/hqlgram.y

@@ -8678,12 +8678,6 @@ simpleDataSet
                             IHqlExpression * left = $3.getExpr();
                             IHqlExpression * right = $5.getExpr();
 
-                            node_operator modeOp = no_none;
-                            if (left->getOperator() == no_table)
-                                modeOp = left->queryChild(2)->getOperator();
-                            if ((modeOp != no_thor) && (modeOp != no_flat) && (modeOp != no_csv) && (modeOp != no_xml) && (modeOp != no_json))
-                                parser->reportError(ERR_FETCH_NON_DATASET, $3, "First parameter of FETCH should be a disk file");
-
                             IHqlExpression *join = createDataset(no_fetch, left, createComma(right, $7.getExpr(), $9.getExpr(), createComma($10.getExpr(), $12.getExpr())));
 
                             $$.setExpr(join);
@@ -8696,12 +8690,6 @@ simpleDataSet
                             IHqlExpression * right = $5.getExpr();
                             IHqlExpression * transform = parser->createDefJoinTransform(left, right, $7, $10.queryExpr(),NULL);
 
-                            node_operator modeOp = no_none;
-                            if (left->getOperator() == no_table)
-                                modeOp = left->queryChild(2)->getOperator();
-                            if ((modeOp != no_thor) && (modeOp != no_flat) && (modeOp != no_csv) && (modeOp != no_xml)  && (modeOp != no_json))
-                                parser->reportError(ERR_FETCH_NON_DATASET, $3, "First parameter of FETCH should be a disk file");
-
                             IHqlExpression *join = createDataset(no_fetch, left, createComma(right, $7.getExpr(), transform, createComma($8.getExpr(), $10.getExpr())));
 
                             $$.setExpr(join);

+ 2 - 1
ecl/hqlcpp/hqlcerrors.hpp

@@ -69,7 +69,7 @@
 #define HQLERR_RowTooLarge                      4043
 #define HQLERR_ShouldHaveBeenHoisted            4044
 #define HQLERR_NoArgumentsInValidator           4045
-
+#define HQLERR_FetchNonDiskfile                 4046
 #define HQLERR_InputMergeNotSorted              4047
 #define HQLERR_TooComplicatedToPreload          4048
 #define HQLERR_KeyedNotKeyed                    4049
@@ -373,6 +373,7 @@
 #define HQLERR_RowTooLarge_Text                 "Row size %u exceeds the maximum specified (%u)"
 #define HQLERR_ShouldHaveBeenHoisted_Text       "Select expression should have been hoisted"
 #define HQLERR_NoArgumentsInValidator_Text      "%s() cannot have a parameter inside a VALIDATE"
+#define HQLERR_FetchNonDiskfile_Text            "First parameter of FETCH should be a disk file"
 #define HQLERR_InputMergeNotSorted_Text         "Input to MERGE does not appear to be sorted"
 #define HQLERR_TooComplicatedToPreload_Text     "Expression is too complicated to preload"
 #define HQLERR_KeyedNotKeyed_Text               "KEYED(%s) could not be looked up in a key."

+ 2 - 0
ecl/hqlcpp/hqlsource.cpp

@@ -7251,6 +7251,8 @@ ABoundActivity * HqlCppTranslator::doBuildActivityFetch(BuildCtx & ctx, IHqlExpr
 {
     IHqlExpression *fetch = queryFetch(expr);
     IHqlExpression *tableExpr = queryPhysicalRootTable(fetch->queryChild(0));
+    if (!tableExpr)
+        throwError(HQLERR_FetchNonDiskfile);
     FetchBuilder info(*this, tableExpr, tableExpr->queryChild(0), expr);
     info.gatherVirtualFields(false, true);//?needToSerializeRecord(mode)
 

+ 55 - 0
ecl/regress/fetchinfunc.ecl

@@ -0,0 +1,55 @@
+/*##############################################################################
+
+    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.
+############################################################################## */
+
+#option ('targetClusterType', 'roxie');
+
+import sq;
+sq.declareCommon();
+
+//UseStandardFiles
+
+//Daft test of fetch retrieving a dataset
+myPeople := sqSimplePersonBookDs(surname <> '');
+
+recfp := {unsigned8 rfpos, sqSimplePersonBookDs};
+
+recfp makeRec3(sqSimplePersonBookDs L, myPeople R) := TRANSFORM
+    self.rfpos := R.filepos;
+    self.books := L.books+R.books;
+    self := L;
+END;
+
+// temporary hack to get around codegen optimizing platform(),once call into global (and therefore hthor) context.
+nononcelib :=
+    SERVICE
+varstring platform() : library='graph', include='eclhelper.hpp', ctxmethod, entrypoint='getPlatform';
+    END;
+
+recordof(sqSimplePersonBookDs) removeFp(recfp l) := TRANSFORM
+    SELF := l;
+END;
+sortIt(dataset(recfp) ds) := FUNCTION
+    RETURN IF(nononcelib.platform() = 'thor', PROJECT(SORT(ds, rfpos),removeFp(LEFT)), PROJECT(ds,removeFp(LEFT)));
+END;
+
+fetchit (dataset(sqSimplePersonBookExRec) ds, string sname) := FUNCTION
+   return fetch(ds, ds(surname=sname), right.filepos, makeRec3(left,right));
+END;
+
+fetched := fetchit( sqSimplePersonBookDs, 'Halliday' );
+
+output(sortIt(fetched));

+ 49 - 0
ecl/regress/fetchinfunc2.ecl

@@ -0,0 +1,49 @@
+/*##############################################################################
+
+    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.
+############################################################################## */
+
+#option ('targetClusterType', 'roxie');
+
+import sq;
+sq.declareCommon();
+
+//UseStandardFiles
+
+//Daft test of fetch retrieving a dataset
+myPeople := sqSimplePersonBookDs(surname <> '');
+
+recfp := {unsigned8 rfpos, sqSimplePersonBookDs};
+
+recfp makeRec3(sqSimplePersonBookDs L, myPeople R) := TRANSFORM
+    self.rfpos := R.filepos;
+    self.books := L.books+R.books;
+    self := L;
+END;
+
+// temporary hack to get around codegen optimizing platform(),once call into global (and therefore hthor) context.
+nononcelib :=
+    SERVICE
+varstring platform() : library='graph', include='eclhelper.hpp', ctxmethod, entrypoint='getPlatform';
+    END;
+
+fetchit (dataset(sqSimplePersonBookExRec) ds, string sname) := FUNCTION
+   return fetch(ds, ds(surname=sname), right.filepos, makeRec3(left,right));
+END;
+
+ds2 := nofold(dataset(100, transform(recordof(sqSimplePersonBookDs), SELF := [])));
+fetched := fetchit( ds2, 'Halliday' );
+
+output(fetched);

+ 8 - 1
testing/regress/ecl/fetch2.ecl

@@ -52,6 +52,12 @@ fetched := fetch(sq.SimplePersonBookDs, myPeople, right.filepos, makeRec(left, r
 fetched2 := fetch(sq.SimplePersonBookDs, myPeople, right.filepos, makeRec2(left, right));
 fetched3 := fetch(sq.SimplePersonBookDs, myPeople, right.filepos, makeRec3(left, right));
 
+fetchit (dataset(sq.SimplePersonBookExRec) ds, string sname) := FUNCTION
+   return fetch(ds, ds(surname=sname), right.filepos, makeRec3(left,right));
+END;
+
+fetched4 := fetchit( sq.SimplePersonBookDs, 'Halliday' );
+
 recordof(sq.SimplePersonBookDs) removeFp(recfp l) := TRANSFORM
     SELF := l;
 END;
@@ -62,5 +68,6 @@ END;
 sequential(
     output(sortIt(fetched)),
     output(sortIt(fetched2)),
-    output(sortIt(fetched3))
+    output(sortIt(fetched3)),
+    output(sortIt(fetched4))
 );

文件差异内容过多而无法显示
+ 5 - 0
testing/regress/ecl/key/fetch2.xml