@@ -115,6 +115,23 @@ TExprNode::TPtr PruneCast(TExprNode::TPtr node) {
115115 return node;
116116}
117117
118+ TVector<TInfoUnit> GetHashableKeys (const std::shared_ptr<IOperator> &input) {
119+ if (!input->Type ) {
120+ return input->GetOutputIUs ();
121+ }
122+
123+ const auto *inputType = input->Type ;
124+ TVector<TInfoUnit> hashableKeys;
125+ const auto * structType = inputType->Cast <TListExprType>()->GetItemType ()->Cast <TStructExprType>();
126+ for (const auto &item : structType->GetItems ()) {
127+ if (item->GetItemType ()->IsHashable ()) {
128+ hashableKeys.push_back (TInfoUnit (TString (item->GetName ())));
129+ }
130+ }
131+
132+ return hashableKeys;
133+ }
134+
118135bool IsNullRejectingPredicate (const TFilterInfo &filter, TExprContext &ctx) {
119136 Y_UNUSED (ctx);
120137#ifdef DEBUG_PREDICATE
@@ -576,8 +593,9 @@ bool TAssignStagesRule::TestAndApply(std::shared_ptr<IOperator> &input, TRBOCont
576593 const auto newStageId = props.StageGraph .AddStage ();
577594 aggregate->Props .StageId = newStageId;
578595 const bool isInputSourceStage = props.StageGraph .IsSourceStage (inputStageId);
596+ const auto shuffleKeys = aggregate->KeyColumns .size () ? aggregate->KeyColumns : GetHashableKeys (aggregate->GetInput ());
579597
580- props.StageGraph .Connect (inputStageId, newStageId, std::make_shared<TShuffleConnection>(aggregate-> KeyColumns , isInputSourceStage));
598+ props.StageGraph .Connect (inputStageId, newStageId, std::make_shared<TShuffleConnection>(shuffleKeys , isInputSourceStage));
581599 YQL_CLOG (TRACE, CoreDq) << " Assign stage to Aggregation " ;
582600 } else {
583601 Y_ENSURE (false , " Unknown operator encountered" );
0 commit comments