Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HPCC-20328 Fix error for function with virtual dataset inside MODULE #11644

Merged
merged 1 commit into from Sep 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions ecl/hql/hqlexpr.cpp
Expand Up @@ -11241,6 +11241,12 @@ void CHqlTemplateFunctionContext::sethash()
HASHFIELD(context);
}

IHqlExpression * CHqlTemplateFunctionContext::clone(HqlExprArray &newkids)
{
assertex(newkids.ordinality() == 1);
return createTemplateFunctionContext(LINK(&newkids.item(0)), LINK(context));
}

//==============================================================================================================

extern IHqlExpression *createParameter(IIdAtom * id, unsigned idx, ITypeInfo *type, HqlExprArray & attrs)
Expand Down
7 changes: 3 additions & 4 deletions ecl/hql/hqlexpr.ipp
Expand Up @@ -1389,18 +1389,17 @@ class CHqlTemplateFunctionContext : public CHqlExpressionWithType
{
public:
CHqlTemplateFunctionContext(IHqlExpression* expr, IHqlScope* scope)
: CHqlExpressionWithType(no_template_context,expr->getType())
: CHqlExpressionWithType(no_template_context,expr->getType()), context(scope)
{
addOperand(expr);
context = scope;
}
~CHqlTemplateFunctionContext() { ::Release(context); }

virtual IHqlScope* queryScope() override { return context; }
virtual IHqlDataset* queryDataset() override { return queryChild(0)->queryDataset(); }
virtual IHqlExpression *clone(HqlExprArray &newkids) override;

protected:
IHqlScope* context; // allows symbols to be resolved when reparsing.
Owned<IHqlScope> context; // allows symbols to be resolved when reparsing.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to owned to make it clear that it retained ownership. (This code is very old...)

virtual void sethash();
};

Expand Down
26 changes: 26 additions & 0 deletions ecl/regress/issue20328.ecl
@@ -0,0 +1,26 @@
BaseModule := MODULE, VIRTUAL
EXPORT AppendUniqueID(VIRTUAL DATASET ds) := FUNCTION
ds1 := PROJECT
(
ds,
TRANSFORM
(
{
UNSIGNED6 gid,
RECORDOF(LEFT)
},
SELF.gid := COUNTER,
SELF := LEFT
)
);

RETURN ds1;
END;
END;

ChildModule := MODULE(BaseModule), VIRTUAL

END;

x := NOFOLD(DATASET(['a', 'b', 'c'], {STRING1 s}));
ChildModule.AppendUniqueID(x);