@@ -409,6 +409,28 @@ RowVectorPtr CudfHashJoinProbe::getOutput() {
409409 auto leftTableView = leftTable->view ();
410410 auto rightTableView = rightTable->view ();
411411
412+ // print the tables
413+ auto probeType = joinNode_->sources ()[0 ]->outputType ();
414+ auto buildType = joinNode_->sources ()[1 ]->outputType ();
415+ if (std::getenv (" PRINT_TABLES" ) != nullptr && std::string (std::getenv (" PRINT_TABLES" )) == " 1" ) {
416+ std::lock_guard<std::mutex> lock (probePrintMutex_);
417+ // move the table with toVeloxColumn and print it
418+ auto veloxTable = with_arrow::toVeloxColumn (leftTable->view (), pool (), probeType->asRow ().names (), stream);
419+ std::cout << " Left table: " << veloxTable->toString () << std::endl;
420+ // print each row in the velox table
421+ for (int i = 0 ; i < veloxTable->size (); i++) {
422+ std::cout << " Row " << std::setw (3 ) << i << " : " << veloxTable->toString (i) << std::endl;
423+ }
424+ // do it for right table
425+ auto veloxTable2 = with_arrow::toVeloxColumn (rightTable->view (), pool (), buildType->asRow ().names (), stream);
426+ std::cout << " Right table: " << veloxTable2->toString () << std::endl;
427+ // print each row in the velox table
428+ for (int i = 0 ; i < veloxTable2->size (); i++) {
429+ std::cout << " Row " << std::setw (3 ) << i << " : " << veloxTable2->toString (i) << std::endl;
430+ }
431+ std::cout << std::flush;
432+ }
433+
412434 if (joinNode_->isInnerJoin ()) {
413435 // left = probe, right = build
414436 if (joinNode_->filter ()) {
@@ -512,6 +534,27 @@ RowVectorPtr CudfHashJoinProbe::getOutput() {
512534 cudf::get_current_device_resource_ref ());
513535 } else {
514536 rightJoinIndices = cudf::left_semi_join (
537+
538+ // print the left indices
539+ if (std::getenv (" PRINT_TABLES" ) != nullptr && std::string (std::getenv (" PRINT_TABLES" )) == " 1" ) {
540+ std::lock_guard<std::mutex> lock (probePrintMutex_);
541+ // move the table with toVeloxColumn and print it
542+ auto veloxTable = with_arrow::toVeloxColumn (cudf::table_view{{leftIndicesCol}}, pool (), " left_indices" , stream);
543+ std::cout << " Left indices: " << veloxTable->toString () << std::endl;
544+ // print each row in the velox table
545+ for (int i = 0 ; i < veloxTable->size (); i++) {
546+ std::cout << " Row " << std::setw (3 ) << i << " : " << veloxTable->toString (i) << std::endl;
547+ }
548+ // do it for right table
549+ auto veloxTable2 = with_arrow::toVeloxColumn (cudf::table_view{{rightIndicesCol}}, pool (), " right_indices" , stream);
550+ std::cout << " Right indices: " << veloxTable2->toString () << std::endl;
551+ // print each row in the velox table
552+ for (int i = 0 ; i < veloxTable2->size (); i++) {
553+ std::cout << " Row " << std::setw (3 ) << i << " : " << veloxTable2->toString (i) << std::endl;
554+ }
555+ std::cout << std::flush;
556+ }
557+
515558 rightTableView.select (rightKeyIndices_),
516559 leftTableView.select (leftKeyIndices_),
517560 cudf::null_equality::EQUAL,
@@ -534,6 +577,27 @@ RowVectorPtr CudfHashJoinProbe::getOutput() {
534577 auto leftIndicesCol = cudf::column_view{leftIndicesSpan};
535578 auto rightIndicesCol = cudf::column_view{rightIndicesSpan};
536579 auto constexpr oobPolicy = cudf::out_of_bounds_policy::NULLIFY;
580+
581+ // print the left indices
582+ if (std::getenv (" PRINT_TABLES" ) != nullptr && std::string (std::getenv (" PRINT_TABLES" )) == " 1" ) {
583+ std::lock_guard<std::mutex> lock (probePrintMutex_);
584+ // move the table with toVeloxColumn and print it
585+ auto veloxTable = with_arrow::toVeloxColumn (cudf::table_view{{leftIndicesCol}}, pool (), " left_indices" , stream);
586+ std::cout << " Left indices: " << veloxTable->toString () << std::endl;
587+ // print each row in the velox table
588+ for (int i = 0 ; i < veloxTable->size (); i++) {
589+ std::cout << " Row " << std::setw (3 ) << i << " : " << veloxTable->toString (i) << std::endl;
590+ }
591+ // do it for right table
592+ auto veloxTable2 = with_arrow::toVeloxColumn (cudf::table_view{{rightIndicesCol}}, pool (), " right_indices" , stream);
593+ std::cout << " Right indices: " << veloxTable2->toString () << std::endl;
594+ // print each row in the velox table
595+ for (int i = 0 ; i < veloxTable2->size (); i++) {
596+ std::cout << " Row " << std::setw (3 ) << i << " : " << veloxTable2->toString (i) << std::endl;
597+ }
598+ std::cout << std::flush;
599+ }
600+
537601 auto leftResult = cudf::gather (leftInput, leftIndicesCol, oobPolicy, stream);
538602 auto rightResult =
539603 cudf::gather (rightInput, rightIndicesCol, oobPolicy, stream);
@@ -558,6 +622,18 @@ RowVectorPtr CudfHashJoinProbe::getOutput() {
558622 auto cudfOutput = std::make_unique<cudf::table>(std::move (joinedCols));
559623 stream.synchronize ();
560624
625+ // print the output
626+ if (std::getenv (" PRINT_TABLES" ) != nullptr && std::string (std::getenv (" PRINT_TABLES" )) == " 1" ) {
627+ std::lock_guard<std::mutex> lock (probePrintMutex_);
628+ auto veloxTable = with_arrow::toVeloxColumn (cudfOutput->view (), pool (), outputType_->asRow ().names (), stream);
629+ std::cout << " Output table: " << veloxTable->toString () << std::endl;
630+ // print each row in the velox table
631+ for (int i = 0 ; i < veloxTable->size (); i++) {
632+ std::cout << " Row " << std::setw (3 ) << i << " : " << veloxTable->toString (i) << std::endl;
633+ }
634+ std::cout << std::flush;
635+ }
636+
561637 input_.reset ();
562638 finished_ = noMoreInput_;
563639
0 commit comments