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-32940 Allow keyed joins to conditional keys in roxie #19270

Open
wants to merge 1 commit into
base: candidate-9.6.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions ecl/hqlcpp/hqlckey.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,22 @@ IHqlExpression * KeyedJoinInfo::querySimplifiedKey(IHqlExpression * expr)
}
}

IHqlExpression * queryBaseIndexForKeyedJoin(IHqlExpression * expr)
{
if (expr->getOperator() == no_if)
{
IHqlExpression * left = queryBaseIndexForKeyedJoin(expr->queryChild(1));
IHqlExpression * right = queryBaseIndexForKeyedJoin(expr->queryChild(2));
if (left && right)
return left;
return nullptr;
}
return queryPhysicalRootTable(expr);
}

IHqlExpression * KeyedJoinInfo::createKeyFromComplexKey(IHqlExpression * expr)
{
IHqlExpression * base = queryPhysicalRootTable(expr);
IHqlExpression * base = queryBaseIndexForKeyedJoin(expr);
if (!base)
{
translator.throwError1(HQLERR_KeyedJoinNoRightIndex_X, getOpString(expr->getOperator()));
Expand Down Expand Up @@ -1232,7 +1245,7 @@ void HqlCppTranslator::buildKeyJoinIndexReadHelper(ActivityInstance & instance,
buildFilenameFunction(instance, instance.startctx, WaIndexname, "getIndexFileName", info->queryKeyFilename(), hasDynamicFilename(info->queryKey()));

//virtual IOutputMetaData * queryIndexRecordSize() = 0;
LinkedHqlExpr indexExpr = info->queryOriginalKey();
LinkedHqlExpr indexExpr = info->queryKey();
OwnedHqlExpr serializedRecord;
unsigned numPayload = numPayloadFields(indexExpr);
if (numPayload)
Expand Down
8 changes: 6 additions & 2 deletions roxie/ccd/ccdactivities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,12 @@ class CRoxieAgentActivity : implements CInterfaceOf<IRoxieAgentActivity>, implem
unsigned checksum;
serializedCreate.read(checksum);
OwnedRoxieString fname(queryDynamicFileName());
varFileInfo.setown(queryAgentDynamicFileCache()->lookupDynamicFile(logctx, fname, cacheDate, checksum, &packet->queryHeader(), isOpt, true));
setVariableFileInfo();
if (fname)
{
//fname may not be set if the index is being provided by another activity
varFileInfo.setown(queryAgentDynamicFileCache()->lookupDynamicFile(logctx, fname, cacheDate, checksum, &packet->queryHeader(), isOpt, true));
setVariableFileInfo();
}
}
}

Expand Down
1 change: 1 addition & 0 deletions roxie/ccd/ccdfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3576,6 +3576,7 @@ class CAgentDynamicFileCache : implements IAgentDynamicFileCache, public CInterf

virtual IResolvedFile *lookupDynamicFile(const IRoxieContextLogger &logctx, const char *lfn, CDateTime &cacheDate, unsigned checksum, RoxiePacketHeader *header, bool isOpt, bool isLocal) override
{
assertex(lfn);
if (doTrace(traceRoxieFiles))
{
StringBuffer s;
Expand Down
13 changes: 12 additions & 1 deletion testing/regress/ecl/keyed_join6.ecl
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@
//version multiPart=true
//version multiPart=true,useLocal=true
//version multiPart=true,useTranslation=true
//version multiPart=false,conditional=true,nothor,nohthor
//version multiPart=true,conditional=true,nothor,nohthor

import ^ as root;
multiPart := #IFDEFINED(root.multiPart, true);
useLocal := #IFDEFINED(root.useLocal, true);
useTranslation := #IFDEFINED(root.useTranslation, false);
conditional := #IFDEFINED(root.conditional, false);

//--- end of version configuration ---

Expand All @@ -52,4 +55,12 @@ inDs := DATASET([
], inRecord);


output(JOIN(inDs, Files.DG_IntIndex, KEYED(RIGHT.DG_parentId = (integer)LEFT.s.v AND RIGHT.DG_parentId = LEFT.i.v)));
#if (conditional)
trueValue := true : stored('trueValue');
indexAlias := INDEX(Files.DG_IntIndex, 'indexAlias', OPT);
joinIndex := IF(trueValue, Files.DG_IntIndex, indexAlias);
#else
joinIndex := Files.DG_IntIndex;
#end

output(JOIN(inDs, joinIndex, KEYED(RIGHT.DG_parentId = (integer)LEFT.s.v AND RIGHT.DG_parentId = LEFT.i.v)));
Loading